Chromium Code Reviews| 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 "media/audio/audio_output_resampler.h" | 5 #include "media/audio/audio_output_resampler.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 "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | |
| 11 #include "base/time.h" | 12 #include "base/time.h" |
| 12 #include "media/audio/audio_io.h" | 13 #include "media/audio/audio_io.h" |
| 13 #include "media/audio/audio_output_dispatcher_impl.h" | 14 #include "media/audio/audio_output_dispatcher_impl.h" |
| 14 #include "media/audio/audio_output_proxy.h" | 15 #include "media/audio/audio_output_proxy.h" |
| 15 #include "media/audio/audio_util.h" | 16 #include "media/audio/audio_util.h" |
| 17 #include "media/audio/sample_rates.h" | |
| 16 #include "media/base/audio_pull_fifo.h" | 18 #include "media/base/audio_pull_fifo.h" |
| 17 #include "media/base/multi_channel_resampler.h" | 19 #include "media/base/multi_channel_resampler.h" |
| 18 | 20 |
| 19 namespace media { | 21 namespace media { |
| 20 | 22 |
| 21 AudioOutputResampler::AudioOutputResampler(AudioManager* audio_manager, | 23 AudioOutputResampler::AudioOutputResampler(AudioManager* audio_manager, |
| 22 const AudioParameters& input_params, | 24 const AudioParameters& input_params, |
| 23 const AudioParameters& output_params, | 25 const AudioParameters& output_params, |
| 24 const base::TimeDelta& close_delay) | 26 const base::TimeDelta& close_delay) |
| 25 : AudioOutputDispatcher(audio_manager, input_params), | 27 : AudioOutputDispatcher(audio_manager, input_params), |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 base::Unretained(this)))); | 72 base::Unretained(this)))); |
| 71 } | 73 } |
| 72 | 74 |
| 73 DVLOG(1) << "I/O ratio is " << io_ratio_; | 75 DVLOG(1) << "I/O ratio is " << io_ratio_; |
| 74 } | 76 } |
| 75 | 77 |
| 76 // TODO(dalecurtis): All this code should be merged into AudioOutputMixer once | 78 // TODO(dalecurtis): All this code should be merged into AudioOutputMixer once |
| 77 // we've stabilized the issues there. | 79 // we've stabilized the issues there. |
| 78 dispatcher_ = new AudioOutputDispatcherImpl( | 80 dispatcher_ = new AudioOutputDispatcherImpl( |
| 79 audio_manager, output_params, close_delay); | 81 audio_manager, output_params, close_delay); |
| 82 | |
| 83 // Fake enum histogram to get exact integral buckets. Expect to never see | |
| 84 // any values over 32 and even that is huge. | |
| 85 UMA_HISTOGRAM_ENUMERATION( | |
| 86 "Media.HardwareAudioBitsPerChannel", output_params.bits_per_sample(), | |
| 87 40); | |
|
scherkus (not reviewing)
2012/09/11 16:53:31
not worth enumifying a la sample rate?
DaleCurtis
2012/09/11 17:35:59
Copy/pasted from AudioDecoderConfig. You tell me.
| |
| 88 UMA_HISTOGRAM_ENUMERATION( | |
| 89 "Media.HardwareAudioChannelLayout", output_params.channel_layout(), | |
|
scherkus (not reviewing)
2012/09/11 16:53:31
I thought we only got hardware channel *count* and
DaleCurtis
2012/09/11 17:35:59
This is all a copy paste of what's in AudioDecoder
DaleCurtis
2012/09/12 09:50:57
Done. I'm now pulling the actual hardware channel
| |
| 90 CHANNEL_LAYOUT_MAX); | |
| 91 AudioSampleRate asr = media::AsAudioSampleRate(output_params.sample_rate()); | |
| 92 if (asr != kUnexpectedAudioSampleRate) { | |
| 93 UMA_HISTOGRAM_ENUMERATION( | |
| 94 "Media.HardwareAudioSamplesPerSecond", asr, kUnexpectedAudioSampleRate); | |
| 95 } else { | |
| 96 UMA_HISTOGRAM_COUNTS( | |
| 97 "Media.HardwareAudioSamplesPerSecondUnexpected", | |
| 98 output_params.sample_rate()); | |
| 99 } | |
| 80 } | 100 } |
| 81 | 101 |
| 82 AudioOutputResampler::~AudioOutputResampler() {} | 102 AudioOutputResampler::~AudioOutputResampler() {} |
| 83 | 103 |
| 84 bool AudioOutputResampler::OpenStream() { | 104 bool AudioOutputResampler::OpenStream() { |
| 85 // TODO(dalecurtis): Automatically revert to high latency path if OpenStream() | 105 // TODO(dalecurtis): Automatically revert to high latency path if OpenStream() |
| 86 // fails; use default high latency output values + rebuffering / resampling. | 106 // fails; use default high latency output values + rebuffering / resampling. |
| 87 return dispatcher_->OpenStream(); | 107 return dispatcher_->OpenStream(); |
| 88 } | 108 } |
| 89 | 109 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 source_callback_->OnError(stream, code); | 216 source_callback_->OnError(stream, code); |
| 197 } | 217 } |
| 198 | 218 |
| 199 void AudioOutputResampler::WaitTillDataReady() { | 219 void AudioOutputResampler::WaitTillDataReady() { |
| 200 base::AutoLock auto_lock(source_lock_); | 220 base::AutoLock auto_lock(source_lock_); |
| 201 if (source_callback_ && !outstanding_audio_bytes_) | 221 if (source_callback_ && !outstanding_audio_bytes_) |
| 202 source_callback_->WaitTillDataReady(); | 222 source_callback_->WaitTillDataReady(); |
| 203 } | 223 } |
| 204 | 224 |
| 205 } // namespace media | 225 } // namespace media |
| OLD | NEW |