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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Create vector of audio buses by wrapping existing blocks of memory. | 285 // Create vector of audio buses by wrapping existing blocks of memory. |
286 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); | 286 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); |
287 for (int i = 0; i < total_segments_; ++i) { | 287 for (int i = 0; i < total_segments_; ++i) { |
288 media::AudioInputBuffer* buffer = | 288 media::AudioInputBuffer* buffer = |
289 reinterpret_cast<media::AudioInputBuffer*>(ptr); | 289 reinterpret_cast<media::AudioInputBuffer*>(ptr); |
290 std::unique_ptr<media::AudioBus> audio_bus = | 290 std::unique_ptr<media::AudioBus> audio_bus = |
291 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); | 291 media::AudioBus::WrapMemory(audio_parameters_, buffer->audio); |
292 audio_buses_.push_back(std::move(audio_bus)); | 292 audio_buses_.push_back(std::move(audio_bus)); |
293 ptr += segment_length_; | 293 ptr += segment_length_; |
294 } | 294 } |
295 | |
296 // Indicate that browser side capture initialization has succeeded and IPC | |
297 // channel initialized. This effectively completes the | |
298 // AudioCapturerSource::Start()' phase as far as the caller of that function | |
299 // is concerned. | |
300 capture_callback_->OnCaptureStarted(); | |
301 } | 295 } |
302 | 296 |
303 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { | 297 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
304 // The shared memory represents parameters, size of the data buffer and the | 298 // The shared memory represents parameters, size of the data buffer and the |
305 // actual data buffer containing audio data. Map the memory into this | 299 // actual data buffer containing audio data. Map the memory into this |
306 // structure and parse out parameters and the data area. | 300 // structure and parse out parameters and the data area. |
307 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); | 301 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); |
308 ptr += current_segment_id_ * segment_length_; | 302 ptr += current_segment_id_ * segment_length_; |
309 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); | 303 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); |
310 | 304 |
(...skipping 27 matching lines...) Expand all Loading... |
338 capture_callback_->Capture( | 332 capture_callback_->Capture( |
339 audio_bus, | 333 audio_bus, |
340 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms | 334 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms |
341 buffer->params.volume, buffer->params.key_pressed); | 335 buffer->params.volume, buffer->params.key_pressed); |
342 | 336 |
343 if (++current_segment_id_ >= total_segments_) | 337 if (++current_segment_id_ >= total_segments_) |
344 current_segment_id_ = 0; | 338 current_segment_id_ = 0; |
345 } | 339 } |
346 | 340 |
347 } // namespace media | 341 } // namespace media |
OLD | NEW |