Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: content/renderer/media/webrtc/media_stream_remote_audio_track.cc

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed o1ka's comments Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/media_stream_remote_audio_track.h" 5 #include "content/renderer/media/webrtc/media_stream_remote_audio_track.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <list> 9 #include <list>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 }; 113 };
114 114
115 MediaStreamRemoteAudioTrack::MediaStreamRemoteAudioTrack( 115 MediaStreamRemoteAudioTrack::MediaStreamRemoteAudioTrack(
116 const blink::WebMediaStreamSource& source, bool enabled) 116 const blink::WebMediaStreamSource& source, bool enabled)
117 : MediaStreamAudioTrack(false), source_(source), enabled_(enabled) { 117 : MediaStreamAudioTrack(false), source_(source), enabled_(enabled) {
118 DCHECK(source.extraData()); // Make sure the source has a native source. 118 DCHECK(source.extraData()); // Make sure the source has a native source.
119 } 119 }
120 120
121 MediaStreamRemoteAudioTrack::~MediaStreamRemoteAudioTrack() { 121 MediaStreamRemoteAudioTrack::~MediaStreamRemoteAudioTrack() {
122 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 122 DCHECK(main_render_thread_checker_.CalledOnValidThread());
123 source()->RemoveAll(this); 123 // Ensure the track is stopped.
124 Stop();
124 } 125 }
125 126
126 void MediaStreamRemoteAudioTrack::SetEnabled(bool enabled) { 127 void MediaStreamRemoteAudioTrack::SetEnabled(bool enabled) {
127 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 128 DCHECK(main_render_thread_checker_.CalledOnValidThread());
128 129
129 // This affects the shared state of the source for whether or not it's a part 130 // This affects the shared state of the source for whether or not it's a part
130 // of the mixed audio that's rendered for remote tracks from WebRTC. 131 // of the mixed audio that's rendered for remote tracks from WebRTC.
131 // All tracks from the same source will share this state and thus can step 132 // All tracks from the same source will share this state and thus can step
132 // on each other's toes. 133 // on each other's toes.
133 // This is also why we can't check the |enabled_| state for equality with 134 // This is also why we can't check the |enabled_| state for equality with
134 // |enabled| before setting the mixing enabled state. |enabled_| and the 135 // |enabled| before setting the mixing enabled state. |enabled_| and the
135 // shared state might not be the same. 136 // shared state might not be the same.
136 source()->SetEnabledForMixing(enabled); 137 source()->SetEnabledForMixing(enabled);
137 138
138 enabled_ = enabled; 139 enabled_ = enabled;
139 source()->SetSinksEnabled(this, enabled); 140 source()->SetSinksEnabled(this, enabled);
140 } 141 }
141 142
142 void MediaStreamRemoteAudioTrack::Stop() { 143 void MediaStreamRemoteAudioTrack::Stop() {
143 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 144 DCHECK(main_render_thread_checker_.CalledOnValidThread());
145
146 MediaStreamAudioTrack::WillStopTrack();
o1ka 2016/03/01 14:18:59 What if some observers rely on the fact that the c
miu 2016/03/02 01:12:50 Good point, and I made the behavior more precisely
o1ka 2016/03/02 16:31:14 I like it!
147
148 source()->RemoveAll(this);
149
144 // Stop means that a track should be stopped permanently. But 150 // Stop means that a track should be stopped permanently. But
145 // since there is no proper way of doing that on a remote track, we can 151 // since there is no proper way of doing that on a remote track, we can
146 // at least disable the track. Blink will not call down to the content layer 152 // at least disable the track. Blink will not call down to the content layer
147 // after a track has been stopped. 153 // after a track has been stopped.
148 SetEnabled(false); 154 SetEnabled(false);
149 } 155 }
150 156
151 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) { 157 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) {
152 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 158 DCHECK(main_render_thread_checker_.CalledOnValidThread());
153 return source()->AddSink(sink, this, enabled_); 159 return source()->AddSink(sink, this, enabled_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (sink_) 228 if (sink_)
223 sink_->RemoveAll(track); 229 sink_->RemoveAll(track);
224 } 230 }
225 231
226 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() { 232 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() {
227 DCHECK(thread_checker_.CalledOnValidThread()); 233 DCHECK(thread_checker_.CalledOnValidThread());
228 return track_.get(); 234 return track_.get();
229 } 235 }
230 236
231 } // namespace content 237 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698