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 "content/browser/renderer_host/media/audio_input_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 DCHECK_GT(render_frame_id, 0); | 308 DCHECK_GT(render_frame_id, 0); |
309 | 309 |
310 // media::AudioParameters is validated in the deserializer. | 310 // media::AudioParameters is validated in the deserializer. |
311 if (LookupById(stream_id) != NULL) { | 311 if (LookupById(stream_id) != NULL) { |
312 SendErrorMessage(stream_id, STREAM_ALREADY_EXISTS); | 312 SendErrorMessage(stream_id, STREAM_ALREADY_EXISTS); |
313 MaybeUnregisterKeyboardMicStream(config); | 313 MaybeUnregisterKeyboardMicStream(config); |
314 return; | 314 return; |
315 } | 315 } |
316 | 316 |
317 media::AudioParameters audio_params(config.params); | 317 media::AudioParameters audio_params(config.params); |
318 if (media_stream_manager_->audio_input_device_manager()-> | 318 if (media_stream_manager_->audio_input_device_manager() |
319 ShouldUseFakeDevice()) { | 319 ->ShouldUseFakeDevice()) |
320 audio_params.Reset( | 320 audio_params.set_format(media::AudioParameters::AUDIO_FAKE); |
321 media::AudioParameters::AUDIO_FAKE, | |
322 config.params.channel_layout(), config.params.channels(), | |
323 config.params.sample_rate(), config.params.bits_per_sample(), | |
324 config.params.frames_per_buffer()); | |
325 } | |
326 | 321 |
327 // Check if we have the permission to open the device and which device to use. | 322 // Check if we have the permission to open the device and which device to use. |
328 std::string device_name; | 323 std::string device_name; |
329 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; | 324 std::string device_id = media::AudioManagerBase::kDefaultDeviceId; |
330 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { | 325 if (audio_params.format() != media::AudioParameters::AUDIO_FAKE) { |
331 const StreamDeviceInfo* info = media_stream_manager_-> | 326 const StreamDeviceInfo* info = media_stream_manager_-> |
332 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); | 327 audio_input_device_manager()->GetOpenedDeviceInfoById(session_id); |
333 if (!info) { | 328 if (!info) { |
334 SendErrorMessage(stream_id, PERMISSION_DENIED); | 329 SendErrorMessage(stream_id, PERMISSION_DENIED); |
335 DLOG(WARNING) << "No permission has been granted to input stream with " | 330 DLOG(WARNING) << "No permission has been granted to input stream with " |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 #if defined(OS_CHROMEOS) | 545 #if defined(OS_CHROMEOS) |
551 if (config.params.channel_layout() == | 546 if (config.params.channel_layout() == |
552 media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { | 547 media::CHANNEL_LAYOUT_STEREO_AND_KEYBOARD_MIC) { |
553 media_stream_manager_->audio_input_device_manager() | 548 media_stream_manager_->audio_input_device_manager() |
554 ->UnregisterKeyboardMicStream(); | 549 ->UnregisterKeyboardMicStream(); |
555 } | 550 } |
556 #endif | 551 #endif |
557 } | 552 } |
558 | 553 |
559 } // namespace content | 554 } // namespace content |
OLD | NEW |