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

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

Issue 1323403005: Allow AudioOutputDevice objects to be initialized with a specific hardware output device and store … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert DCHECK in destructor Created 5 years, 3 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // the client on the main thread, and the delegates from the I/O thread. 65 // the client on the main thread, and the delegates from the I/O thread.
66 client_ = NULL; 66 client_ = NULL;
67 io_task_runner_->PostTask( 67 io_task_runner_->PostTask(
68 FROM_HERE, 68 FROM_HERE,
69 base::Bind(&PepperPlatformAudioOutput::ShutDownOnIOThread, this)); 69 base::Bind(&PepperPlatformAudioOutput::ShutDownOnIOThread, this));
70 } 70 }
71 71
72 void PepperPlatformAudioOutput::OnStateChanged( 72 void PepperPlatformAudioOutput::OnStateChanged(
73 media::AudioOutputIPCDelegateState state) {} 73 media::AudioOutputIPCDelegateState state) {}
74 74
75 void PepperPlatformAudioOutput::OnDeviceAuthorized(
76 bool success,
77 const media::AudioParameters& output_params) {}
bbudge 2015/09/15 11:39:42 I'm assuming 'success' is always 'true' here. If s
Guido Urdaneta 2015/09/15 11:55:14 Actually, this is never called because the Request
bbudge 2015/09/15 12:59:12 OK that's fine.
78
75 void PepperPlatformAudioOutput::OnStreamCreated( 79 void PepperPlatformAudioOutput::OnStreamCreated(
76 base::SharedMemoryHandle handle, 80 base::SharedMemoryHandle handle,
77 base::SyncSocket::Handle socket_handle, 81 base::SyncSocket::Handle socket_handle,
78 int length) { 82 int length) {
79 #if defined(OS_WIN) 83 #if defined(OS_WIN)
80 DCHECK(handle); 84 DCHECK(handle);
81 DCHECK(socket_handle); 85 DCHECK(socket_handle);
82 #else 86 #else
83 DCHECK(base::SharedMemory::IsHandleValid(handle)); 87 DCHECK(base::SharedMemory::IsHandleValid(handle));
84 DCHECK_NE(-1, socket_handle); 88 DCHECK_NE(-1, socket_handle);
85 #endif 89 #endif
86 DCHECK(length); 90 DCHECK(length);
87 91
88 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) { 92 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) {
89 // Must dereference the client only on the main thread. Shutdown may have 93 // Must dereference the client only on the main thread. Shutdown may have
90 // occurred while the request was in-flight, so we need to NULL check. 94 // occurred while the request was in-flight, so we need to NULL check.
91 if (client_) 95 if (client_)
92 client_->StreamCreated(handle, length, socket_handle); 96 client_->StreamCreated(handle, length, socket_handle);
93 } else { 97 } else {
94 main_task_runner_->PostTask( 98 main_task_runner_->PostTask(
95 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this, 99 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this,
96 handle, socket_handle, length)); 100 handle, socket_handle, length));
97 } 101 }
98 } 102 }
99 103
100 void PepperPlatformAudioOutput::OnOutputDeviceSwitched( 104 void PepperPlatformAudioOutput::OnOutputDeviceSwitched(
101 int request_id,
102 media::SwitchOutputDeviceResult result) {} 105 media::SwitchOutputDeviceResult result) {}
103 106
104 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); } 107 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); }
105 108
106 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() { 109 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() {
107 // Make sure we have been shut down. Warning: this will usually happen on 110 // Make sure we have been shut down. Warning: this will usually happen on
108 // the I/O thread! 111 // the I/O thread!
109 DCHECK(!ipc_); 112 DCHECK(!ipc_);
110 DCHECK(!client_); 113 DCHECK(!client_);
111 } 114 }
(...skipping 24 matching lines...) Expand all
136 139
137 io_task_runner_->PostTask( 140 io_task_runner_->PostTask(
138 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, 141 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread,
139 this, params)); 142 this, params));
140 return true; 143 return true;
141 } 144 }
142 145
143 void PepperPlatformAudioOutput::InitializeOnIOThread( 146 void PepperPlatformAudioOutput::InitializeOnIOThread(
144 const media::AudioParameters& params) { 147 const media::AudioParameters& params) {
145 DCHECK(io_task_runner_->BelongsToCurrentThread()); 148 DCHECK(io_task_runner_->BelongsToCurrentThread());
146 const int kSessionId = 0;
147 if (ipc_) 149 if (ipc_)
148 ipc_->CreateStream(this, params, kSessionId); 150 ipc_->CreateStream(this, params);
149 } 151 }
150 152
151 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() { 153 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() {
152 DCHECK(io_task_runner_->BelongsToCurrentThread()); 154 DCHECK(io_task_runner_->BelongsToCurrentThread());
153 if (ipc_) 155 if (ipc_)
154 ipc_->PlayStream(); 156 ipc_->PlayStream();
155 } 157 }
156 158
157 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() { 159 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() {
158 DCHECK(io_task_runner_->BelongsToCurrentThread()); 160 DCHECK(io_task_runner_->BelongsToCurrentThread());
159 if (ipc_) 161 if (ipc_)
160 ipc_->PauseStream(); 162 ipc_->PauseStream();
161 } 163 }
162 164
163 void PepperPlatformAudioOutput::ShutDownOnIOThread() { 165 void PepperPlatformAudioOutput::ShutDownOnIOThread() {
164 DCHECK(io_task_runner_->BelongsToCurrentThread()); 166 DCHECK(io_task_runner_->BelongsToCurrentThread());
165 167
166 // Make sure we don't call shutdown more than once. 168 // Make sure we don't call shutdown more than once.
167 if (!ipc_) 169 if (!ipc_)
168 return; 170 return;
169 171
170 ipc_->CloseStream(); 172 ipc_->CloseStream();
171 ipc_.reset(); 173 ipc_.reset();
172 174
173 Release(); // Release for the delegate, balances out the reference taken in 175 Release(); // Release for the delegate, balances out the reference taken in
174 // PepperPlatformAudioOutput::Create. 176 // PepperPlatformAudioOutput::Create.
175 } 177 }
176 178
177 } // namespace content 179 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/pepper/pepper_platform_audio_output.h ('k') | media/audio/audio_output_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698