mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-05 12:54:02 +00:00
Fixed another deadlock in Player.cpp. Hopefully this is the last one.
This commit is contained in:
parent
e15d4118ef
commit
0f8fd82a5b
@ -164,6 +164,15 @@ void Player::ThreadLoop() {
|
||||
this->output->Stop(); /* flush all buffers */
|
||||
this->output->Resume(); /* start it back up */
|
||||
|
||||
/* 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
|
||||
waiting for all buffers to complete. */
|
||||
if (buffer) {
|
||||
this->OnBufferProcessed(buffer.get());
|
||||
buffer.reset();
|
||||
}
|
||||
|
||||
{
|
||||
boost::mutex::scoped_lock lock(this->queueMutex);
|
||||
|
||||
@ -178,8 +187,6 @@ void Player::ThreadLoop() {
|
||||
boost::mutex::scoped_lock lock(this->queueMutex);
|
||||
this->prebufferQueue.clear();
|
||||
}
|
||||
|
||||
buffer.reset();
|
||||
}
|
||||
|
||||
/* let's see if we can find some samples to play */
|
||||
@ -195,6 +202,11 @@ void Player::ThreadLoop() {
|
||||
else {
|
||||
buffer = this->stream->GetNextProcessedOutputBuffer();
|
||||
}
|
||||
|
||||
/* lock it down until it's processed */
|
||||
if (buffer) {
|
||||
this->lockedBuffers.push_back(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
/* if we have a decoded, processed buffer available. let's try to send it to
|
||||
@ -205,7 +217,6 @@ void Player::ThreadLoop() {
|
||||
/* lock it down so it's not destroyed until the output device lets us
|
||||
know it's done with it. */
|
||||
boost::mutex::scoped_lock lock(this->queueMutex);
|
||||
this->lockedBuffers.push_back(buffer);
|
||||
|
||||
if (this->lockedBuffers.size() == 1) {
|
||||
this->currentPosition = buffer->Position();
|
||||
|
Loading…
Reference in New Issue
Block a user