From b3ada1540827c60a63058570a94a57dfd260ad11 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Wed, 7 Aug 2013 17:57:36 +0000 Subject: Ref-counted rewrite of ChannelManager. The complexity of the last ChannelManager and potentially usage of it as well caused race conditions and deadlocks in loopback voe_auto_test. This ref-counted solution takes no long-term locks, uses less locks overall and is significantly easier to understand. ScopedChannel has been split up into a ChannelOwner with a reference to a channel and an Iterator over ChannelManager. Previous code was really used for both things. ChannelOwner is used as a shared pointer to a channel object, while an Iterator should work as expected. BUG=2081 R=tommi@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/1802004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@4502 4adac7df-926f-26a2-2b94-8c16560cd09d --- voice_engine/voe_audio_processing_impl.cc | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'voice_engine/voe_audio_processing_impl.cc') diff --git a/voice_engine/voe_audio_processing_impl.cc b/voice_engine/voe_audio_processing_impl.cc index 430f86dc..a57ede93 100644 --- a/voice_engine/voe_audio_processing_impl.cc +++ b/voice_engine/voe_audio_processing_impl.cc @@ -342,8 +342,8 @@ int VoEAudioProcessingImpl::SetRxNsStatus(int channel, return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "SetRxNsStatus() failed to locate channel"); @@ -368,8 +368,8 @@ int VoEAudioProcessingImpl::GetRxNsStatus(int channel, return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "GetRxNsStatus() failed to locate channel"); @@ -395,8 +395,8 @@ int VoEAudioProcessingImpl::SetRxAgcStatus(int channel, return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "SetRxAgcStatus() failed to locate channel"); @@ -421,8 +421,8 @@ int VoEAudioProcessingImpl::GetRxAgcStatus(int channel, return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "GetRxAgcStatus() failed to locate channel"); @@ -446,8 +446,8 @@ int VoEAudioProcessingImpl::SetRxAgcConfig(int channel, return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "SetRxAgcConfig() failed to locate channel"); @@ -470,8 +470,8 @@ int VoEAudioProcessingImpl::GetRxAgcConfig(int channel, AgcConfig& config) { return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "GetRxAgcConfig() failed to locate channel"); @@ -771,8 +771,8 @@ int VoEAudioProcessingImpl::RegisterRxVadObserver( _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "RegisterRxVadObserver() failed to locate channel"); @@ -788,8 +788,8 @@ int VoEAudioProcessingImpl::DeRegisterRxVadObserver(int channel) { _shared->SetLastError(VE_NOT_INITED, kTraceError); return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "DeRegisterRxVadObserver() failed to locate channel"); @@ -807,8 +807,8 @@ int VoEAudioProcessingImpl::VoiceActivityIndicator(int channel) { return -1; } - voe::ScopedChannel sc(_shared->channel_manager(), channel); - voe::Channel* channelPtr = sc.ChannelPtr(); + voe::ChannelOwner ch = _shared->channel_manager().GetChannel(channel); + voe::Channel* channelPtr = ch.channel(); if (channelPtr == NULL) { _shared->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, "DeRegisterRxVadObserver() failed to locate channel"); -- cgit v1.2.3