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

Side by Side Diff: content/renderer/pepper/pepper_platform_audio_output.cc

Issue 2065513004: Expose flash playback status and volume control to content renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_focus_manager
Patch Set: addressing nits Created 4 years, 5 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 (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.h" 5 #include "content/renderer/pepper/pepper_platform_audio_output.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 bool PepperPlatformAudioOutput::StopPlayback() { 53 bool PepperPlatformAudioOutput::StopPlayback() {
54 if (ipc_) { 54 if (ipc_) {
55 io_task_runner_->PostTask( 55 io_task_runner_->PostTask(
56 FROM_HERE, 56 FROM_HERE,
57 base::Bind(&PepperPlatformAudioOutput::StopPlaybackOnIOThread, this)); 57 base::Bind(&PepperPlatformAudioOutput::StopPlaybackOnIOThread, this));
58 return true; 58 return true;
59 } 59 }
60 return false; 60 return false;
61 } 61 }
62 62
63 bool PepperPlatformAudioOutput::SetVolume(double volume) {
64 if (ipc_) {
65 io_task_runner_->PostTask(
66 FROM_HERE,
67 base::Bind(&PepperPlatformAudioOutput::SetVolumeOnIOThread,
68 this, volume));
69 return true;
70 }
71 return false;
72 }
73
63 void PepperPlatformAudioOutput::ShutDown() { 74 void PepperPlatformAudioOutput::ShutDown() {
64 // Called on the main thread to stop all audio callbacks. We must only change 75 // Called on the main thread to stop all audio callbacks. We must only change
65 // the client on the main thread, and the delegates from the I/O thread. 76 // the client on the main thread, and the delegates from the I/O thread.
66 client_ = NULL; 77 client_ = NULL;
67 io_task_runner_->PostTask( 78 io_task_runner_->PostTask(
68 FROM_HERE, 79 FROM_HERE,
69 base::Bind(&PepperPlatformAudioOutput::ShutDownOnIOThread, this)); 80 base::Bind(&PepperPlatformAudioOutput::ShutDownOnIOThread, this));
70 } 81 }
71 82
72 void PepperPlatformAudioOutput::OnStateChanged( 83 void PepperPlatformAudioOutput::OnStateChanged(
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 if (ipc_) 160 if (ipc_)
150 ipc_->CreateStream(this, params); 161 ipc_->CreateStream(this, params);
151 } 162 }
152 163
153 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() { 164 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() {
154 DCHECK(io_task_runner_->BelongsToCurrentThread()); 165 DCHECK(io_task_runner_->BelongsToCurrentThread());
155 if (ipc_) 166 if (ipc_)
156 ipc_->PlayStream(); 167 ipc_->PlayStream();
157 } 168 }
158 169
170 void PepperPlatformAudioOutput::SetVolumeOnIOThread(double volume) {
171 DCHECK(io_task_runner_->BelongsToCurrentThread());
172 if (ipc_)
173 ipc_->SetVolume(volume);
174 }
175
159 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() { 176 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() {
160 DCHECK(io_task_runner_->BelongsToCurrentThread()); 177 DCHECK(io_task_runner_->BelongsToCurrentThread());
161 if (ipc_) 178 if (ipc_)
162 ipc_->PauseStream(); 179 ipc_->PauseStream();
163 } 180 }
164 181
165 void PepperPlatformAudioOutput::ShutDownOnIOThread() { 182 void PepperPlatformAudioOutput::ShutDownOnIOThread() {
166 DCHECK(io_task_runner_->BelongsToCurrentThread()); 183 DCHECK(io_task_runner_->BelongsToCurrentThread());
167 184
168 // Make sure we don't call shutdown more than once. 185 // Make sure we don't call shutdown more than once.
169 if (!ipc_) 186 if (!ipc_)
170 return; 187 return;
171 188
172 ipc_->CloseStream(); 189 ipc_->CloseStream();
173 ipc_.reset(); 190 ipc_.reset();
174 191
175 Release(); // Release for the delegate, balances out the reference taken in 192 Release(); // Release for the delegate, balances out the reference taken in
176 // PepperPlatformAudioOutput::Create. 193 // PepperPlatformAudioOutput::Create.
177 } 194 }
178 195
179 } // namespace content 196 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698