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

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

Issue 1780653002: Revert of MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Ensure the track is stopped. 123 source()->RemoveAll(this);
124 MediaStreamAudioTrack::Stop();
125 } 124 }
126 125
127 void MediaStreamRemoteAudioTrack::SetEnabled(bool enabled) { 126 void MediaStreamRemoteAudioTrack::SetEnabled(bool enabled) {
128 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 127 DCHECK(main_render_thread_checker_.CalledOnValidThread());
129 128
130 // This affects the shared state of the source for whether or not it's a part 129 // This affects the shared state of the source for whether or not it's a part
131 // of the mixed audio that's rendered for remote tracks from WebRTC. 130 // of the mixed audio that's rendered for remote tracks from WebRTC.
132 // All tracks from the same source will share this state and thus can step 131 // All tracks from the same source will share this state and thus can step
133 // on each other's toes. 132 // on each other's toes.
134 // This is also why we can't check the |enabled_| state for equality with 133 // This is also why we can't check the |enabled_| state for equality with
135 // |enabled| before setting the mixing enabled state. |enabled_| and the 134 // |enabled| before setting the mixing enabled state. |enabled_| and the
136 // shared state might not be the same. 135 // shared state might not be the same.
137 source()->SetEnabledForMixing(enabled); 136 source()->SetEnabledForMixing(enabled);
138 137
139 enabled_ = enabled; 138 enabled_ = enabled;
140 source()->SetSinksEnabled(this, enabled); 139 source()->SetSinksEnabled(this, enabled);
141 } 140 }
142 141
143 void MediaStreamRemoteAudioTrack::OnStop() { 142 void MediaStreamRemoteAudioTrack::Stop() {
144 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 143 DCHECK(main_render_thread_checker_.CalledOnValidThread());
145 DVLOG(1) << "MediaStreamRemoteAudioTrack::OnStop()";
146
147 source()->RemoveAll(this);
148
149 // Stop means that a track should be stopped permanently. But 144 // Stop means that a track should be stopped permanently. But
150 // since there is no proper way of doing that on a remote track, we can 145 // since there is no proper way of doing that on a remote track, we can
151 // at least disable the track. Blink will not call down to the content layer 146 // at least disable the track. Blink will not call down to the content layer
152 // after a track has been stopped. 147 // after a track has been stopped.
153 SetEnabled(false); 148 SetEnabled(false);
154 } 149 }
155 150
156 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) { 151 void MediaStreamRemoteAudioTrack::AddSink(MediaStreamAudioSink* sink) {
157 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 152 DCHECK(main_render_thread_checker_.CalledOnValidThread());
158 return source()->AddSink(sink, this, enabled_); 153 return source()->AddSink(sink, this, enabled_);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (sink_) 222 if (sink_)
228 sink_->RemoveAll(track); 223 sink_->RemoveAll(track);
229 } 224 }
230 225
231 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() { 226 webrtc::AudioTrackInterface* MediaStreamRemoteAudioSource::GetAudioAdapter() {
232 DCHECK(thread_checker_.CalledOnValidThread()); 227 DCHECK(thread_checker_.CalledOnValidThread());
233 return track_.get(); 228 return track_.get();
234 } 229 }
235 230
236 } // namespace content 231 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698