| 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_input_device.h" | 5 #include "media/audio/audio_input_device.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { | 283 void AudioInputDevice::AudioThreadCallback::MapSharedMemory() { |
| 284 shared_memory_.Map(memory_length_); | 284 shared_memory_.Map(memory_length_); |
| 285 | 285 |
| 286 // Create vector of audio buses by wrapping existing blocks of memory. | 286 // Create vector of audio buses by wrapping existing blocks of memory. |
| 287 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); | 287 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); |
| 288 for (int i = 0; i < total_segments_; ++i) { | 288 for (int i = 0; i < total_segments_; ++i) { |
| 289 media::AudioInputBuffer* buffer = | 289 media::AudioInputBuffer* buffer = |
| 290 reinterpret_cast<media::AudioInputBuffer*>(ptr); | 290 reinterpret_cast<media::AudioInputBuffer*>(ptr); |
| 291 scoped_ptr<media::AudioBus> audio_bus = | 291 scoped_ptr<media::AudioBus> audio_bus = |
| 292 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); | 292 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); |
| 293 audio_buses_.push_back(audio_bus.release()); | 293 audio_buses_.push_back(audio_bus.Pass()); |
| 294 ptr += segment_length_; | 294 ptr += segment_length_; |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| 298 void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { | 298 void AudioInputDevice::AudioThreadCallback::Process(uint32 pending_data) { |
| 299 // The shared memory represents parameters, size of the data buffer and the | 299 // The shared memory represents parameters, size of the data buffer and the |
| 300 // actual data buffer containing audio data. Map the memory into this | 300 // actual data buffer containing audio data. Map the memory into this |
| 301 // structure and parse out parameters and the data area. | 301 // structure and parse out parameters and the data area. |
| 302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); | 302 uint8* ptr = static_cast<uint8*>(shared_memory_.memory()); |
| 303 ptr += current_segment_id_ * segment_length_; | 303 ptr += current_segment_id_ * segment_length_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 316 // and update the audio-delay measurement. | 316 // and update the audio-delay measurement. |
| 317 int audio_delay_milliseconds = pending_data / bytes_per_ms_; | 317 int audio_delay_milliseconds = pending_data / bytes_per_ms_; |
| 318 capture_callback_->Capture( | 318 capture_callback_->Capture( |
| 319 audio_bus, audio_delay_milliseconds, volume, key_pressed); | 319 audio_bus, audio_delay_milliseconds, volume, key_pressed); |
| 320 | 320 |
| 321 if (++current_segment_id_ >= total_segments_) | 321 if (++current_segment_id_ >= total_segments_) |
| 322 current_segment_id_ = 0; | 322 current_segment_id_ = 0; |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace media | 325 } // namespace media |
| OLD | NEW |