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:
casey 2016-06-01 01:32:12 -07:00
parent c1d902766d
commit 6ec0a8042b
2 changed files with 15 additions and 2 deletions

View File

@ -85,8 +85,20 @@ Transport::PlaybackState Transport::GetPlaybackState() {
}
void Transport::PrepareNextTrack(const std::string& trackUrl) {
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) {

View File

@ -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();