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/filters/audio_renderer_impl.h" | 5 #include "media/filters/audio_renderer_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/callback_helpers.h" | 13 #include "base/callback_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/message_loop_proxy.h" | 16 #include "base/message_loop_proxy.h" |
17 #include "base/metrics/histogram.h" | |
17 #include "media/audio/audio_util.h" | 18 #include "media/audio/audio_util.h" |
18 #include "media/base/audio_splicer.h" | 19 #include "media/base/audio_splicer.h" |
19 #include "media/base/bind_to_loop.h" | 20 #include "media/base/bind_to_loop.h" |
20 #include "media/base/data_buffer.h" | 21 #include "media/base/data_buffer.h" |
21 #include "media/base/demuxer_stream.h" | 22 #include "media/base/demuxer_stream.h" |
22 #include "media/base/media_switches.h" | 23 #include "media/base/media_switches.h" |
23 #include "media/filters/audio_decoder_selector.h" | 24 #include "media/filters/audio_decoder_selector.h" |
24 #include "media/filters/decrypting_demuxer_stream.h" | 25 #include "media/filters/decrypting_demuxer_stream.h" |
25 | 26 |
26 namespace media { | 27 namespace media { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 int bytes_per_frame = channels * decoder_->bits_per_channel() / 8; | 278 int bytes_per_frame = channels * decoder_->bits_per_channel() / 8; |
278 splicer_.reset(new AudioSplicer(bytes_per_frame, sample_rate)); | 279 splicer_.reset(new AudioSplicer(bytes_per_frame, sample_rate)); |
279 | 280 |
280 // We're all good! Continue initializing the rest of the audio renderer based | 281 // We're all good! Continue initializing the rest of the audio renderer based |
281 // on the decoder format. | 282 // on the decoder format. |
282 algorithm_.reset(new AudioRendererAlgorithm()); | 283 algorithm_.reset(new AudioRendererAlgorithm()); |
283 algorithm_->Initialize(0, audio_parameters_); | 284 algorithm_->Initialize(0, audio_parameters_); |
284 | 285 |
285 state_ = kPaused; | 286 state_ = kPaused; |
286 | 287 |
288 HISTOGRAM_BOOLEAN("Media.AudioRendererSinkErrors", false); | |
DaleCurtis
2013/04/24 20:56:39
I believe you want UMA_*, otherwise this won't get
jar (doing other things)
2013/04/24 21:51:07
+1 for needing the prefix UMA_HISTOGRAM_BOOLEAN
T
scherkus (not reviewing)
2013/04/25 00:04:46
Done.
| |
289 | |
287 sink_->Initialize(audio_parameters_, weak_this_); | 290 sink_->Initialize(audio_parameters_, weak_this_); |
288 sink_->Start(); | 291 sink_->Start(); |
289 | 292 |
290 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 293 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
291 } | 294 } |
292 | 295 |
293 void AudioRendererImpl::ResumeAfterUnderflow(bool buffer_more_audio) { | 296 void AudioRendererImpl::ResumeAfterUnderflow(bool buffer_more_audio) { |
294 DCHECK(message_loop_->BelongsToCurrentThread()); | 297 DCHECK(message_loop_->BelongsToCurrentThread()); |
295 base::AutoLock auto_lock(lock_); | 298 base::AutoLock auto_lock(lock_); |
296 if (state_ == kUnderflow) { | 299 if (state_ == kUnderflow) { |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 base::TimeDelta predicted_play_time = base::TimeDelta::FromMicroseconds( | 625 base::TimeDelta predicted_play_time = base::TimeDelta::FromMicroseconds( |
623 static_cast<float>(frames_filled) * base::Time::kMicrosecondsPerSecond / | 626 static_cast<float>(frames_filled) * base::Time::kMicrosecondsPerSecond / |
624 audio_parameters_.sample_rate()); | 627 audio_parameters_.sample_rate()); |
625 | 628 |
626 lock_.AssertAcquired(); | 629 lock_.AssertAcquired(); |
627 earliest_end_time_ = std::max( | 630 earliest_end_time_ = std::max( |
628 earliest_end_time_, time_now + playback_delay + predicted_play_time); | 631 earliest_end_time_, time_now + playback_delay + predicted_play_time); |
629 } | 632 } |
630 | 633 |
631 void AudioRendererImpl::OnRenderError() { | 634 void AudioRendererImpl::OnRenderError() { |
635 HISTOGRAM_BOOLEAN("Media.AudioRendererSinkErrors", true); | |
scherkus (not reviewing)
2013/04/24 20:27:41
we can also record audio_parameters_ when hitting
jar (doing other things)
2013/04/24 21:51:07
Some of this stuff *might* be pulled from dremel l
| |
632 disabled_cb_.Run(); | 636 disabled_cb_.Run(); |
633 } | 637 } |
634 | 638 |
635 void AudioRendererImpl::DisableUnderflowForTesting() { | 639 void AudioRendererImpl::DisableUnderflowForTesting() { |
636 underflow_disabled_ = true; | 640 underflow_disabled_ = true; |
637 } | 641 } |
638 | 642 |
639 void AudioRendererImpl::HandleAbortedReadOrDecodeError(bool is_decode_error) { | 643 void AudioRendererImpl::HandleAbortedReadOrDecodeError(bool is_decode_error) { |
640 PipelineStatus status = is_decode_error ? PIPELINE_ERROR_DECODE : PIPELINE_OK; | 644 PipelineStatus status = is_decode_error ? PIPELINE_ERROR_DECODE : PIPELINE_OK; |
641 switch (state_) { | 645 switch (state_) { |
(...skipping 15 matching lines...) Expand all Loading... | |
657 case kUnderflow: | 661 case kUnderflow: |
658 case kRebuffering: | 662 case kRebuffering: |
659 case kStopped: | 663 case kStopped: |
660 if (status != PIPELINE_OK) | 664 if (status != PIPELINE_OK) |
661 error_cb_.Run(status); | 665 error_cb_.Run(status); |
662 return; | 666 return; |
663 } | 667 } |
664 } | 668 } |
665 | 669 |
666 } // namespace media | 670 } // namespace media |
OLD | NEW |