| 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/histogram.h" | 7 #include "base/histogram.h" |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/shared_memory.h" | 10 #include "base/shared_memory.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 process_handle_ = 0; | 114 process_handle_ = 0; |
| 115 | 115 |
| 116 // Since the IPC channel is gone, close all requested audio streams. | 116 // Since the IPC channel is gone, close all requested audio streams. |
| 117 DeleteEntries(); | 117 DeleteEntries(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
| 121 // media::AudioOutputController::EventHandler implementations. | 121 // media::AudioOutputController::EventHandler implementations. |
| 122 void AudioRendererHost::OnCreated(media::AudioOutputController* controller) { | 122 void AudioRendererHost::OnCreated(media::AudioOutputController* controller) { |
| 123 ChromeThread::PostTask( | 123 ChromeThread::PostTask( |
| 124 ChromeThread::IO, FROM_HERE, | 124 ChromeThread::IO, |
| 125 NewRunnableMethod(this, &AudioRendererHost::DoCompleteCreation, | 125 FROM_HERE, |
| 126 controller)); | 126 NewRunnableMethod( |
| 127 this, |
| 128 &AudioRendererHost::DoCompleteCreation, |
| 129 make_scoped_refptr(controller))); |
| 127 } | 130 } |
| 128 | 131 |
| 129 void AudioRendererHost::OnPlaying(media::AudioOutputController* controller) { | 132 void AudioRendererHost::OnPlaying(media::AudioOutputController* controller) { |
| 130 ChromeThread::PostTask( | 133 ChromeThread::PostTask( |
| 131 ChromeThread::IO, FROM_HERE, | 134 ChromeThread::IO, |
| 132 NewRunnableMethod(this, &AudioRendererHost::DoSendPlayingMessage, | 135 FROM_HERE, |
| 133 controller)); | 136 NewRunnableMethod( |
| 137 this, |
| 138 &AudioRendererHost::DoSendPlayingMessage, |
| 139 make_scoped_refptr(controller))); |
| 134 } | 140 } |
| 135 | 141 |
| 136 void AudioRendererHost::OnPaused(media::AudioOutputController* controller) { | 142 void AudioRendererHost::OnPaused(media::AudioOutputController* controller) { |
| 137 ChromeThread::PostTask( | 143 ChromeThread::PostTask( |
| 138 ChromeThread::IO, FROM_HERE, | 144 ChromeThread::IO, |
| 139 NewRunnableMethod(this, &AudioRendererHost::DoSendPausedMessage, | 145 FROM_HERE, |
| 140 controller)); | 146 NewRunnableMethod( |
| 147 this, |
| 148 &AudioRendererHost::DoSendPausedMessage, |
| 149 make_scoped_refptr(controller))); |
| 141 } | 150 } |
| 142 | 151 |
| 143 void AudioRendererHost::OnError(media::AudioOutputController* controller, | 152 void AudioRendererHost::OnError(media::AudioOutputController* controller, |
| 144 int error_code) { | 153 int error_code) { |
| 145 ChromeThread::PostTask( | 154 ChromeThread::PostTask( |
| 146 ChromeThread::IO, FROM_HERE, | 155 ChromeThread::IO, |
| 147 NewRunnableMethod(this, &AudioRendererHost::DoHandleError, | 156 FROM_HERE, |
| 148 controller, error_code)); | 157 NewRunnableMethod(this, |
| 158 &AudioRendererHost::DoHandleError, |
| 159 make_scoped_refptr(controller), |
| 160 error_code)); |
| 149 } | 161 } |
| 150 | 162 |
| 151 void AudioRendererHost::OnMoreData(media::AudioOutputController* controller, | 163 void AudioRendererHost::OnMoreData(media::AudioOutputController* controller, |
| 152 AudioBuffersState buffers_state) { | 164 AudioBuffersState buffers_state) { |
| 153 ChromeThread::PostTask( | 165 ChromeThread::PostTask( |
| 154 ChromeThread::IO, FROM_HERE, | 166 ChromeThread::IO, |
| 155 NewRunnableMethod(this, &AudioRendererHost::DoRequestMoreData, | 167 FROM_HERE, |
| 156 controller, buffers_state)); | 168 NewRunnableMethod(this, |
| 169 &AudioRendererHost::DoRequestMoreData, |
| 170 make_scoped_refptr(controller), |
| 171 buffers_state)); |
| 157 } | 172 } |
| 158 | 173 |
| 159 void AudioRendererHost::DoCompleteCreation( | 174 void AudioRendererHost::DoCompleteCreation( |
| 160 media::AudioOutputController* controller) { | 175 media::AudioOutputController* controller) { |
| 161 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 176 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 162 | 177 |
| 163 AudioEntry* entry = LookupByController(controller); | 178 AudioEntry* entry = LookupByController(controller); |
| 164 if (!entry) | 179 if (!entry) |
| 165 return; | 180 return; |
| 166 | 181 |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 574 |
| 560 // Iterate the map of entries. | 575 // Iterate the map of entries. |
| 561 // TODO(hclam): Implement a faster look up method. | 576 // TODO(hclam): Implement a faster look up method. |
| 562 for (AudioEntryMap::iterator i = audio_entries_.begin(); | 577 for (AudioEntryMap::iterator i = audio_entries_.begin(); |
| 563 i != audio_entries_.end(); ++i) { | 578 i != audio_entries_.end(); ++i) { |
| 564 if (controller == i->second->controller.get()) | 579 if (controller == i->second->controller.get()) |
| 565 return i->second; | 580 return i->second; |
| 566 } | 581 } |
| 567 return NULL; | 582 return NULL; |
| 568 } | 583 } |
| OLD | NEW |