OLD | NEW |
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 DCHECK(thread_checker_.CalledOnValidThread()); | 111 DCHECK(thread_checker_.CalledOnValidThread()); |
112 | 112 |
113 // TODO(erickung): An alternative way would be to use a dedicated socket for | 113 // TODO(erickung): An alternative way would be to use a dedicated socket for |
114 // this event. | 114 // this event. |
115 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( | 115 bool success = media_channel_proxy_->Send(scoped_ptr<IPC::Message>( |
116 new CmaHostMsg_NotifyPipeWrite( | 116 new CmaHostMsg_NotifyPipeWrite( |
117 media_channel_proxy_->GetId(), kAudioTrackId))); | 117 media_channel_proxy_->GetId(), kAudioTrackId))); |
118 VLOG_IF(4, !success) << "Sending msg failed"; | 118 VLOG_IF(4, !success) << "Sending msg failed"; |
119 } | 119 } |
120 | 120 |
121 void AudioPipelineProxyInternal::SetClient( | 121 void AudioPipelineProxyInternal::SetClient(const base::Closure& pipe_read_cb, |
122 const base::Closure& pipe_read_cb, | 122 const AvPipelineClient& client) { |
123 const AvPipelineClient& client) { | |
124 DCHECK(thread_checker_.CalledOnValidThread()); | 123 DCHECK(thread_checker_.CalledOnValidThread()); |
125 | 124 |
126 CmaMessageFilterProxy::AudioDelegate delegate; | 125 CmaMessageFilterProxy::AudioDelegate delegate; |
127 delegate.av_pipe_cb = | 126 delegate.av_pipe_cb = |
128 base::Bind(&AudioPipelineProxyInternal::OnAvPipeCreated, | 127 base::Bind(&AudioPipelineProxyInternal::OnAvPipeCreated, |
129 base::Unretained(this)); | 128 base::Unretained(this)); |
130 delegate.state_changed_cb = | 129 delegate.state_changed_cb = |
131 base::Bind(&AudioPipelineProxyInternal::OnStateChanged, | 130 base::Bind(&AudioPipelineProxyInternal::OnStateChanged, |
132 base::Unretained(this)); | 131 base::Unretained(this)); |
133 delegate.pipe_read_cb = pipe_read_cb; | 132 delegate.pipe_read_cb = pipe_read_cb; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 } | 213 } |
215 | 214 |
216 AudioPipelineProxy::~AudioPipelineProxy() { | 215 AudioPipelineProxy::~AudioPipelineProxy() { |
217 DCHECK(thread_checker_.CalledOnValidThread()); | 216 DCHECK(thread_checker_.CalledOnValidThread()); |
218 // Release the underlying object on the right thread. | 217 // Release the underlying object on the right thread. |
219 io_task_runner_->PostTask( | 218 io_task_runner_->PostTask( |
220 FROM_HERE, | 219 FROM_HERE, |
221 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_))); | 220 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_))); |
222 } | 221 } |
223 | 222 |
224 void AudioPipelineProxy::SetClient( | 223 void AudioPipelineProxy::SetClient(const AvPipelineClient& client) { |
225 const AvPipelineClient& client) { | |
226 DCHECK(thread_checker_.CalledOnValidThread()); | 224 DCHECK(thread_checker_.CalledOnValidThread()); |
227 base::Closure pipe_read_cb = ::media::BindToCurrentLoop( | 225 base::Closure pipe_read_cb = ::media::BindToCurrentLoop( |
228 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_)); | 226 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_)); |
229 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client); | 227 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client); |
230 } | 228 } |
231 | 229 |
232 void AudioPipelineProxy::Initialize( | 230 void AudioPipelineProxy::Initialize( |
233 const ::media::AudioDecoderConfig& config, | 231 const ::media::AudioDecoderConfig& config, |
234 scoped_ptr<CodedFrameProvider> frame_provider, | 232 scoped_ptr<CodedFrameProvider> frame_provider, |
235 const ::media::PipelineStatusCB& status_cb) { | 233 const ::media::PipelineStatusCB& status_cb) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 FORWARD_ON_IO_THREAD(NotifyPipeWrite); | 297 FORWARD_ON_IO_THREAD(NotifyPipeWrite); |
300 } | 298 } |
301 | 299 |
302 void AudioPipelineProxy::OnPipeRead() { | 300 void AudioPipelineProxy::OnPipeRead() { |
303 DCHECK(thread_checker_.CalledOnValidThread()); | 301 DCHECK(thread_checker_.CalledOnValidThread()); |
304 if (audio_streamer_) | 302 if (audio_streamer_) |
305 audio_streamer_->OnFifoReadEvent(); | 303 audio_streamer_->OnFifoReadEvent(); |
306 } | 304 } |
307 | 305 |
308 } // namespace cma | 306 } // namespace cma |
309 } // namespace chromecast | 307 } // namespace chromecast |
OLD | NEW |