Browse Source

Fix for BufferingAudioSource.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
427941e8c3
3 changed files with 19 additions and 3 deletions
  1. +2
    -3
      modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp
  2. +11
    -0
      modules/juce_core/threads/juce_TimeSliceThread.cpp
  3. +6
    -0
      modules/juce_core/threads/juce_TimeSliceThread.h

+ 2
- 3
modules/juce_audio_basics/sources/juce_BufferingAudioSource.cpp 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()


+ 11
- 0
modules/juce_core/threads/juce_TimeSliceThread.cpp 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();


+ 6
- 0
modules/juce_core/threads/juce_TimeSliceThread.h 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;


Loading…
Cancel
Save