| 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 "media/base/audio_renderer_mixer.h" | 10 #include "media/base/audio_renderer_mixer.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Create output parameters based on the audio hardware configuration for | 43 // Create output parameters based on the audio hardware configuration for |
| 44 // passing on to the output sink. Force to 16-bit output for now since we | 44 // passing on to the output sink. Force to 16-bit output for now since we |
| 45 // know that works well for WebAudio and WebRTC. | 45 // know that works well for WebAudio and WebRTC. |
| 46 media::AudioParameters output_params( | 46 media::AudioParameters output_params( |
| 47 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), | 47 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), |
| 48 hardware_sample_rate_, 16, hardware_buffer_size_); | 48 hardware_sample_rate_, 16, hardware_buffer_size_); |
| 49 | 49 |
| 50 media::AudioRendererMixer* mixer = new media::AudioRendererMixer( | 50 media::AudioRendererMixer* mixer = new media::AudioRendererMixer( |
| 51 params, output_params, AudioDeviceFactory::Create()); | 51 params, output_params, AudioDeviceFactory::NewOutputDevice()); |
| 52 | 52 |
| 53 AudioRendererMixerReference mixer_reference = { mixer, 1 }; | 53 AudioRendererMixerReference mixer_reference = { mixer, 1 }; |
| 54 mixers_[params] = mixer_reference; | 54 mixers_[params] = mixer_reference; |
| 55 return mixer; | 55 return mixer; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void AudioRendererMixerManager::RemoveMixer( | 58 void AudioRendererMixerManager::RemoveMixer( |
| 59 const media::AudioParameters& params) { | 59 const media::AudioParameters& params) { |
| 60 base::AutoLock auto_lock(mixers_lock_); | 60 base::AutoLock auto_lock(mixers_lock_); |
| 61 | 61 |
| 62 AudioRendererMixerMap::iterator it = mixers_.find(params); | 62 AudioRendererMixerMap::iterator it = mixers_.find(params); |
| 63 DCHECK(it != mixers_.end()); | 63 DCHECK(it != mixers_.end()); |
| 64 | 64 |
| 65 // Only remove the mixer if AudioRendererMixerManager is the last owner. | 65 // Only remove the mixer if AudioRendererMixerManager is the last owner. |
| 66 it->second.ref_count--; | 66 it->second.ref_count--; |
| 67 if (it->second.ref_count == 0) { | 67 if (it->second.ref_count == 0) { |
| 68 delete it->second.mixer; | 68 delete it->second.mixer; |
| 69 mixers_.erase(it); | 69 mixers_.erase(it); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace content | 73 } // namespace content |
| OLD | NEW |