mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-16 22:13:19 +00:00
Fixed a couple bugs that prevented auto-advancing from working properly.
This commit is contained in:
parent
6326162ee0
commit
54192079ed
@ -258,6 +258,8 @@ void Player::ThreadLoop() {
|
||||
this->PlaybackError(this);
|
||||
}
|
||||
|
||||
bool stopped = false;
|
||||
|
||||
/* wait until all remaining buffers have been written, set final state... */
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->mutex);
|
||||
@ -272,12 +274,13 @@ void Player::ThreadLoop() {
|
||||
while (this->lockedBuffers.size() > 0) {
|
||||
writeToOutputCondition.wait(this->mutex);
|
||||
}
|
||||
|
||||
this->state = Player::Quit;
|
||||
}
|
||||
|
||||
stopped = (this->state == Player::Quit);
|
||||
this->state = Player::Quit;
|
||||
}
|
||||
|
||||
if (this->Exited()) {
|
||||
if (stopped) {
|
||||
this->PlaybackStopped(this);
|
||||
}
|
||||
else {
|
||||
|
@ -11,7 +11,6 @@ using musik::core::audio::Transport;
|
||||
using namespace musik::core::library::constants;
|
||||
|
||||
#define URI_AT_INDEX(x) this->playlist.at(x)->URI()
|
||||
#define MESSAGE_START_NEXT_TRACK 1234
|
||||
#define PREVIOUS_GRACE_PERIOD 2.0f
|
||||
|
||||
class StreamEvent : public IMessage {
|
||||
@ -24,14 +23,8 @@ PlaybackService::PlaybackService(Transport& transport)
|
||||
this->index = (size_t) -1;
|
||||
}
|
||||
|
||||
|
||||
void PlaybackService::ProcessMessage(IMessage &message) {
|
||||
if (message.MessageType() == MESSAGE_START_NEXT_TRACK) {
|
||||
if (!Next()) {
|
||||
transport.Stop();
|
||||
index = (size_t)-1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool PlaybackService::Next() {
|
||||
@ -79,14 +72,10 @@ void PlaybackService::Play(size_t index) {
|
||||
}
|
||||
|
||||
void PlaybackService::OnStreamEvent(int eventType, std::string uri) {
|
||||
if (eventType == Transport::StreamFinished) {
|
||||
MessageQueue::Instance().Post(
|
||||
Message::Create(this, MESSAGE_START_NEXT_TRACK, 0, 0));
|
||||
if (eventType == Transport::StreamAlmostDone) {
|
||||
if (this->playlist.size() > this->index + 1) {
|
||||
this->transport.PrepareNextTrack(URI_AT_INDEX(index + 1));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
//if (eventType == Transport::StreamAlmostDone) {
|
||||
// if (this->playlist.size() > this->index + 1) {
|
||||
// this->transport.PrepareNextTrack(URI_AT_INDEX(index + 1));
|
||||
// index++;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user