Chromium Code Reviews| Index: content/renderer/media/webrtc_audio_capturer.cc |
| diff --git a/content/renderer/media/webrtc_audio_capturer.cc b/content/renderer/media/webrtc_audio_capturer.cc |
| index 7363b3e7d13fe436bebf1882e357d1f36026e9e4..e942f8f5e4f2ce97bb73cbaa02b11f9d5f30b68a 100644 |
| --- a/content/renderer/media/webrtc_audio_capturer.cc |
| +++ b/content/renderer/media/webrtc_audio_capturer.cc |
| @@ -13,6 +13,7 @@ |
| #include "content/renderer/media/audio_device_factory.h" |
| #include "content/renderer/media/media_stream_audio_processor.h" |
| #include "content/renderer/media/media_stream_audio_processor_options.h" |
| +#include "content/renderer/media/media_stream_audio_source.h" |
| #include "content/renderer/media/webrtc_audio_device_impl.h" |
| #include "content/renderer/media/webrtc_local_audio_track.h" |
| #include "content/renderer/media/webrtc_logging.h" |
| @@ -87,7 +88,7 @@ class WebRtcAudioCapturer::TrackOwner |
| // This can be reentrant so reset |delegate_| before calling out. |
| WebRtcLocalAudioTrack* temp = delegate_; |
| delegate_ = NULL; |
| - temp->Stop(); |
| + temp->StopTrack(); |
| } |
| // Wrapper which allows to use std::find_if() when adding and removing |
| @@ -123,9 +124,10 @@ class WebRtcAudioCapturer::TrackOwner |
| scoped_refptr<WebRtcAudioCapturer> WebRtcAudioCapturer::CreateCapturer( |
| int render_view_id, const StreamDeviceInfo& device_info, |
| const blink::WebMediaConstraints& constraints, |
| - WebRtcAudioDeviceImpl* audio_device) { |
| + WebRtcAudioDeviceImpl* audio_device, |
| + MediaStreamAudioSource* audio_source) { |
| scoped_refptr<WebRtcAudioCapturer> capturer = new WebRtcAudioCapturer( |
| - render_view_id, device_info, constraints, audio_device); |
| + render_view_id, device_info, constraints, audio_device, audio_source); |
| if (capturer->Initialize()) |
| return capturer; |
| @@ -208,7 +210,8 @@ WebRtcAudioCapturer::WebRtcAudioCapturer( |
| int render_view_id, |
| const StreamDeviceInfo& device_info, |
| const blink::WebMediaConstraints& constraints, |
| - WebRtcAudioDeviceImpl* audio_device) |
| + WebRtcAudioDeviceImpl* audio_device, |
| + MediaStreamAudioSource* audio_source) |
| : constraints_(constraints), |
| audio_processor_( |
| new talk_base::RefCountedObject<MediaStreamAudioProcessor>( |
| @@ -221,7 +224,8 @@ WebRtcAudioCapturer::WebRtcAudioCapturer( |
| peer_connection_mode_(false), |
| key_pressed_(false), |
| need_audio_processing_(false), |
| - audio_device_(audio_device) { |
| + audio_device_(audio_device), |
| + audio_source_(audio_source) { |
| DVLOG(1) << "WebRtcAudioCapturer::WebRtcAudioCapturer()"; |
| } |
| @@ -255,16 +259,30 @@ void WebRtcAudioCapturer::AddTrack(WebRtcLocalAudioTrack* track) { |
| void WebRtcAudioCapturer::RemoveTrack(WebRtcLocalAudioTrack* track) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - base::AutoLock auto_lock(lock_); |
| + DVLOG(1) << "WebRtcAudioCapturer::RemoveTrack()"; |
| + bool stop_source = false; |
| + { |
| + base::AutoLock auto_lock(lock_); |
| - scoped_refptr<TrackOwner> removed_item = |
| - tracks_.Remove(TrackOwner::TrackWrapper(track)); |
| + scoped_refptr<TrackOwner> removed_item = |
| + tracks_.Remove(TrackOwner::TrackWrapper(track)); |
| - // Clear the delegate to ensure that no more capture callbacks will |
| - // be sent to this sink. Also avoids a possible crash which can happen |
| - // if this method is called while capturing is active. |
| - if (removed_item.get()) |
| - removed_item->Reset(); |
| + // Clear the delegate to ensure that no more capture callbacks will |
| + // be sent to this sink. Also avoids a possible crash which can happen |
| + // if this method is called while capturing is active. |
| + if (removed_item.get()) { |
| + removed_item->Reset(); |
| + stop_source = tracks_.IsEmpty(); |
| + } |
| + } |
| + if (stop_source) { |
| + // Since WebRtcAudioCapturer does not inherit MediaStreamAudioSource, |
| + // and instead MediaStreamAudioSource is composed of a WebRtcAudioCapturer, |
| + // we have to call StopSource on the MediaStreamSource. This will call |
| + // MediaStreamAudioSource::DoStopSource which in turn call |
| + // WebRtcAudioCapturerer::Stop(); |
| + audio_source_->StopSource(); |
|
no longer working on chromium
2014/04/02 13:50:56
you will trigger WebRtcAudioCapturerer::Stop() her
perkj_chrome
2014/04/03 11:58:34
We discussed offline and decided to start the capt
|
| + } |
| } |
| void WebRtcAudioCapturer::SetCapturerSource( |