From 675e260ad1b2074bde22a8929d25d2640bd4e452 Mon Sep 17 00:00:00 2001 From: "xians@webrtc.org" Date: Thu, 17 Oct 2013 16:15:34 +0000 Subject: [PATCH] Check the number of playout channels instead of the send channels in StopPlayout() BUG=2467 R=henrika@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2420004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4989 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/voice_engine/shared_data.cc | 17 +++++++++++++++-- webrtc/voice_engine/shared_data.h | 3 ++- webrtc/voice_engine/voe_base_impl.cc | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/webrtc/voice_engine/shared_data.cc b/webrtc/voice_engine/shared_data.cc index 2d485ae71..712bb66a7 100644 --- a/webrtc/voice_engine/shared_data.cc +++ b/webrtc/voice_engine/shared_data.cc @@ -76,9 +76,9 @@ void SharedData::set_audio_processing(AudioProcessing* audioproc) { _outputMixerPtr->SetAudioProcessingModule(audioproc); } -uint16_t SharedData::NumOfSendingChannels() { +int SharedData::NumOfSendingChannels() { ChannelManager::Iterator it(&_channelManager); - uint16_t sending_channels = 0; + int sending_channels = 0; for (ChannelManager::Iterator it(&_channelManager); it.IsValid(); it.Increment()) { @@ -89,6 +89,19 @@ uint16_t SharedData::NumOfSendingChannels() { return sending_channels; } +int SharedData::NumOfPlayingChannels() { + ChannelManager::Iterator it(&_channelManager); + int playout_channels = 0; + + for (ChannelManager::Iterator it(&_channelManager); it.IsValid(); + it.Increment()) { + if (it.GetChannel()->Playing()) + ++playout_channels; + } + + return playout_channels; +} + void SharedData::SetLastError(int32_t error) const { _engineStatistics.SetLastError(error); } diff --git a/webrtc/voice_engine/shared_data.h b/webrtc/voice_engine/shared_data.h index 7c7ad5c93..dd76e96ab 100644 --- a/webrtc/voice_engine/shared_data.h +++ b/webrtc/voice_engine/shared_data.h @@ -56,7 +56,8 @@ public: _audioDeviceLayer = layer; } - uint16_t NumOfSendingChannels(); + int NumOfSendingChannels(); + int NumOfPlayingChannels(); // Convenience methods for calling statistics().SetLastError(). void SetLastError(int32_t error) const; diff --git a/webrtc/voice_engine/voe_base_impl.cc b/webrtc/voice_engine/voe_base_impl.cc index ab78f7744..c76e06dee 100644 --- a/webrtc/voice_engine/voe_base_impl.cc +++ b/webrtc/voice_engine/voe_base_impl.cc @@ -999,7 +999,7 @@ int32_t VoEBaseImpl::StopPlayout() { VoEId(_shared->instance_id(), -1), "VoEBaseImpl::StopPlayout()"); // Stop audio-device playing if no channel is playing out - if (_shared->NumOfSendingChannels() == 0) { + if (_shared->NumOfPlayingChannels() == 0) { if (_shared->audio_device()->StopPlayout() != 0) { _shared->SetLastError(VE_CANNOT_STOP_PLAYOUT, kTraceError,