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 "media/audio/audio_device_thread.h" | 5 #include "media/audio/audio_device_thread.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 base::AutoLock auto_lock(callback_lock_); | 170 base::AutoLock auto_lock(callback_lock_); |
171 if (callback_) | 171 if (callback_) |
172 callback_->Process(pending_data); | 172 callback_->Process(pending_data); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 // AudioDeviceThread::Callback implementation | 176 // AudioDeviceThread::Callback implementation |
177 | 177 |
178 AudioDeviceThread::Callback::Callback( | 178 AudioDeviceThread::Callback::Callback( |
179 const AudioParameters& audio_parameters, | 179 const AudioParameters& audio_parameters, |
| 180 int input_channels, |
180 base::SharedMemoryHandle memory, int memory_length) | 181 base::SharedMemoryHandle memory, int memory_length) |
181 : audio_parameters_(audio_parameters), | 182 : audio_parameters_(audio_parameters), |
| 183 input_channels_(input_channels), |
182 samples_per_ms_(audio_parameters.sample_rate() / 1000), | 184 samples_per_ms_(audio_parameters.sample_rate() / 1000), |
183 bytes_per_ms_(audio_parameters.channels() * | 185 bytes_per_ms_(audio_parameters.channels() * |
184 (audio_parameters_.bits_per_sample() / 8) * | 186 (audio_parameters_.bits_per_sample() / 8) * |
185 samples_per_ms_), | 187 samples_per_ms_), |
186 shared_memory_(memory, false), | 188 shared_memory_(memory, false), |
187 memory_length_(memory_length) { | 189 memory_length_(memory_length) { |
188 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early. | 190 CHECK_NE(bytes_per_ms_, 0); // Catch division by zero early. |
189 CHECK_NE(samples_per_ms_, 0); | 191 CHECK_NE(samples_per_ms_, 0); |
190 } | 192 } |
191 | 193 |
192 AudioDeviceThread::Callback::~Callback() {} | 194 AudioDeviceThread::Callback::~Callback() {} |
193 | 195 |
194 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 196 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
195 MapSharedMemory(); | 197 MapSharedMemory(); |
196 DCHECK(shared_memory_.memory() != NULL); | 198 DCHECK(shared_memory_.memory() != NULL); |
197 } | 199 } |
198 | 200 |
199 } // namespace media. | 201 } // namespace media. |
OLD | NEW |