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_buffer_size, |
| 128 int new_sample_rate) { |
| 129 BrowserThread::PostTask( |
| 130 BrowserThread::IO, |
| 131 FROM_HERE, |
| 132 base::Bind(&AudioRendererHost::DoSendDeviceChangeMessage, |
| 133 this, make_scoped_refptr(controller), new_buffer_size, |
| 134 new_sample_rate)); |
| 135 } |
| 136 |
126 void AudioRendererHost::DoCompleteCreation( | 137 void AudioRendererHost::DoCompleteCreation( |
127 media::AudioOutputController* controller) { | 138 media::AudioOutputController* controller) { |
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
129 | 140 |
130 AudioEntry* entry = LookupByController(controller); | 141 AudioEntry* entry = LookupByController(controller); |
131 if (!entry) | 142 if (!entry) |
132 return; | 143 return; |
133 | 144 |
134 if (!peer_handle()) { | 145 if (!peer_handle()) { |
135 NOTREACHED() << "Renderer process handle is invalid."; | 146 NOTREACHED() << "Renderer process handle is invalid."; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
190 | 201 |
191 AudioEntry* entry = LookupByController(controller); | 202 AudioEntry* entry = LookupByController(controller); |
192 if (!entry) | 203 if (!entry) |
193 return; | 204 return; |
194 | 205 |
195 Send(new AudioMsg_NotifyStreamStateChanged( | 206 Send(new AudioMsg_NotifyStreamStateChanged( |
196 entry->stream_id, media::AudioOutputIPCDelegate::kPaused)); | 207 entry->stream_id, media::AudioOutputIPCDelegate::kPaused)); |
197 } | 208 } |
198 | 209 |
| 210 void AudioRendererHost::DoSendDeviceChangeMessage( |
| 211 media::AudioOutputController* controller, int new_buffer_size, |
| 212 int new_sample_rate) { |
| 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 214 |
| 215 AudioEntry* entry = LookupByController(controller); |
| 216 if (!entry) |
| 217 return; |
| 218 |
| 219 Send(new AudioMsg_NotifyDeviceChanged( |
| 220 entry->stream_id, new_buffer_size, new_sample_rate)); |
| 221 } |
| 222 |
199 void AudioRendererHost::DoHandleError(media::AudioOutputController* controller, | 223 void AudioRendererHost::DoHandleError(media::AudioOutputController* controller, |
200 int error_code) { | 224 int error_code) { |
201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
202 | 226 |
203 AudioEntry* entry = LookupByController(controller); | 227 AudioEntry* entry = LookupByController(controller); |
204 if (!entry) | 228 if (!entry) |
205 return; | 229 return; |
206 | 230 |
207 DeleteEntryOnError(entry); | 231 DeleteEntryOnError(entry); |
208 } | 232 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 return NULL; | 490 return NULL; |
467 } | 491 } |
468 | 492 |
469 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( | 493 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( |
470 int stream_id) { | 494 int stream_id) { |
471 AudioEntry* const entry = LookupById(stream_id); | 495 AudioEntry* const entry = LookupById(stream_id); |
472 return entry ? entry->controller : NULL; | 496 return entry ? entry->controller : NULL; |
473 } | 497 } |
474 | 498 |
475 } // namespace content | 499 } // namespace content |
OLD | NEW |