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

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: Fix unit tests broken by recent MSAudioTrack::Stop() reworking. 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.getExtraData()); // Make sure the source has a native source. 118 DCHECK(source.getExtraData()); // 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 MediaStreamAudioTrack::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::OnStop() {
143 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 144 DCHECK(main_render_thread_checker_.CalledOnValidThread());
145 DVLOG(1) << "MediaStreamRemoteAudioTrack::OnStop()";
146
147 source()->RemoveAll(this);
148
144 // Stop means that a track should be stopped permanently. But 149 // 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 150 // 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 151 // at least disable the track. Blink will not call down to the content layer
147 // after a track has been stopped. 152 // after a track has been stopped.
148 SetEnabled(false); 153 SetEnabled(false);
149 } 154 }
150 155
151 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) { 156 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) {
152 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 157 DCHECK(main_render_thread_checker_.CalledOnValidThread());
153 return source()->AddSink(sink, this, enabled_); 158 return source()->AddSink(sink, this, enabled_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 if (sink_) 227 if (sink_)
223 sink_->RemoveAll(track); 228 sink_->RemoveAll(track);
224 } 229 }
225 230
226 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() { 231 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() {
227 DCHECK(thread_checker_.CalledOnValidThread()); 232 DCHECK(thread_checker_.CalledOnValidThread());
228 return track_.get(); 233 return track_.get();
229 } 234 }
230 235
231 } // namespace content 236 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698