From 570cf968ebaa00c5b1e88f7daff3ca2e2cbfacda Mon Sep 17 00:00:00 2001 From: Pengyu Liao Date: Mon, 27 Nov 2017 15:15:53 -0800 Subject: [PATCH] Fix playout (recording from caller point of view) functionality for FileAudioDevice. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:8585 Change-Id: Ied2cbea146560488b07ac74bd3c5009f8804f1a0 Reviewed-on: https://webrtc-review.googlesource.com/26440 Commit-Queue: Patrik Höglund Reviewed-by: Henrik Andreassson Reviewed-by: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#20927} --- modules/audio_device/dummy/file_audio_device.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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() {