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/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process.h" | 9 #include "base/process.h" |
10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 void AudioRendererHost::OnError(media::AudioOutputController* controller, | 117 void AudioRendererHost::OnError(media::AudioOutputController* controller, |
118 int error_code) { | 118 int error_code) { |
119 BrowserThread::PostTask( | 119 BrowserThread::PostTask( |
120 BrowserThread::IO, | 120 BrowserThread::IO, |
121 FROM_HERE, | 121 FROM_HERE, |
122 base::Bind(&AudioRendererHost::DoHandleError, | 122 base::Bind(&AudioRendererHost::DoHandleError, |
123 this, make_scoped_refptr(controller), error_code)); | 123 this, make_scoped_refptr(controller), error_code)); |
124 } | 124 } |
125 | 125 |
| 126 void AudioRendererHost::OnDeviceChange(media::AudioOutputController* controller, |
| 127 int new_sample_rate, |
| 128 int new_buffer_size) { |
| 129 BrowserThread::PostTask( |
| 130 BrowserThread::IO, |
| 131 FROM_HERE, |
| 132 base::Bind( |
| 133 &AudioRendererHost::DoSendDeviceChangeMessage, |
| 134 this, |
| 135 make_scoped_refptr(controller), new_sample_rate, new_buffer_size)); |
| 136 } |
| 137 |
126 void AudioRendererHost::DoCompleteCreation( | 138 void AudioRendererHost::DoCompleteCreation( |
127 media::AudioOutputController* controller) { | 139 media::AudioOutputController* controller) { |
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 140 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
129 | 141 |
130 AudioEntry* entry = LookupByController(controller); | 142 AudioEntry* entry = LookupByController(controller); |
131 if (!entry) | 143 if (!entry) |
132 return; | 144 return; |
133 | 145 |
134 if (!peer_handle()) { | 146 if (!peer_handle()) { |
135 NOTREACHED() << "Renderer process handle is invalid."; | 147 NOTREACHED() << "Renderer process handle is invalid."; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 int error_code) { | 212 int error_code) { |
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
202 | 214 |
203 AudioEntry* entry = LookupByController(controller); | 215 AudioEntry* entry = LookupByController(controller); |
204 if (!entry) | 216 if (!entry) |
205 return; | 217 return; |
206 | 218 |
207 DeleteEntryOnError(entry); | 219 DeleteEntryOnError(entry); |
208 } | 220 } |
209 | 221 |
| 222 void AudioRendererHost::DoSendDeviceChangeMessage( |
| 223 media::AudioOutputController* controller, int new_sample_rate, |
| 224 int new_buffer_size) { |
| 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 226 |
| 227 AudioEntry* entry = LookupByController(controller); |
| 228 if (!entry) |
| 229 return; |
| 230 |
| 231 LOG(ERROR) << "SENDING DEV CHANGE MESSAGE"; |
| 232 |
| 233 Send(new AudioMsg_NotifyDeviceChanged( |
| 234 entry->stream_id, new_sample_rate, new_buffer_size)); |
| 235 } |
| 236 |
210 /////////////////////////////////////////////////////////////////////////////// | 237 /////////////////////////////////////////////////////////////////////////////// |
211 // IPC Messages handler | 238 // IPC Messages handler |
212 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message, | 239 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message, |
213 bool* message_was_ok) { | 240 bool* message_was_ok) { |
214 bool handled = true; | 241 bool handled = true; |
215 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok) | 242 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok) |
216 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) | 243 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) |
217 IPC_MESSAGE_HANDLER(AudioHostMsg_AssociateStreamWithProducer, | 244 IPC_MESSAGE_HANDLER(AudioHostMsg_AssociateStreamWithProducer, |
218 OnAssociateStreamWithProducer) | 245 OnAssociateStreamWithProducer) |
219 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) | 246 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return NULL; | 493 return NULL; |
467 } | 494 } |
468 | 495 |
469 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( | 496 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( |
470 int stream_id) { | 497 int stream_id) { |
471 AudioEntry* const entry = LookupById(stream_id); | 498 AudioEntry* const entry = LookupById(stream_id); |
472 return entry ? entry->controller : NULL; | 499 return entry ? entry->controller : NULL; |
473 } | 500 } |
474 | 501 |
475 } // namespace content | 502 } // namespace content |
OLD | NEW |