| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper/pepper_platform_audio_output_impl.h" | 5 #include "content/renderer/pepper/pepper_platform_audio_output_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 void PepperPlatformAudioOutputImpl::InitializeOnIOThread( | 156 void PepperPlatformAudioOutputImpl::InitializeOnIOThread( |
| 157 const media::AudioParameters& params, int source_render_view_id) { | 157 const media::AudioParameters& params, int source_render_view_id) { |
| 158 // Make sure we don't call init more than once. | 158 // Make sure we don't call init more than once. |
| 159 DCHECK_EQ(0, stream_id_); | 159 DCHECK_EQ(0, stream_id_); |
| 160 stream_id_ = ipc_->AddDelegate(this); | 160 stream_id_ = ipc_->AddDelegate(this); |
| 161 DCHECK_NE(0, stream_id_); | 161 DCHECK_NE(0, stream_id_); |
| 162 | 162 |
| 163 ipc_->CreateStream(stream_id_, params, 0); | 163 ipc_->CreateStream(stream_id_, params); |
| 164 ipc_->AssociateStreamWithProducer(stream_id_, source_render_view_id); | 164 ipc_->AssociateStreamWithProducer(stream_id_, source_render_view_id); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread() { | 167 void PepperPlatformAudioOutputImpl::StartPlaybackOnIOThread() { |
| 168 if (stream_id_) | 168 if (stream_id_) |
| 169 ipc_->PlayStream(stream_id_); | 169 ipc_->PlayStream(stream_id_); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void PepperPlatformAudioOutputImpl::StopPlaybackOnIOThread() { | 172 void PepperPlatformAudioOutputImpl::StopPlaybackOnIOThread() { |
| 173 if (stream_id_) | 173 if (stream_id_) |
| 174 ipc_->PauseStream(stream_id_); | 174 ipc_->PauseStream(stream_id_); |
| 175 } | 175 } |
| 176 | 176 |
| 177 void PepperPlatformAudioOutputImpl::ShutDownOnIOThread() { | 177 void PepperPlatformAudioOutputImpl::ShutDownOnIOThread() { |
| 178 // Make sure we don't call shutdown more than once. | 178 // Make sure we don't call shutdown more than once. |
| 179 if (!stream_id_) | 179 if (!stream_id_) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 ipc_->CloseStream(stream_id_); | 182 ipc_->CloseStream(stream_id_); |
| 183 ipc_->RemoveDelegate(stream_id_); | 183 ipc_->RemoveDelegate(stream_id_); |
| 184 stream_id_ = 0; | 184 stream_id_ = 0; |
| 185 | 185 |
| 186 Release(); // Release for the delegate, balances out the reference taken in | 186 Release(); // Release for the delegate, balances out the reference taken in |
| 187 // PepperPluginDelegateImpl::CreateAudio. | 187 // PepperPluginDelegateImpl::CreateAudio. |
| 188 } | 188 } |
| 189 | 189 |
| 190 } // namespace content | 190 } // namespace content |
| OLD | NEW |