| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/audio_renderer_host.h" | 5 #include "chrome/browser/renderer_host/audio_renderer_host.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "base/process.h" | 8 #include "base/process.h" |
| 9 #include "base/shared_memory.h" | 9 #include "base/shared_memory.h" |
| 10 #include "chrome/browser/renderer_host/audio_sync_reader.h" | 10 #include "chrome/browser/renderer_host/audio_sync_reader.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 /////////////////////////////////////////////////////////////////////////////// | 49 /////////////////////////////////////////////////////////////////////////////// |
| 50 // AudioRendererHost implementations. | 50 // AudioRendererHost implementations. |
| 51 AudioRendererHost::AudioRendererHost() { | 51 AudioRendererHost::AudioRendererHost() { |
| 52 } | 52 } |
| 53 | 53 |
| 54 AudioRendererHost::~AudioRendererHost() { | 54 AudioRendererHost::~AudioRendererHost() { |
| 55 DCHECK(audio_entries_.empty()); | 55 DCHECK(audio_entries_.empty()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void AudioRendererHost::OnChannelClosing() { | 58 void AudioRendererHost::OnChannelClosing() { |
| 59 BrowserIOMessageFilter::OnChannelClosing(); | 59 BrowserMessageFilter::OnChannelClosing(); |
| 60 | 60 |
| 61 // Since the IPC channel is gone, close all requested audio streams. | 61 // Since the IPC channel is gone, close all requested audio streams. |
| 62 DeleteEntries(); | 62 DeleteEntries(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void AudioRendererHost::OnDestruct() const { | 65 void AudioRendererHost::OnDestruct() const { |
| 66 BrowserThread::DeleteOnIOThread::Destruct(this); | 66 BrowserThread::DeleteOnIOThread::Destruct(this); |
| 67 } | 67 } |
| 68 | 68 |
| 69 /////////////////////////////////////////////////////////////////////////////// | 69 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 226 |
| 227 AudioEntry* entry = LookupByController(controller); | 227 AudioEntry* entry = LookupByController(controller); |
| 228 if (!entry) | 228 if (!entry) |
| 229 return; | 229 return; |
| 230 | 230 |
| 231 DeleteEntryOnError(entry); | 231 DeleteEntryOnError(entry); |
| 232 } | 232 } |
| 233 | 233 |
| 234 /////////////////////////////////////////////////////////////////////////////// | 234 /////////////////////////////////////////////////////////////////////////////// |
| 235 // IPC Messages handler | 235 // IPC Messages handler |
| 236 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message) { | 236 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message, |
| 237 bool* message_was_ok) { |
| 237 bool handled = true; | 238 bool handled = true; |
| 238 bool message_was_ok = true; | 239 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok) |
| 239 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, message_was_ok) | |
| 240 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateAudioStream, OnCreateStream) | 240 IPC_MESSAGE_HANDLER(ViewHostMsg_CreateAudioStream, OnCreateStream) |
| 241 IPC_MESSAGE_HANDLER(ViewHostMsg_PlayAudioStream, OnPlayStream) | 241 IPC_MESSAGE_HANDLER(ViewHostMsg_PlayAudioStream, OnPlayStream) |
| 242 IPC_MESSAGE_HANDLER(ViewHostMsg_PauseAudioStream, OnPauseStream) | 242 IPC_MESSAGE_HANDLER(ViewHostMsg_PauseAudioStream, OnPauseStream) |
| 243 IPC_MESSAGE_HANDLER(ViewHostMsg_FlushAudioStream, OnFlushStream) | 243 IPC_MESSAGE_HANDLER(ViewHostMsg_FlushAudioStream, OnFlushStream) |
| 244 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseAudioStream, OnCloseStream) | 244 IPC_MESSAGE_HANDLER(ViewHostMsg_CloseAudioStream, OnCloseStream) |
| 245 IPC_MESSAGE_HANDLER(ViewHostMsg_NotifyAudioPacketReady, OnNotifyPacketReady) | 245 IPC_MESSAGE_HANDLER(ViewHostMsg_NotifyAudioPacketReady, OnNotifyPacketReady) |
| 246 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioVolume, OnGetVolume) | 246 IPC_MESSAGE_HANDLER(ViewHostMsg_GetAudioVolume, OnGetVolume) |
| 247 IPC_MESSAGE_HANDLER(ViewHostMsg_SetAudioVolume, OnSetVolume) | 247 IPC_MESSAGE_HANDLER(ViewHostMsg_SetAudioVolume, OnSetVolume) |
| 248 IPC_MESSAGE_UNHANDLED(handled = false) | 248 IPC_MESSAGE_UNHANDLED(handled = false) |
| 249 IPC_END_MESSAGE_MAP_EX() | 249 IPC_END_MESSAGE_MAP_EX() |
| 250 | 250 |
| 251 if (!message_was_ok) | |
| 252 BadMessageReceived(message.type()); | |
| 253 | |
| 254 return handled; | 251 return handled; |
| 255 } | 252 } |
| 256 | 253 |
| 257 void AudioRendererHost::OnCreateStream( | 254 void AudioRendererHost::OnCreateStream( |
| 258 const IPC::Message& msg, int stream_id, | 255 const IPC::Message& msg, int stream_id, |
| 259 const ViewHostMsg_Audio_CreateStream_Params& params, bool low_latency) { | 256 const ViewHostMsg_Audio_CreateStream_Params& params, bool low_latency) { |
| 260 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 261 DCHECK(LookupById(msg.routing_id(), stream_id) == NULL); | 258 DCHECK(LookupById(msg.routing_id(), stream_id) == NULL); |
| 262 | 259 |
| 263 AudioParameters audio_params(params.params); | 260 AudioParameters audio_params(params.params); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 | 470 |
| 474 // Iterate the map of entries. | 471 // Iterate the map of entries. |
| 475 // TODO(hclam): Implement a faster look up method. | 472 // TODO(hclam): Implement a faster look up method. |
| 476 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 473 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 477 i != audio_entries_.end(); ++i) { | 474 i != audio_entries_.end(); ++i) { |
| 478 if (controller == i->second->controller.get()) | 475 if (controller == i->second->controller.get()) |
| 479 return i->second; | 476 return i->second; |
| 480 } | 477 } |
| 481 return NULL; | 478 return NULL; |
| 482 } | 479 } |
| OLD | NEW |