AudioStream: Don't call FramesAvailable() while locked
This commit is contained in:
parent
7b4b2d5dc5
commit
444a09efd4
|
@ -80,19 +80,20 @@ void AudioStream::BeginWrite(SampleType** buffer_ptr, u32* num_frames)
|
|||
void AudioStream::WriteFrames(const SampleType* frames, u32 num_frames)
|
||||
{
|
||||
const u32 num_samples = num_frames * m_channels;
|
||||
std::unique_lock<std::mutex> lock(m_buffer_mutex);
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_buffer_mutex);
|
||||
EnsureBuffer(num_samples);
|
||||
m_buffer.PushRange(frames, num_samples);
|
||||
}
|
||||
|
||||
EnsureBuffer(num_samples);
|
||||
m_buffer.PushRange(frames, num_samples);
|
||||
FramesAvailable();
|
||||
}
|
||||
|
||||
void AudioStream::EndWrite(u32 num_frames)
|
||||
{
|
||||
m_buffer.AdvanceTail(num_frames * m_channels);
|
||||
FramesAvailable();
|
||||
|
||||
m_buffer_mutex.unlock();
|
||||
FramesAvailable();
|
||||
}
|
||||
|
||||
float AudioStream::GetMaxLatency(u32 sample_rate, u32 buffer_size)
|
||||
|
@ -209,6 +210,7 @@ void AudioStream::EnsureBuffer(u32 size)
|
|||
|
||||
void AudioStream::DropFrames(u32 count)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(m_buffer_mutex);
|
||||
m_buffer.Remove(count);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ void NullAudioStream::CloseDevice() {}
|
|||
void NullAudioStream::FramesAvailable()
|
||||
{
|
||||
// drop any buffer as soon as they're available
|
||||
DropFrames(GetSamplesAvailableLocked());
|
||||
DropFrames(GetSamplesAvailable());
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioStream> AudioStream::CreateNullAudioStream()
|
||||
|
|
Loading…
Reference in New Issue