Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix current track display/broadcasting/recording when starting auto-DJ #3500

Merged
merged 1 commit into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/mixer/playerinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ void PlayerInfo::setTrackInfo(const QString& group, const TrackPointer& track) {
emit trackUnloaded(group, pOld);
}
emit trackLoaded(group, track);

if (m_currentlyPlayingDeck >= 0 &&
group == PlayerManager::groupForDeck(m_currentlyPlayingDeck)) {
emit currentPlayingTrackChanged(track);
}
}

bool PlayerInfo::isTrackLoaded(const TrackPointer& pTrack) const {
Expand Down Expand Up @@ -113,6 +118,17 @@ void PlayerInfo::updateCurrentPlayingDeck() {
double maxVolume = 0;
int maxDeck = -1;

CSAMPLE_GAIN xfl, xfr;
// TODO: supply correct parameters to the function. If the hamster style
// for the crossfader is enabled, the result is currently wrong.
EngineXfader::getXfadeGains(m_pCOxfader->get(),
1.0,
0.0,
MIXXX_XFADER_ADDITIVE,
false,
&xfl,
&xfr);

for (int i = 0; i < (int)PlayerManager::numDecks(); ++i) {
DeckControls* pDc = getDeckControls(i);

Expand All @@ -129,12 +145,6 @@ void PlayerInfo::updateCurrentPlayingDeck() {
continue;
}

CSAMPLE_GAIN xfl, xfr;
// TODO: supply correct parameters to the function. If the hamster style
// for the crossfader is enabled, the result is currently wrong.
EngineXfader::getXfadeGains(m_pCOxfader->get(), 1.0, 0.0, MIXXX_XFADER_ADDITIVE, false,
&xfl, &xfr);

const auto orient = static_cast<int>(pDc->m_orientation.get());
double xfvol;
if (orient == EngineChannel::LEFT) {
Expand All @@ -151,16 +161,16 @@ void PlayerInfo::updateCurrentPlayingDeck() {
maxVolume = dvol;
}
}
if (maxDeck != m_currentlyPlayingDeck) {
m_currentlyPlayingDeck = maxDeck;
locker.unlock();
locker.unlock();

int oldDeck = m_currentlyPlayingDeck.fetchAndStoreRelease(maxDeck);
if (maxDeck != oldDeck) {
emit currentPlayingDeckChanged(maxDeck);
emit currentPlayingTrackChanged(getCurrentPlayingTrack());
}
}

int PlayerInfo::getCurrentPlayingDeck() {
QMutexLocker locker(&m_mutex);
return m_currentlyPlayingDeck;
}

Expand Down
3 changes: 2 additions & 1 deletion src/mixer/playerinfo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Helper class to have easy access
#pragma once

#include <QAtomicInt>
#include <QMap>
#include <QMutex>
#include <QObject>
Expand Down Expand Up @@ -57,7 +58,7 @@ class PlayerInfo : public QObject {
ControlProxy* m_pCOxfader;
// QMap is faster than QHash for small count of elements < 50
QMap<QString, TrackPointer> m_loadedTrackMap;
int m_currentlyPlayingDeck;
QAtomicInt m_currentlyPlayingDeck;
QList<DeckControls*> m_deckControlList;

static PlayerInfo* m_pPlayerinfo;
Expand Down