Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: media/audio/audio_input_device.cc

Issue 2623443002: Fix getUserMedia so that failure is reported for invalid audio sources. (Closed)
Patch Set: Address comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
315 } 321 }
316 322
317 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { 323 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
318 // The shared memory represents parameters, size of the data buffer and the 324 // The shared memory represents parameters, size of the data buffer and the
319 // actual data buffer containing audio data. Map the memory into this 325 // actual data buffer containing audio data. Map the memory into this
320 // structure and parse out parameters and the data area. 326 // structure and parse out parameters and the data area.
321 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); 327 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory());
322 ptr += current_segment_id_ * segment_length_; 328 ptr += current_segment_id_ * segment_length_;
323 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 329 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
324 330
(...skipping 27 matching lines...) Expand all
352 capture_callback_->Capture( 358 capture_callback_->Capture(
353 audio_bus, 359 audio_bus,
354 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 360 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
355 buffer->params.volume, buffer->params.key_pressed); 361 buffer->params.volume, buffer->params.key_pressed);
356 362
357 if (++current_segment_id_ >= total_segments_) 363 if (++current_segment_id_ >= total_segments_)
358 current_segment_id_ = 0; 364 current_segment_id_ = 0;
359 } 365 }
360 366
361 } // namespace media 367 } // namespace media
OLDNEW
« no previous file with comments | « content/shell/renderer/layout_test/blink_test_runner.cc ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698