| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Create vector of audio buses by wrapping existing blocks of memory. | 305 // Create vector of audio buses by wrapping existing blocks of memory. |
| 306 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); | 306 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); |
| 307 for (int i = 0; i < total_segments_; ++i) { | 307 for (int i = 0; i < total_segments_; ++i) { |
| 308 media::AudioInputBuffer* buffer = | 308 media::AudioInputBuffer* buffer = |
| 309 reinterpret_cast<media::AudioInputBuffer*>(ptr); | 309 reinterpret_cast<media::AudioInputBuffer*>(ptr); |
| 310 std::unique_ptr<media::AudioBus> audio_bus = | 310 std::unique_ptr<media::AudioBus> audio_bus = |
| 311 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); | 311 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); |
| 312 audio_buses_.push_back(std::move(audio_bus)); | 312 audio_buses_.push_back(std::move(audio_bus)); |
| 313 ptr += segment_length_; | 313 ptr += segment_length_; |
| 314 } | 314 } |
| 315 | |
| 316 // Indicate that browser side capture initialization has succeeded and IPC | |
| 317 // channel initialized. This effectively completes the | |
| 318 // AudioCapturerSource::Start()' phase as far as the caller of that function | |
| 319 // is concerned. | |
| 320 capture_callback_->OnCaptureStarted(); | |
| 321 } | 315 } |
| 322 | 316 |
| 323 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { | 317 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
| 324 // The shared memory represents parameters, size of the data buffer and the | 318 // The shared memory represents parameters, size of the data buffer and the |
| 325 // actual data buffer containing audio data. Map the memory into this | 319 // actual data buffer containing audio data. Map the memory into this |
| 326 // structure and parse out parameters and the data area. | 320 // structure and parse out parameters and the data area. |
| 327 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); | 321 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); |
| 328 ptr += current_segment_id_ * segment_length_; | 322 ptr += current_segment_id_ * segment_length_; |
| 329 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); | 323 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); |
| 330 | 324 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 358 capture_callback_->Capture( | 352 capture_callback_->Capture( |
| 359 audio_bus, | 353 audio_bus, |
| 360 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms | 354 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms |
| 361 buffer->params.volume, buffer->params.key_pressed); | 355 buffer->params.volume, buffer->params.key_pressed); |
| 362 | 356 |
| 363 if (++current_segment_id_ >= total_segments_) | 357 if (++current_segment_id_ >= total_segments_) |
| 364 current_segment_id_ = 0; | 358 current_segment_id_ = 0; |
| 365 } | 359 } |
| 366 | 360 |
| 367 } // namespace media | 361 } // namespace media |
| OLD | NEW |