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

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: Palmer's comments 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) {
78 NOTREACHED();
79 }
80
75 void PepperPlatformAudioOutput::OnStreamCreated( 81 void PepperPlatformAudioOutput::OnStreamCreated(
76 base::SharedMemoryHandle handle, 82 base::SharedMemoryHandle handle,
77 base::SyncSocket::Handle socket_handle, 83 base::SyncSocket::Handle socket_handle,
78 int length) { 84 int length) {
79 #if defined(OS_WIN) 85 #if defined(OS_WIN)
80 DCHECK(handle); 86 DCHECK(handle);
81 DCHECK(socket_handle); 87 DCHECK(socket_handle);
82 #else 88 #else
83 DCHECK(base::SharedMemory::IsHandleValid(handle)); 89 DCHECK(base::SharedMemory::IsHandleValid(handle));
84 DCHECK_NE(-1, socket_handle); 90 DCHECK_NE(-1, socket_handle);
85 #endif 91 #endif
86 DCHECK(length); 92 DCHECK(length);
87 93
88 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) { 94 if (base::ThreadTaskRunnerHandle::Get().get() == main_task_runner_.get()) {
89 // Must dereference the client only on the main thread. Shutdown may have 95 // 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. 96 // occurred while the request was in-flight, so we need to NULL check.
91 if (client_) 97 if (client_)
92 client_->StreamCreated(handle, length, socket_handle); 98 client_->StreamCreated(handle, length, socket_handle);
93 } else { 99 } else {
94 main_task_runner_->PostTask( 100 main_task_runner_->PostTask(
95 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this, 101 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::OnStreamCreated, this,
96 handle, socket_handle, length)); 102 handle, socket_handle, length));
97 } 103 }
98 } 104 }
99 105
100 void PepperPlatformAudioOutput::OnOutputDeviceSwitched( 106 void PepperPlatformAudioOutput::OnOutputDeviceSwitched(
101 int request_id,
102 media::SwitchOutputDeviceResult result) {} 107 media::SwitchOutputDeviceResult result) {}
103 108
104 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); } 109 void PepperPlatformAudioOutput::OnIPCClosed() { ipc_.reset(); }
105 110
106 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() { 111 PepperPlatformAudioOutput::~PepperPlatformAudioOutput() {
107 // Make sure we have been shut down. Warning: this will usually happen on 112 // Make sure we have been shut down. Warning: this will usually happen on
108 // the I/O thread! 113 // the I/O thread!
109 DCHECK(!ipc_); 114 DCHECK(!ipc_);
110 DCHECK(!client_); 115 DCHECK(!client_);
111 } 116 }
(...skipping 24 matching lines...) Expand all
136 141
137 io_task_runner_->PostTask( 142 io_task_runner_->PostTask(
138 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread, 143 FROM_HERE, base::Bind(&PepperPlatformAudioOutput::InitializeOnIOThread,
139 this, params)); 144 this, params));
140 return true; 145 return true;
141 } 146 }
142 147
143 void PepperPlatformAudioOutput::InitializeOnIOThread( 148 void PepperPlatformAudioOutput::InitializeOnIOThread(
144 const media::AudioParameters& params) { 149 const media::AudioParameters& params) {
145 DCHECK(io_task_runner_->BelongsToCurrentThread()); 150 DCHECK(io_task_runner_->BelongsToCurrentThread());
146 const int kSessionId = 0;
147 if (ipc_) 151 if (ipc_)
148 ipc_->CreateStream(this, params, kSessionId); 152 ipc_->CreateStream(this, params);
149 } 153 }
150 154
151 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() { 155 void PepperPlatformAudioOutput::StartPlaybackOnIOThread() {
152 DCHECK(io_task_runner_->BelongsToCurrentThread()); 156 DCHECK(io_task_runner_->BelongsToCurrentThread());
153 if (ipc_) 157 if (ipc_)
154 ipc_->PlayStream(); 158 ipc_->PlayStream();
155 } 159 }
156 160
157 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() { 161 void PepperPlatformAudioOutput::StopPlaybackOnIOThread() {
158 DCHECK(io_task_runner_->BelongsToCurrentThread()); 162 DCHECK(io_task_runner_->BelongsToCurrentThread());
159 if (ipc_) 163 if (ipc_)
160 ipc_->PauseStream(); 164 ipc_->PauseStream();
161 } 165 }
162 166
163 void PepperPlatformAudioOutput::ShutDownOnIOThread() { 167 void PepperPlatformAudioOutput::ShutDownOnIOThread() {
164 DCHECK(io_task_runner_->BelongsToCurrentThread()); 168 DCHECK(io_task_runner_->BelongsToCurrentThread());
165 169
166 // Make sure we don't call shutdown more than once. 170 // Make sure we don't call shutdown more than once.
167 if (!ipc_) 171 if (!ipc_)
168 return; 172 return;
169 173
170 ipc_->CloseStream(); 174 ipc_->CloseStream();
171 ipc_.reset(); 175 ipc_.reset();
172 176
173 Release(); // Release for the delegate, balances out the reference taken in 177 Release(); // Release for the delegate, balances out the reference taken in
174 // PepperPlatformAudioOutput::Create. 178 // PepperPlatformAudioOutput::Create.
175 } 179 }
176 180
177 } // namespace content 181 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698