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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) | 187 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) |
188 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream) | 188 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream) |
189 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream) | 189 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream) |
190 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume) | 190 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume) |
191 IPC_MESSAGE_UNHANDLED(handled = false) | 191 IPC_MESSAGE_UNHANDLED(handled = false) |
192 IPC_END_MESSAGE_MAP_EX() | 192 IPC_END_MESSAGE_MAP_EX() |
193 | 193 |
194 return handled; | 194 return handled; |
195 } | 195 } |
196 | 196 |
| 197 // TODO(miu): AudioRendererHost will keep track of the render_view_id associated |
| 198 // with the created audio stream in a soon-upcoming change. |
197 void AudioRendererHost::OnCreateStream( | 199 void AudioRendererHost::OnCreateStream( |
198 int stream_id, const media::AudioParameters& params, int input_channels) { | 200 int render_view_id, int stream_id, const media::AudioParameters& params, |
| 201 int input_channels) { |
199 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
200 DCHECK(LookupById(stream_id) == NULL); | 203 DCHECK(LookupById(stream_id) == NULL); |
201 | 204 |
| 205 // TODO(miu): There is still code in the renderer which has been stubbed out, |
| 206 // and should be implemented to plumb in the source render_view_id. See |
| 207 // http://crbug.com/156535. In debug mode, log a WARNING until this is |
| 208 // resolved. |
| 209 DLOG_IF(WARNING, render_view_id <= 0) |
| 210 << ("FIXME: AudioRendererHost::OnCreateStream called with unknown render " |
| 211 "view."); |
| 212 DVLOG(1) << "AudioRendererHost@" << this |
| 213 << "::OnCreateStream(render_view_id=" << render_view_id |
| 214 << ", stream_id=" << stream_id << ")"; |
| 215 |
202 media::AudioParameters audio_params(params); | 216 media::AudioParameters audio_params(params); |
203 uint32 buffer_size = media::AudioBus::CalculateMemorySize(audio_params); | 217 uint32 buffer_size = media::AudioBus::CalculateMemorySize(audio_params); |
204 DCHECK_GT(buffer_size, 0U); | 218 DCHECK_GT(buffer_size, 0U); |
205 DCHECK_LE(buffer_size, | 219 DCHECK_LE(buffer_size, |
206 static_cast<uint32>(media::limits::kMaxPacketSizeInBytes)); | 220 static_cast<uint32>(media::limits::kMaxPacketSizeInBytes)); |
207 | 221 |
208 DCHECK_GE(input_channels, 0); | 222 DCHECK_GE(input_channels, 0); |
209 DCHECK_LT(input_channels, media::limits::kMaxChannels); | 223 DCHECK_LT(input_channels, media::limits::kMaxChannels); |
210 | 224 |
211 // Calculate output and input memory size. | 225 // Calculate output and input memory size. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 | 411 |
398 // Iterate the map of entries. | 412 // Iterate the map of entries. |
399 // TODO(hclam): Implement a faster look up method. | 413 // TODO(hclam): Implement a faster look up method. |
400 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 414 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
401 i != audio_entries_.end(); ++i) { | 415 i != audio_entries_.end(); ++i) { |
402 if (!i->second->pending_close && controller == i->second->controller.get()) | 416 if (!i->second->pending_close && controller == i->second->controller.get()) |
403 return i->second; | 417 return i->second; |
404 } | 418 } |
405 return NULL; | 419 return NULL; |
406 } | 420 } |
OLD | NEW |