mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-29 03:32:42 +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);
|
this->PlaybackError(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool stopped = false;
|
||||||
|
|
||||||
/* wait until all remaining buffers have been written, set final state... */
|
/* wait until all remaining buffers have been written, set final state... */
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(this->mutex);
|
boost::mutex::scoped_lock lock(this->mutex);
|
||||||
@ -272,12 +274,13 @@ void Player::ThreadLoop() {
|
|||||||
while (this->lockedBuffers.size() > 0) {
|
while (this->lockedBuffers.size() > 0) {
|
||||||
writeToOutputCondition.wait(this->mutex);
|
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);
|
this->PlaybackStopped(this);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -11,7 +11,6 @@ using musik::core::audio::Transport;
|
|||||||
using namespace musik::core::library::constants;
|
using namespace musik::core::library::constants;
|
||||||
|
|
||||||
#define URI_AT_INDEX(x) this->playlist.at(x)->URI()
|
#define URI_AT_INDEX(x) this->playlist.at(x)->URI()
|
||||||
#define MESSAGE_START_NEXT_TRACK 1234
|
|
||||||
#define PREVIOUS_GRACE_PERIOD 2.0f
|
#define PREVIOUS_GRACE_PERIOD 2.0f
|
||||||
|
|
||||||
class StreamEvent : public IMessage {
|
class StreamEvent : public IMessage {
|
||||||
@ -24,14 +23,8 @@ PlaybackService::PlaybackService(Transport& transport)
|
|||||||
this->index = (size_t) -1;
|
this->index = (size_t) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PlaybackService::ProcessMessage(IMessage &message) {
|
void PlaybackService::ProcessMessage(IMessage &message) {
|
||||||
if (message.MessageType() == MESSAGE_START_NEXT_TRACK) {
|
|
||||||
if (!Next()) {
|
|
||||||
transport.Stop();
|
|
||||||
index = (size_t)-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlaybackService::Next() {
|
bool PlaybackService::Next() {
|
||||||
@ -79,14 +72,10 @@ void PlaybackService::Play(size_t index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackService::OnStreamEvent(int eventType, std::string uri) {
|
void PlaybackService::OnStreamEvent(int eventType, std::string uri) {
|
||||||
if (eventType == Transport::StreamFinished) {
|
if (eventType == Transport::StreamAlmostDone) {
|
||||||
MessageQueue::Instance().Post(
|
if (this->playlist.size() > this->index + 1) {
|
||||||
Message::Create(this, MESSAGE_START_NEXT_TRACK, 0, 0));
|
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…
x
Reference in New Issue
Block a user