Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/base/android/audio_decoder_job.h" | 5 #include "media/base/android/audio_decoder_job.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
| 10 #include "media/base/android/sdk_media_codec_bridge.h" | 10 #include "media/base/android/sdk_media_codec_bridge.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 int output_buffer_index, | 98 int output_buffer_index, |
| 99 size_t offset, | 99 size_t offset, |
| 100 size_t size, | 100 size_t size, |
| 101 bool render_output, | 101 bool render_output, |
| 102 bool /* is_late_frame */, | 102 bool /* is_late_frame */, |
| 103 base::TimeDelta current_presentation_timestamp, | 103 base::TimeDelta current_presentation_timestamp, |
| 104 const ReleaseOutputCompletionCallback& callback) { | 104 const ReleaseOutputCompletionCallback& callback) { |
| 105 render_output = render_output && (size != 0u); | 105 render_output = render_output && (size != 0u); |
| 106 bool is_audio_underrun = false; | 106 bool is_audio_underrun = false; |
| 107 if (render_output) { | 107 if (render_output) { |
| 108 int64_t head_position = | 108 bool postpone = false; |
| 109 int64_t head_position; | |
| 110 MediaCodecStatus status = | |
| 109 (static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) | 111 (static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 110 ->PlayOutputBuffer(output_buffer_index, size, offset); | 112 ->PlayOutputBuffer(output_buffer_index, size, offset, postpone, |
| 113 &head_position); | |
| 114 // TODO(timav,watk): This CHECK maintains the behavior of this call before | |
| 115 // we started catching CodecException and returning it as MEDIA_CODEC_ERROR. | |
| 116 // It needs to be handled some other way. http://crbug.com/585978 | |
| 117 CHECK_EQ(status, MEDIA_CODEC_OK); | |
| 111 | 118 |
| 112 base::TimeTicks current_time = base::TimeTicks::Now(); | 119 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 113 | 120 |
| 114 size_t new_frames_count = size / bytes_per_frame_; | 121 size_t new_frames_count = size / bytes_per_frame_; |
| 115 frame_count_ += new_frames_count; | 122 frame_count_ += new_frames_count; |
| 116 audio_timestamp_helper_->AddFrames(new_frames_count); | 123 audio_timestamp_helper_->AddFrames(new_frames_count); |
| 117 int64_t frames_to_play = frame_count_ - head_position; | 124 int64_t frames_to_play = frame_count_ - head_position; |
| 118 DCHECK_GE(frames_to_play, 0); | 125 DCHECK_GE(frames_to_play, 0); |
| 119 | 126 |
| 120 const base::TimeDelta last_buffered = | 127 const base::TimeDelta last_buffered = |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 if (media_codec_bridge_) { | 191 if (media_codec_bridge_) { |
| 185 static_cast<AudioCodecBridge*>(media_codec_bridge_.get())->SetVolume( | 192 static_cast<AudioCodecBridge*>(media_codec_bridge_.get())->SetVolume( |
| 186 volume_); | 193 volume_); |
| 187 } | 194 } |
| 188 } | 195 } |
| 189 | 196 |
| 190 void AudioDecoderJob::OnOutputFormatChanged() { | 197 void AudioDecoderJob::OnOutputFormatChanged() { |
| 191 DCHECK(media_codec_bridge_); | 198 DCHECK(media_codec_bridge_); |
| 192 | 199 |
| 193 int old_sampling_rate = output_sampling_rate_; | 200 int old_sampling_rate = output_sampling_rate_; |
| 194 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 201 MediaCodecStatus status = |
| 195 if (output_sampling_rate_ != old_sampling_rate) | 202 media_codec_bridge_->GetOutputSamplingRate(&output_sampling_rate_); |
| 203 if (status != MEDIA_CODEC_OK || output_sampling_rate_ != old_sampling_rate) | |
|
qinmin
2016/03/03 23:15:23
if the return status is not MEDIA_CODEC_OK, i thin
watk
2016/03/04 01:33:32
Makes sense. I'm not quite sure how to do that jus
| |
| 196 ResetTimestampHelper(); | 204 ResetTimestampHelper(); |
| 197 } | 205 } |
| 198 | 206 |
| 199 } // namespace media | 207 } // namespace media |
| OLD | NEW |