| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 // Notify the other side (browser process) of some activity on the audio pipe. | 48 // Notify the other side (browser process) of some activity on the audio pipe. |
| 49 // TODO(erickung): either send an IPC message or write a byte on the | 49 // TODO(erickung): either send an IPC message or write a byte on the |
| 50 // SyncSocket. | 50 // SyncSocket. |
| 51 void NotifyPipeWrite(); | 51 void NotifyPipeWrite(); |
| 52 | 52 |
| 53 // These functions are almost a one to one correspondence with AudioPipeline | 53 // These functions are almost a one to one correspondence with AudioPipeline |
| 54 // but this is an internal class and there is no reason to derive from | 54 // but this is an internal class and there is no reason to derive from |
| 55 // AudioPipeline. | 55 // AudioPipeline. |
| 56 void SetClient(const base::Closure& pipe_read_cb, | 56 void SetClient(const base::Closure& pipe_read_cb, |
| 57 const AvPipelineClient& client); | 57 const RendererAvPipelineClient& client); |
| 58 void CreateAvPipe(const SharedMemCB& shared_mem_cb); | 58 void CreateAvPipe(const SharedMemCB& shared_mem_cb); |
| 59 void Initialize(const ::media::AudioDecoderConfig& config, | 59 void Initialize(const ::media::AudioDecoderConfig& config, |
| 60 const ::media::PipelineStatusCB& status_cb); | 60 const ::media::PipelineStatusCB& status_cb); |
| 61 void SetVolume(float volume); | 61 void SetVolume(float volume); |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 void Shutdown(); | 64 void Shutdown(); |
| 65 | 65 |
| 66 // Callbacks for CmaMessageFilterHost::AudioDelegate. | 66 // Callbacks for CmaMessageFilterHost::AudioDelegate. |
| 67 void OnAvPipeCreated(bool status, | 67 void OnAvPipeCreated(bool status, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( |
| 122 const base::Closure& pipe_read_cb, | 122 const base::Closure& pipe_read_cb, |
| 123 const AvPipelineClient& client) { | 123 const RendererAvPipelineClient& client) { |
| 124 DCHECK(thread_checker_.CalledOnValidThread()); | 124 DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 | 125 |
| 126 CmaMessageFilterProxy::AudioDelegate delegate; | 126 CmaMessageFilterProxy::AudioDelegate delegate; |
| 127 delegate.av_pipe_cb = | 127 delegate.av_pipe_cb = |
| 128 base::Bind(&AudioPipelineProxyInternal::OnAvPipeCreated, | 128 base::Bind(&AudioPipelineProxyInternal::OnAvPipeCreated, |
| 129 base::Unretained(this)); | 129 base::Unretained(this)); |
| 130 delegate.state_changed_cb = | 130 delegate.state_changed_cb = |
| 131 base::Bind(&AudioPipelineProxyInternal::OnStateChanged, | 131 base::Bind(&AudioPipelineProxyInternal::OnStateChanged, |
| 132 base::Unretained(this)); | 132 base::Unretained(this)); |
| 133 delegate.pipe_read_cb = pipe_read_cb; | 133 delegate.pipe_read_cb = pipe_read_cb; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 } | 214 } |
| 215 | 215 |
| 216 AudioPipelineProxy::~AudioPipelineProxy() { | 216 AudioPipelineProxy::~AudioPipelineProxy() { |
| 217 DCHECK(thread_checker_.CalledOnValidThread()); | 217 DCHECK(thread_checker_.CalledOnValidThread()); |
| 218 // Release the underlying object on the right thread. | 218 // Release the underlying object on the right thread. |
| 219 io_task_runner_->PostTask( | 219 io_task_runner_->PostTask( |
| 220 FROM_HERE, | 220 FROM_HERE, |
| 221 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_))); | 221 base::Bind(&AudioPipelineProxyInternal::Release, base::Passed(&proxy_))); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void AudioPipelineProxy::SetClient( | 224 void AudioPipelineProxy::SetClient(const RendererAvPipelineClient& client) { |
| 225 const AvPipelineClient& client) { | |
| 226 DCHECK(thread_checker_.CalledOnValidThread()); | 225 DCHECK(thread_checker_.CalledOnValidThread()); |
| 227 base::Closure pipe_read_cb = ::media::BindToCurrentLoop( | 226 base::Closure pipe_read_cb = ::media::BindToCurrentLoop( |
| 228 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_)); | 227 base::Bind(&AudioPipelineProxy::OnPipeRead, weak_this_)); |
| 229 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client); | 228 FORWARD_ON_IO_THREAD(SetClient, pipe_read_cb, client); |
| 230 } | 229 } |
| 231 | 230 |
| 232 void AudioPipelineProxy::Initialize( | 231 void AudioPipelineProxy::Initialize( |
| 233 const ::media::AudioDecoderConfig& config, | 232 const ::media::AudioDecoderConfig& config, |
| 234 scoped_ptr<CodedFrameProvider> frame_provider, | 233 scoped_ptr<CodedFrameProvider> frame_provider, |
| 235 const ::media::PipelineStatusCB& status_cb) { | 234 const ::media::PipelineStatusCB& status_cb) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 FORWARD_ON_IO_THREAD(NotifyPipeWrite); | 298 FORWARD_ON_IO_THREAD(NotifyPipeWrite); |
| 300 } | 299 } |
| 301 | 300 |
| 302 void AudioPipelineProxy::OnPipeRead() { | 301 void AudioPipelineProxy::OnPipeRead() { |
| 303 DCHECK(thread_checker_.CalledOnValidThread()); | 302 DCHECK(thread_checker_.CalledOnValidThread()); |
| 304 if (audio_streamer_) | 303 if (audio_streamer_) |
| 305 audio_streamer_->OnFifoReadEvent(); | 304 audio_streamer_->OnFifoReadEvent(); |
| 306 } | 305 } |
| 307 | 306 |
| 308 } // namespace cma | 307 } // namespace cma |
| 309 } // namespace chromecast | 308 } // namespace chromecast |
| OLD | NEW |