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/renderer/media/audio_renderer_mixer_manager.h" | 5 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "content/renderer/media/audio_device_factory.h" | 9 #include "content/renderer/media/audio_device_factory.h" |
10 #include "content/renderer/media/renderer_audio_output_device.h" | 10 #include "content/renderer/media/renderer_audio_output_device.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 const media::AudioParameters& params) { | 45 const media::AudioParameters& params) { |
46 const MixerKey key(source_render_view_id, params); | 46 const MixerKey key(source_render_view_id, params); |
47 base::AutoLock auto_lock(mixers_lock_); | 47 base::AutoLock auto_lock(mixers_lock_); |
48 | 48 |
49 AudioRendererMixerMap::iterator it = mixers_.find(key); | 49 AudioRendererMixerMap::iterator it = mixers_.find(key); |
50 if (it != mixers_.end()) { | 50 if (it != mixers_.end()) { |
51 it->second.ref_count++; | 51 it->second.ref_count++; |
52 return it->second.mixer; | 52 return it->second.mixer; |
53 } | 53 } |
54 | 54 |
55 int buffer_size = hardware_buffer_size_; | |
56 | |
57 // TODO(justinlin): Enable this on other platforms when renderer side mixing | |
58 // is enabled for them if we don't have renderer side device changes yet. | |
59 #if defined(OS_WIN) || defined(OS_MACOSX) | |
60 // Force at least a 2048 buffer size until we have renderer-side device | |
61 // changes. Audio mirroring will use the input device's buffer size to | |
62 // drive mirroring, so we need the output device's buffer size to be big | |
63 // enough to avoid garbled audio. | |
64 buffer_size = std::max(hardware_buffer_size_, 2048); | |
miu
2013/01/16 22:56:57
Why not make this a function of hardware_sample_ra
| |
65 #endif | |
66 | |
55 // Create output parameters based on the audio hardware configuration for | 67 // Create output parameters based on the audio hardware configuration for |
56 // passing on to the output sink. Force to 16-bit output for now since we | 68 // passing on to the output sink. Force to 16-bit output for now since we |
57 // know that works well for WebAudio and WebRTC. | 69 // know that works well for WebAudio and WebRTC. |
58 media::AudioParameters output_params( | 70 media::AudioParameters output_params( |
59 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), | 71 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), |
60 hardware_sample_rate_, 16, hardware_buffer_size_); | 72 hardware_sample_rate_, 16, buffer_size); |
61 | 73 |
62 // If we've created invalid output parameters, simply pass on the input params | 74 // If we've created invalid output parameters, simply pass on the input params |
63 // and let the browser side handle automatic fallback. | 75 // and let the browser side handle automatic fallback. |
64 if (!output_params.IsValid()) | 76 if (!output_params.IsValid()) |
65 output_params = params; | 77 output_params = params; |
66 | 78 |
67 media::AudioRendererMixer* mixer; | 79 media::AudioRendererMixer* mixer; |
68 if (sink_for_testing_) { | 80 if (sink_for_testing_) { |
69 mixer = new media::AudioRendererMixer( | 81 mixer = new media::AudioRendererMixer( |
70 params, output_params, sink_for_testing_); | 82 params, output_params, sink_for_testing_); |
(...skipping 20 matching lines...) Expand all Loading... | |
91 | 103 |
92 // Only remove the mixer if AudioRendererMixerManager is the last owner. | 104 // Only remove the mixer if AudioRendererMixerManager is the last owner. |
93 it->second.ref_count--; | 105 it->second.ref_count--; |
94 if (it->second.ref_count == 0) { | 106 if (it->second.ref_count == 0) { |
95 delete it->second.mixer; | 107 delete it->second.mixer; |
96 mixers_.erase(it); | 108 mixers_.erase(it); |
97 } | 109 } |
98 } | 110 } |
99 | 111 |
100 } // namespace content | 112 } // namespace content |
OLD | NEW |