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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Create output parameters based on the audio hardware configuration for | 55 // 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 | 56 // passing on to the output sink. Force to 16-bit output for now since we |
57 // know that works well for WebAudio and WebRTC. | 57 // know that works well for WebAudio and WebRTC. Force a 2048 buffer size |
58 // until we have renderer-side device changes since WebRTC audio mirroring | |
59 // will use the input device's buffer size to drive mirroring so we need | |
60 // the output device's buffer size to be big enough. | |
58 media::AudioParameters output_params( | 61 media::AudioParameters output_params( |
59 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), | 62 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), |
60 hardware_sample_rate_, 16, hardware_buffer_size_); | 63 hardware_sample_rate_, 16, 2048); |
DaleCurtis
2013/01/15 21:00:08
You'll need to test this on mac/win and make sure
justinlin
2013/01/15 22:36:21
OK, will test.
| |
61 | 64 |
62 // If we've created invalid output parameters, simply pass on the input params | 65 // If we've created invalid output parameters, simply pass on the input params |
63 // and let the browser side handle automatic fallback. | 66 // and let the browser side handle automatic fallback. |
64 if (!output_params.IsValid()) | 67 if (!output_params.IsValid()) |
65 output_params = params; | 68 output_params = params; |
66 | 69 |
67 media::AudioRendererMixer* mixer; | 70 media::AudioRendererMixer* mixer; |
68 if (sink_for_testing_) { | 71 if (sink_for_testing_) { |
69 mixer = new media::AudioRendererMixer( | 72 mixer = new media::AudioRendererMixer( |
70 params, output_params, sink_for_testing_); | 73 params, output_params, sink_for_testing_); |
(...skipping 20 matching lines...) Expand all Loading... | |
91 | 94 |
92 // Only remove the mixer if AudioRendererMixerManager is the last owner. | 95 // Only remove the mixer if AudioRendererMixerManager is the last owner. |
93 it->second.ref_count--; | 96 it->second.ref_count--; |
94 if (it->second.ref_count == 0) { | 97 if (it->second.ref_count == 0) { |
95 delete it->second.mixer; | 98 delete it->second.mixer; |
96 mixers_.erase(it); | 99 mixers_.erase(it); |
97 } | 100 } |
98 } | 101 } |
99 | 102 |
100 } // namespace content | 103 } // namespace content |
OLD | NEW |