summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-01-01 10:27:22 +0100
committerGitHub <noreply@github.com>2021-01-01 10:27:22 +0100
commitf5873fd2f2352cc6c2e860dd39cb262c8dcae417 (patch)
tree626c92fa98cd5321f6ad02b34ff2d64bcf112c1d /src
parentb784a4dae958d4c5e618d5bbd1c782b1584f1108 (diff)
parent1add09b52fc89d9d64cb60ca57aeeb822d3ad541 (diff)
Merge pull request #3500 from daschuer/current_track_fix
Fix current track display/broadcasting/recording when starting auto-DJ
Diffstat (limited to 'src')
-rw-r--r--src/mixer/playerinfo.cpp30
-rw-r--r--src/mixer/playerinfo.h3
2 files changed, 22 insertions, 11 deletions
diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp
index 91b2bfc42c..93e43db93a 100644
--- a/src/mixer/playerinfo.cpp
+++ b/src/mixer/playerinfo.cpp
@@ -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 {
@@ -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);
@@ -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) {
@@ -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;
}
diff --git a/src/mixer/playerinfo.h b/src/mixer/playerinfo.h
index 2b06412cb0..7fc1035fcc 100644
--- a/src/mixer/playerinfo.h
+++ b/src/mixer/playerinfo.h
@@ -1,6 +1,7 @@
// Helper class to have easy access
#pragma once
+#include <QAtomicInt>
#include <QMap>
#include <QMutex>
#include <QObject>
@@ -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;