diff --git a/modules/audio_device/dummy/file_audio_device.cc b/modules/audio_device/dummy/file_audio_device.cc index af9b569257..e02ec6ccb7 100644 --- a/modules/audio_device/dummy/file_audio_device.cc +++ b/modules/audio_device/dummy/file_audio_device.cc @@ -140,6 +140,14 @@ int32_t FileAudioDevice::PlayoutIsAvailable(bool& available) { } int32_t FileAudioDevice::InitPlayout() { + rtc::CritScope lock(&_critSect); + + if (_playing) { + return -1; + } + + _playoutFramesIn10MS = static_cast(kPlayoutFixedSampleRate / 100); + if (_ptrAudioBuffer) { // Update webrtc audio buffer with the selected parameters _ptrAudioBuffer->SetPlayoutSampleRate(kPlayoutFixedSampleRate); @@ -149,7 +157,7 @@ int32_t FileAudioDevice::InitPlayout() { } bool FileAudioDevice::PlayoutIsInitialized() const { - return true; + return _playoutFramesIn10MS != 0; } int32_t FileAudioDevice::RecordingIsAvailable(bool& available) { @@ -186,7 +194,6 @@ int32_t FileAudioDevice::StartPlayout() { return 0; } - _playoutFramesIn10MS = static_cast(kPlayoutFixedSampleRate / 100); _playing = true; _playoutFramesLeft = 0; @@ -243,7 +250,7 @@ int32_t FileAudioDevice::StopPlayout() { } bool FileAudioDevice::Playing() const { - return true; + return _playing; } int32_t FileAudioDevice::StartRecording() {