mirror of
https://github.com/clangen/musikcube.git
synced 2025-02-11 09:40:26 +00:00
Moving to a better asynchronous model and fixing those deadlocks
uncovered a handful of bugs. Hopefully this is the last one -- ensure the next prepared track always gets played.
This commit is contained in:
parent
c1d902766d
commit
6ec0a8042b
@ -85,8 +85,20 @@ Transport::PlaybackState Transport::GetPlaybackState() {
|
||||
}
|
||||
|
||||
void Transport::PrepareNextTrack(const std::string& trackUrl) {
|
||||
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
|
||||
this->nextPlayer = new Player(trackUrl, this->volume, this->output);
|
||||
bool startNext = false;
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock(this->stateMutex);
|
||||
this->nextPlayer = new Player(trackUrl, this->volume, this->output);
|
||||
startNext = this->state == PlaybackStopped;
|
||||
}
|
||||
|
||||
/* we raise an event when the current stream has almost finished, which
|
||||
allows the calling app to prepare a new track. by the time this preparation
|
||||
is complete, the track may have ended. if we're in the stopped state, start
|
||||
playback of this new track immediately. */
|
||||
if (startNext) {
|
||||
this->StartWithPlayer(this->nextPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
void Transport::Start(const std::string& url) {
|
||||
|
@ -68,6 +68,7 @@ namespace musik { namespace core { namespace audio {
|
||||
~Transport();
|
||||
|
||||
void PrepareNextTrack(const std::string& trackUrl);
|
||||
|
||||
void Start(const std::string& trackUrl);
|
||||
void Stop();
|
||||
bool Pause();
|
||||
|
Loading…
x
Reference in New Issue
Block a user