mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-23 06:15:38 +00:00
AudioStream: Fix a crash when opening device fails
This commit is contained in:
parent
ae49215251
commit
357235404a
|
@ -35,7 +35,7 @@ bool AudioStream::Reconfigure(u32 input_sample_rate /* = DefaultInputSampleRate
|
|||
|
||||
if (!OpenDevice())
|
||||
{
|
||||
EmptyBuffers();
|
||||
LockedEmptyBuffers();
|
||||
m_buffer_size = 0;
|
||||
m_output_sample_rate = 0;
|
||||
m_channels = 0;
|
||||
|
@ -289,6 +289,11 @@ void AudioStream::EmptyBuffers()
|
|||
{
|
||||
std::unique_lock<std::mutex> lock(m_buffer_mutex);
|
||||
std::unique_lock<std::mutex> resampler_lock(m_resampler_mutex);
|
||||
LockedEmptyBuffers();
|
||||
}
|
||||
|
||||
void AudioStream::LockedEmptyBuffers()
|
||||
{
|
||||
m_buffer.Clear();
|
||||
m_underflow_flag.store(false);
|
||||
m_buffer_filling.store(m_wait_for_buffer_fill);
|
||||
|
|
|
@ -75,6 +75,7 @@ protected:
|
|||
bool SetBufferSize(u32 buffer_size);
|
||||
bool IsDeviceOpen() const { return (m_output_sample_rate > 0); }
|
||||
|
||||
void LockedEmptyBuffers();
|
||||
u32 GetSamplesAvailable() const;
|
||||
u32 GetSamplesAvailableLocked() const;
|
||||
void ReadFrames(SampleType* samples, u32 num_frames, bool apply_volume);
|
||||
|
|
Loading…
Reference in a new issue