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

Side by Side Diff: chromecast/renderer/media/audio_pipeline_proxy.cc

Issue 1142513004: Chromecast: MessageLoopProxy cleanup --> SingleThreadTaskRunner. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/renderer/media/audio_pipeline_proxy.h" 5 #include "chromecast/renderer/media/audio_pipeline_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 kAudioTrackId, volume))); 188 kAudioTrackId, volume)));
189 } 189 }
190 190
191 void AudioPipelineProxyInternal::OnStateChanged( 191 void AudioPipelineProxyInternal::OnStateChanged(
192 ::media::PipelineStatus status) { 192 ::media::PipelineStatus status) {
193 DCHECK(thread_checker_.CalledOnValidThread()); 193 DCHECK(thread_checker_.CalledOnValidThread());
194 DCHECK(!status_cb_.is_null()); 194 DCHECK(!status_cb_.is_null());
195 base::ResetAndReturn(&status_cb_).Run(status); 195 base::ResetAndReturn(&status_cb_).Run(status);
196 } 196 }
197 197
198 198 // A macro runs current member function on |io_task_runner_| thread.
199 // A macro runs current member function on |io_message_loop_proxy_| thread. 199 #define FORWARD_ON_IO_THREAD(param_fn, ...) \
200 #define FORWARD_ON_IO_THREAD(param_fn, ...) \ 200 io_task_runner_->PostTask( \
201 io_message_loop_proxy_->PostTask( \ 201 FROM_HERE, base::Bind(&AudioPipelineProxyInternal::param_fn, \
202 FROM_HERE, \ 202 base::Unretained(proxy_.get()), ##__VA_ARGS__))
203 base::Bind(&AudioPipelineProxyInternal::param_fn, \
204 base::Unretained(proxy_.get()), ##__VA_ARGS__))
205 203
206 AudioPipelineProxy::AudioPipelineProxy( 204 AudioPipelineProxy::AudioPipelineProxy(
207 scoped_refptr<base::MessageLoopProxy> io_message_loop_proxy, 205 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
208 scoped_refptr<MediaChannelProxy> media_channel_proxy) 206 scoped_refptr<MediaChannelProxy> media_channel_proxy)
209 : io_message_loop_proxy_(io_message_loop_proxy), 207 : io_task_runner_(io_task_runner),
210 proxy_(new AudioPipelineProxyInternal(media_channel_proxy)), 208 proxy_(new AudioPipelineProxyInternal(media_channel_proxy)),
211 audio_streamer_(new AvStreamerProxy()), 209 audio_streamer_(new AvStreamerProxy()),
212 weak_factory_(this) { 210 weak_factory_(this) {
213 DCHECK(io_message_loop_proxy_.get()); 211 DCHECK(io_task_runner_.get());
214 weak_this_ = weak_factory_.GetWeakPtr(); 212 weak_this_ = weak_factory_.GetWeakPtr();
215 thread_checker_.DetachFromThread(); 213 thread_checker_.DetachFromThread();
216 } 214 }
217 215
218 AudioPipelineProxy::~AudioPipelineProxy() { 216 AudioPipelineProxy::~AudioPipelineProxy() {
219 DCHECK(thread_checker_.CalledOnValidThread()); 217 DCHECK(thread_checker_.CalledOnValidThread());
220 // Release the underlying object on the right thread. 218 // Release the underlying object on the right thread.
221 io_message_loop_proxy_->PostTask( 219 io_task_runner_->PostTask(
222 FROM_HERE, 220 FROM_HERE,
223 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_))); 221 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_)));
224 } 222 }
225 223
226 void AudioPipelineProxy::SetClient( 224 void AudioPipelineProxy::SetClient(
227 const AvPipelineClient& client) { 225 const AvPipelineClient& client) {
228 DCHECK(thread_checker_.CalledOnValidThread()); 226 DCHECK(thread_checker_.CalledOnValidThread());
229 base::Closure pipe_read_cb = ::media::BindToCurrentLoop( 227 base::Closure pipe_read_cb = ::media::BindToCurrentLoop(
230 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_)); 228 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_));
231 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client); 229 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 300 }
303 301
304 void AudioPipelineProxy::OnPipeRead() { 302 void AudioPipelineProxy::OnPipeRead() {
305 DCHECK(thread_checker_.CalledOnValidThread()); 303 DCHECK(thread_checker_.CalledOnValidThread());
306 if (audio_streamer_) 304 if (audio_streamer_)
307 audio_streamer_->OnFifoReadEvent(); 305 audio_streamer_->OnFifoReadEvent();
308 } 306 }
309 307
310 } // namespace cma 308 } // namespace cma
311 } // namespace chromecast 309 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/renderer/media/audio_pipeline_proxy.h ('k') | chromecast/renderer/media/cma_message_filter_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698