From 4de777ba2bbf00ab5e26ca7d8052572d6d893081 Mon Sep 17 00:00:00 2001 From: "braveyao@webrtc.org" Date: Fri, 15 Jun 2012 02:37:53 +0000 Subject: [PATCH] Refine the error processing of StopRecordingMicrophone. BUG = TEST = Review URL: https://webrtc-codereview.appspot.com/636007 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2406 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/voice_engine/main/source/transmit_mixer.cc | 4 ++-- src/voice_engine/main/source/voe_file_impl.cc | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/voice_engine/main/source/transmit_mixer.cc b/src/voice_engine/main/source/transmit_mixer.cc index 946574959..3ea1a8415 100644 --- a/src/voice_engine/main/source/transmit_mixer.cc +++ b/src/voice_engine/main/source/transmit_mixer.cc @@ -879,9 +879,9 @@ int TransmitMixer::StopRecordingMicrophone() if (!_fileRecording) { - WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId, -1), + WEBRTC_TRACE(kTraceWarning, kTraceVoice, VoEId(_instanceId, -1), "StopRecordingMicrophone() isnot recording"); - return -1; + return 0; } CriticalSectionScoped cs(&_critSect); diff --git a/src/voice_engine/main/source/voe_file_impl.cc b/src/voice_engine/main/source/voe_file_impl.cc index af5a19cc6..8f0061faa 100644 --- a/src/voice_engine/main/source/voe_file_impl.cc +++ b/src/voice_engine/main/source/voe_file_impl.cc @@ -614,6 +614,11 @@ int VoEFileImpl::StopRecordingMicrophone() _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } + + int err = 0; + + // TODO(xians): consider removing Start/StopRecording() in + // Start/StopRecordingMicrophone() if no channel is recording. if (_shared->NumOfSendingChannels() == 0 && _shared->audio_device()->Recording()) { @@ -622,10 +627,19 @@ int VoEFileImpl::StopRecordingMicrophone() { _shared->SetLastError(VE_CANNOT_STOP_RECORDING, kTraceError, "StopRecordingMicrophone() failed to stop recording"); - return -1; + err = -1; } } - return _shared->transmit_mixer()->StopRecordingMicrophone(); + + if (_shared->transmit_mixer()->StopRecordingMicrophone() != 0) + { + WEBRTC_TRACE(kTraceError, kTraceVoice, + VoEId(_shared->instance_id(), -1), + "StopRecordingMicrophone() failed to stop recording to mixer"); + err = -1; + } + + return err; } // TODO(andrew): a cursory inspection suggests there's a large amount of