| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media_codec_audio_decoder.h" | 5 #include "media/base/android/media_codec_audio_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "media/base/android/media_codec_bridge.h" | 9 #include "media/base/android/media_codec_bridge.h" |
| 10 #include "media/base/audio_timestamp_helper.h" | 10 #include "media/base/audio_timestamp_helper.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 150 |
| 151 DCHECK(media_codec_bridge_); | 151 DCHECK(media_codec_bridge_); |
| 152 | 152 |
| 153 int old_sampling_rate = output_sampling_rate_; | 153 int old_sampling_rate = output_sampling_rate_; |
| 154 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 154 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
| 155 if (output_sampling_rate_ != old_sampling_rate) | 155 if (output_sampling_rate_ != old_sampling_rate) |
| 156 ResetTimestampHelper(); | 156 ResetTimestampHelper(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void MediaCodecAudioDecoder::Render(int buffer_index, | 159 void MediaCodecAudioDecoder::Render(int buffer_index, |
| 160 size_t offset, |
| 160 size_t size, | 161 size_t size, |
| 161 bool render_output, | 162 bool render_output, |
| 162 base::TimeDelta pts, | 163 base::TimeDelta pts, |
| 163 bool eos_encountered) { | 164 bool eos_encountered) { |
| 164 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); | 165 DCHECK(decoder_thread_.task_runner()->BelongsToCurrentThread()); |
| 165 | 166 |
| 166 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; | 167 DVLOG(2) << class_name() << "::" << __FUNCTION__ << " pts:" << pts; |
| 167 | 168 |
| 168 render_output = render_output && (size != 0u); | 169 render_output = render_output && (size != 0u); |
| 169 | 170 |
| 170 if (render_output) { | 171 if (render_output) { |
| 171 int64 head_position = | 172 int64 head_position = |
| 172 (static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) | 173 (static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 173 ->PlayOutputBuffer(buffer_index, size); | 174 ->PlayOutputBuffer(buffer_index, size, offset); |
| 174 | 175 |
| 175 size_t new_frames_count = size / bytes_per_frame_; | 176 size_t new_frames_count = size / bytes_per_frame_; |
| 176 frame_count_ += new_frames_count; | 177 frame_count_ += new_frames_count; |
| 177 audio_timestamp_helper_->AddFrames(new_frames_count); | 178 audio_timestamp_helper_->AddFrames(new_frames_count); |
| 178 int64 frames_to_play = frame_count_ - head_position; | 179 int64 frames_to_play = frame_count_ - head_position; |
| 179 DCHECK_GE(frames_to_play, 0); | 180 DCHECK_GE(frames_to_play, 0); |
| 180 | 181 |
| 181 base::TimeDelta last_buffered = audio_timestamp_helper_->GetTimestamp(); | 182 base::TimeDelta last_buffered = audio_timestamp_helper_->GetTimestamp(); |
| 182 base::TimeDelta now_playing = | 183 base::TimeDelta now_playing = |
| 183 last_buffered - | 184 last_buffered - |
| (...skipping 29 matching lines...) Expand all Loading... |
| 213 if (audio_timestamp_helper_) | 214 if (audio_timestamp_helper_) |
| 214 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); | 215 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); |
| 215 | 216 |
| 216 audio_timestamp_helper_.reset( | 217 audio_timestamp_helper_.reset( |
| 217 new AudioTimestampHelper(configs_.audio_sampling_rate)); | 218 new AudioTimestampHelper(configs_.audio_sampling_rate)); |
| 218 | 219 |
| 219 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); | 220 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); |
| 220 } | 221 } |
| 221 | 222 |
| 222 } // namespace media | 223 } // namespace media |
| OLD | NEW |