| 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/audio/audio_output_device.h" | 10 #include "media/audio/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 // On ChromeOS we can rely on the playback device to handle resampling, so | 55 // On ChromeOS and Linux we can rely on the playback device to handle |
| 56 // don't waste cycles on it here. | 56 // resampling, so don't waste cycles on it here. |
| 57 #if defined(OS_CHROMEOS) | 57 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 58 int sample_rate = params.sample_rate(); | 58 int sample_rate = params.sample_rate(); |
| 59 #else | 59 #else |
| 60 int sample_rate = hardware_config_->GetOutputSampleRate(); | 60 int sample_rate = hardware_config_->GetOutputSampleRate(); |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 // Create output parameters based on the audio hardware configuration for | 63 // Create output parameters based on the audio hardware configuration for |
| 64 // passing on to the output sink. Force to 16-bit output for now since we | 64 // passing on to the output sink. Force to 16-bit output for now since we |
| 65 // know that works well for WebAudio and WebRTC. | 65 // know that works well for WebAudio and WebRTC. |
| 66 media::AudioParameters output_params( | 66 media::AudioParameters output_params( |
| 67 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), | 67 media::AudioParameters::AUDIO_PCM_LOW_LATENCY, params.channel_layout(), |
| (...skipping 30 matching lines...) Expand all Loading... |
| 98 | 98 |
| 99 // Only remove the mixer if AudioRendererMixerManager is the last owner. | 99 // Only remove the mixer if AudioRendererMixerManager is the last owner. |
| 100 it->second.ref_count--; | 100 it->second.ref_count--; |
| 101 if (it->second.ref_count == 0) { | 101 if (it->second.ref_count == 0) { |
| 102 delete it->second.mixer; | 102 delete it->second.mixer; |
| 103 mixers_.erase(it); | 103 mixers_.erase(it); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace content | 107 } // namespace content |
| OLD | NEW |