| 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/renderer/media/audio_device_thread.h" | 5 #include "content/renderer/media/audio_device_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/platform_thread.h" | 10 #include "base/threading/platform_thread.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 callback_->Process(pending_data); | 167 callback_->Process(pending_data); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 // AudioDeviceThread::Callback implementation | 171 // AudioDeviceThread::Callback implementation |
| 172 | 172 |
| 173 AudioDeviceThread::Callback::Callback(const AudioParameters& audio_parameters, | 173 AudioDeviceThread::Callback::Callback(const AudioParameters& audio_parameters, |
| 174 base::SharedMemoryHandle memory, | 174 base::SharedMemoryHandle memory, |
| 175 int memory_length) | 175 int memory_length) |
| 176 : audio_parameters_(audio_parameters), | 176 : audio_parameters_(audio_parameters), |
| 177 samples_per_ms_(audio_parameters.sample_rate / 1000), | 177 samples_per_ms_(audio_parameters.sample_rate() / 1000), |
| 178 bytes_per_ms_(audio_parameters.channels * | 178 bytes_per_ms_(audio_parameters.channels() * |
| 179 (audio_parameters_.bits_per_sample / 8) * | 179 (audio_parameters_.bits_per_sample() / 8) * |
| 180 samples_per_ms_), | 180 samples_per_ms_), |
| 181 shared_memory_(memory, false), | 181 shared_memory_(memory, false), |
| 182 memory_length_(memory_length) { | 182 memory_length_(memory_length) { |
| 183 } | 183 } |
| 184 | 184 |
| 185 AudioDeviceThread::Callback::~Callback() { | 185 AudioDeviceThread::Callback::~Callback() { |
| 186 for (size_t i = 0; i < audio_data_.size(); ++i) | 186 for (size_t i = 0; i < audio_data_.size(); ++i) |
| 187 delete [] audio_data_[i]; | 187 delete [] audio_data_[i]; |
| 188 } | 188 } |
| 189 | 189 |
| 190 void AudioDeviceThread::Callback::InitializeOnAudioThread() { | 190 void AudioDeviceThread::Callback::InitializeOnAudioThread() { |
| 191 DCHECK(audio_data_.empty()); | 191 DCHECK(audio_data_.empty()); |
| 192 | 192 |
| 193 MapSharedMemory(); | 193 MapSharedMemory(); |
| 194 DCHECK(shared_memory_.memory() != NULL); | 194 DCHECK(shared_memory_.memory() != NULL); |
| 195 | 195 |
| 196 audio_data_.reserve(audio_parameters_.channels); | 196 audio_data_.reserve(audio_parameters_.channels()); |
| 197 for (int i = 0; i < audio_parameters_.channels; ++i) { | 197 for (int i = 0; i < audio_parameters_.channels(); ++i) { |
| 198 float* channel_data = new float[audio_parameters_.samples_per_packet]; | 198 float* channel_data = new float[audio_parameters_.frames_per_buffer()]; |
| 199 audio_data_.push_back(channel_data); | 199 audio_data_.push_back(channel_data); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | |
| OLD | NEW |