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

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

Issue 2622073003: Fix getUserMedia so that failure is reported for invalid audio sources. (Closed)
Patch Set: Switch to std::vector and std::unique_ptr 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
295 } 301 }
296 302
297 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) { 303 void AudioInputDevice::AudioThreadCallback::Process(uint32_t pending_data) {
298 // The shared memory represents parameters, size of the data buffer and the 304 // The shared memory represents parameters, size of the data buffer and the
299 // actual data buffer containing audio data. Map the memory into this 305 // actual data buffer containing audio data. Map the memory into this
300 // structure and parse out parameters and the data area. 306 // structure and parse out parameters and the data area.
301 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory()); 307 uint8_t* ptr = static_cast<uint8_t*>(shared_memory_.memory());
302 ptr += current_segment_id_ * segment_length_; 308 ptr += current_segment_id_ * segment_length_;
303 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr); 309 AudioInputBuffer* buffer = reinterpret_cast<AudioInputBuffer*>(ptr);
304 310
(...skipping 27 matching lines...) Expand all
332 capture_callback_->Capture( 338 capture_callback_->Capture(
333 audio_bus, 339 audio_bus,
334 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms 340 buffer->params.hardware_delay_bytes / bytes_per_ms_, // Delay in ms
335 buffer->params.volume, buffer->params.key_pressed); 341 buffer->params.volume, buffer->params.key_pressed);
336 342
337 if (++current_segment_id_ >= total_segments_) 343 if (++current_segment_id_ >= total_segments_)
338 current_segment_id_ = 0; 344 current_segment_id_ = 0;
339 } 345 }
340 346
341 } // namespace media 347 } // namespace media
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/webrtc_media_stream_adapter_unittest.cc ('k') | media/audio/audio_input_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698