mirror of
https://github.com/clangen/musikcube.git
synced 2024-11-19 20:13:36 +00:00
Fixed a bug that could result in Player threads being unable to terminate.
This commit is contained in:
parent
deddc410a0
commit
c6610585b7
@ -127,6 +127,8 @@ void Player::ThreadLoop() {
|
||||
/* create and open the stream */
|
||||
this->stream = Stream::Create();
|
||||
|
||||
BufferPtr buffer;
|
||||
|
||||
if (this->stream->OpenStream(this->url)) {
|
||||
/* precache until buffers are full */
|
||||
bool keepPrecaching = true;
|
||||
@ -146,7 +148,6 @@ void Player::ThreadLoop() {
|
||||
|
||||
/* we're ready to go.... */
|
||||
bool finished = false;
|
||||
BufferPtr buffer;
|
||||
|
||||
while (!finished && !this->Exited()) {
|
||||
/* see if we've been asked to seek since the last sample was
|
||||
@ -166,7 +167,7 @@ void Player::ThreadLoop() {
|
||||
|
||||
/* if we've allocated a buffer, but it hasn't been written
|
||||
to the output yet, unlock it. this is an important step, and if
|
||||
not performed, will result in a deadlock just below while
|
||||
not performed, will result in a deadlock just below while
|
||||
waiting for all buffers to complete. */
|
||||
if (buffer) {
|
||||
this->OnBufferProcessed(buffer.get());
|
||||
@ -252,6 +253,12 @@ void Player::ThreadLoop() {
|
||||
|
||||
this->state = Player::Quit;
|
||||
|
||||
/* unlock any remaining buffers... see comment above */
|
||||
if (buffer) {
|
||||
this->OnBufferProcessed(buffer.get());
|
||||
buffer.reset();
|
||||
}
|
||||
|
||||
/* wait until all remaining buffers have been written, set final state... */
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->queueMutex);
|
||||
|
Loading…
Reference in New Issue
Block a user