| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 DeleteEntryOnError(entry); | 196 DeleteEntryOnError(entry); |
| 197 } | 197 } |
| 198 | 198 |
| 199 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
| 200 // IPC Messages handler | 200 // IPC Messages handler |
| 201 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message, | 201 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message, |
| 202 bool* message_was_ok) { | 202 bool* message_was_ok) { |
| 203 bool handled = true; | 203 bool handled = true; |
| 204 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok) | 204 IPC_BEGIN_MESSAGE_MAP_EX(AudioRendererHost, message, *message_was_ok) |
| 205 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) | 205 IPC_MESSAGE_HANDLER(AudioHostMsg_CreateStream, OnCreateStream) |
| 206 IPC_MESSAGE_HANDLER(AudioHostMsg_AssociateStreamWithProducer, |
| 207 OnAssociateStreamWithProducer) |
| 206 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) | 208 IPC_MESSAGE_HANDLER(AudioHostMsg_PlayStream, OnPlayStream) |
| 207 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) | 209 IPC_MESSAGE_HANDLER(AudioHostMsg_PauseStream, OnPauseStream) |
| 208 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream) | 210 IPC_MESSAGE_HANDLER(AudioHostMsg_FlushStream, OnFlushStream) |
| 209 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream) | 211 IPC_MESSAGE_HANDLER(AudioHostMsg_CloseStream, OnCloseStream) |
| 210 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume) | 212 IPC_MESSAGE_HANDLER(AudioHostMsg_SetVolume, OnSetVolume) |
| 211 IPC_MESSAGE_UNHANDLED(handled = false) | 213 IPC_MESSAGE_UNHANDLED(handled = false) |
| 212 IPC_END_MESSAGE_MAP_EX() | 214 IPC_END_MESSAGE_MAP_EX() |
| 213 | 215 |
| 214 return handled; | 216 return handled; |
| 215 } | 217 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 276 } |
| 275 | 277 |
| 276 // If we have created the controller successfully, create an entry and add it | 278 // If we have created the controller successfully, create an entry and add it |
| 277 // to the map. | 279 // to the map. |
| 278 entry->stream_id = stream_id; | 280 entry->stream_id = stream_id; |
| 279 audio_entries_.insert(std::make_pair(stream_id, entry.release())); | 281 audio_entries_.insert(std::make_pair(stream_id, entry.release())); |
| 280 if (media_observer_) | 282 if (media_observer_) |
| 281 media_observer_->OnSetAudioStreamStatus(this, stream_id, "created"); | 283 media_observer_->OnSetAudioStreamStatus(this, stream_id, "created"); |
| 282 } | 284 } |
| 283 | 285 |
| 286 void AudioRendererHost::OnAssociateStreamWithProducer(int stream_id, |
| 287 int render_view_id) { |
| 288 // TODO(miu): Will use render_view_id in upcoming change. |
| 289 DVLOG(1) << "AudioRendererHost@" << this |
| 290 << "::OnAssociateStreamWithProducer(stream_id=" << stream_id |
| 291 << ", render_view_id=" << render_view_id << ")"; |
| 292 } |
| 293 |
| 284 void AudioRendererHost::OnPlayStream(int stream_id) { | 294 void AudioRendererHost::OnPlayStream(int stream_id) { |
| 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 286 | 296 |
| 287 AudioEntry* entry = LookupById(stream_id); | 297 AudioEntry* entry = LookupById(stream_id); |
| 288 if (!entry) { | 298 if (!entry) { |
| 289 SendErrorMessage(stream_id); | 299 SendErrorMessage(stream_id); |
| 290 return; | 300 return; |
| 291 } | 301 } |
| 292 | 302 |
| 293 entry->controller->Play(); | 303 entry->controller->Play(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 return NULL; | 435 return NULL; |
| 426 } | 436 } |
| 427 | 437 |
| 428 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( | 438 media::AudioOutputController* AudioRendererHost::LookupControllerByIdForTesting( |
| 429 int stream_id) { | 439 int stream_id) { |
| 430 AudioEntry* const entry = LookupById(stream_id); | 440 AudioEntry* const entry = LookupById(stream_id); |
| 431 return entry ? entry->controller : NULL; | 441 return entry ? entry->controller : NULL; |
| 432 } | 442 } |
| 433 | 443 |
| 434 } // namespace content | 444 } // namespace content |
| OLD | NEW |