| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/media/audio_input_device.h" | 5 #include "content/renderer/media/audio_input_device.h" |
| 6 | 6 |
| 7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
| 10 #include "content/common/media/audio_messages.h" | 10 #include "content/common/media/audio_messages.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 bool AudioInputDevice::GetVolume(double* volume) { | 128 bool AudioInputDevice::GetVolume(double* volume) { |
| 129 NOTIMPLEMENTED(); | 129 NOTIMPLEMENTED(); |
| 130 return false; | 130 return false; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void AudioInputDevice::InitializeOnIOThread(const AudioParameters& params) { | 133 void AudioInputDevice::InitializeOnIOThread(const AudioParameters& params) { |
| 134 stream_id_ = filter_->AddDelegate(this); | 134 stream_id_ = filter_->AddDelegate(this); |
| 135 filter_->Send( | 135 filter_->Send( |
| 136 new AudioInputHostMsg_CreateStream(0, stream_id_, params, true)); | 136 new AudioInputHostMsg_CreateStream(stream_id_, params, true)); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void AudioInputDevice::StartOnIOThread() { | 139 void AudioInputDevice::StartOnIOThread() { |
| 140 if (stream_id_) | 140 if (stream_id_) |
| 141 filter_->Send(new AudioInputHostMsg_RecordStream(0, stream_id_)); | 141 filter_->Send(new AudioInputHostMsg_RecordStream(stream_id_)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void AudioInputDevice::ShutDownOnIOThread() { | 144 void AudioInputDevice::ShutDownOnIOThread() { |
| 145 // Make sure we don't call shutdown more than once. | 145 // Make sure we don't call shutdown more than once. |
| 146 if (!stream_id_) | 146 if (!stream_id_) |
| 147 return; | 147 return; |
| 148 | 148 |
| 149 filter_->Send(new AudioInputHostMsg_CloseStream(0, stream_id_)); | 149 filter_->Send(new AudioInputHostMsg_CloseStream(stream_id_)); |
| 150 filter_->RemoveDelegate(stream_id_); | 150 filter_->RemoveDelegate(stream_id_); |
| 151 stream_id_ = 0; | 151 stream_id_ = 0; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void AudioInputDevice::SetVolumeOnIOThread(double volume) { | 154 void AudioInputDevice::SetVolumeOnIOThread(double volume) { |
| 155 if (stream_id_) | 155 if (stream_id_) |
| 156 filter_->Send(new AudioInputHostMsg_SetVolume(0, stream_id_, volume)); | 156 filter_->Send(new AudioInputHostMsg_SetVolume(stream_id_, volume)); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void AudioInputDevice::OnLowLatencyCreated( | 159 void AudioInputDevice::OnLowLatencyCreated( |
| 160 base::SharedMemoryHandle handle, | 160 base::SharedMemoryHandle handle, |
| 161 base::SyncSocket::Handle socket_handle, | 161 base::SyncSocket::Handle socket_handle, |
| 162 uint32 length) { | 162 uint32 length) { |
| 163 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
| 164 DCHECK(handle); | 164 DCHECK(handle); |
| 165 DCHECK(socket_handle); | 165 DCHECK(socket_handle); |
| 166 #else | 166 #else |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 bytes_per_sample, | 232 bytes_per_sample, |
| 233 number_of_frames); | 233 number_of_frames); |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Deliver captured data to the client in floating point format | 236 // Deliver captured data to the client in floating point format |
| 237 // and update the audio-delay measurement. | 237 // and update the audio-delay measurement. |
| 238 callback_->Capture(audio_data_, | 238 callback_->Capture(audio_data_, |
| 239 number_of_frames, | 239 number_of_frames, |
| 240 audio_delay_milliseconds_); | 240 audio_delay_milliseconds_); |
| 241 } | 241 } |
| OLD | NEW |