1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Fix for BufferingAudioSource.

This commit is contained in:
Julian Storer 2011-09-11 20:28:26 +01:00
parent 79090d1017
commit 427941e8c3
3 changed files with 19 additions and 3 deletions

View file

@ -80,7 +80,7 @@ void BufferingAudioSource::prepareToPlay (int samplesPerBlockExpected, double sa
while (bufferValidEnd - bufferValidStart < jmin (((int) sampleRate_) / 4,
buffer.getNumSamples() / 2))
{
backgroundThread.addTimeSliceClient (this);
backgroundThread.moveToFrontOfQueue (this);
Thread::sleep (5);
}
}
@ -168,8 +168,7 @@ void BufferingAudioSource::setNextReadPosition (int64 newPosition)
const ScopedLock sl (bufferStartPosLock);
nextPlayPos = newPosition;
backgroundThread.addTimeSliceClient (this);
backgroundThread.moveToFrontOfQueue (this);
}
bool BufferingAudioSource::readNextBufferChunk()

View file

@ -70,6 +70,17 @@ void TimeSliceThread::removeTimeSliceClient (TimeSliceClient* const client)
}
}
void TimeSliceThread::moveToFrontOfQueue (TimeSliceClient* client)
{
const ScopedLock sl (listLock);
if (clients.contains (client))
{
client->nextCallTime = Time::getCurrentTime();
notify();
}
}
int TimeSliceThread::getNumClients() const
{
return clients.size();

View file

@ -117,6 +117,12 @@ public:
*/
void removeTimeSliceClient (TimeSliceClient* client);
/** If the given client is waiting in the queue, it will be moved to the front
and given a time-slice as soon as possible.
If the specified client has not been added, nothing will happen.
*/
void moveToFrontOfQueue (TimeSliceClient* client);
/** Returns the number of registered clients. */
int getNumClients() const;