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/media_codec_bridge.h" | 10 #include "media/base/android/media_codec_bridge.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void AudioDecoderJob::ResetTimestampHelper() { | 89 void AudioDecoderJob::ResetTimestampHelper() { |
90 if (audio_timestamp_helper_) | 90 if (audio_timestamp_helper_) |
91 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); | 91 base_timestamp_ = audio_timestamp_helper_->GetTimestamp(); |
92 audio_timestamp_helper_.reset( | 92 audio_timestamp_helper_.reset( |
93 new AudioTimestampHelper(output_sampling_rate_)); | 93 new AudioTimestampHelper(output_sampling_rate_)); |
94 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); | 94 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp_); |
95 } | 95 } |
96 | 96 |
97 void AudioDecoderJob::ReleaseOutputBuffer( | 97 void AudioDecoderJob::ReleaseOutputBuffer( |
98 int output_buffer_index, | 98 int output_buffer_index, |
| 99 size_t offset, |
99 size_t size, | 100 size_t size, |
100 bool render_output, | 101 bool render_output, |
101 base::TimeDelta current_presentation_timestamp, | 102 base::TimeDelta current_presentation_timestamp, |
102 const ReleaseOutputCompletionCallback& callback) { | 103 const ReleaseOutputCompletionCallback& callback) { |
103 render_output = render_output && (size != 0u); | 104 render_output = render_output && (size != 0u); |
104 if (render_output) { | 105 if (render_output) { |
105 int64 head_position = (static_cast<AudioCodecBridge*>( | 106 int64 head_position = (static_cast<AudioCodecBridge*>( |
106 media_codec_bridge_.get()))->PlayOutputBuffer( | 107 media_codec_bridge_.get()))->PlayOutputBuffer( |
107 output_buffer_index, size); | 108 output_buffer_index, size, offset); |
108 size_t new_frames_count = size / bytes_per_frame_; | 109 size_t new_frames_count = size / bytes_per_frame_; |
109 frame_count_ += new_frames_count; | 110 frame_count_ += new_frames_count; |
110 audio_timestamp_helper_->AddFrames(new_frames_count); | 111 audio_timestamp_helper_->AddFrames(new_frames_count); |
111 int64 frames_to_play = frame_count_ - head_position; | 112 int64 frames_to_play = frame_count_ - head_position; |
112 DCHECK_GE(frames_to_play, 0); | 113 DCHECK_GE(frames_to_play, 0); |
113 current_presentation_timestamp = | 114 current_presentation_timestamp = |
114 audio_timestamp_helper_->GetTimestamp() - | 115 audio_timestamp_helper_->GetTimestamp() - |
115 audio_timestamp_helper_->GetFrameDuration(frames_to_play); | 116 audio_timestamp_helper_->GetFrameDuration(frames_to_play); |
116 } else { | 117 } else { |
117 current_presentation_timestamp = kNoTimestamp(); | 118 current_presentation_timestamp = kNoTimestamp(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 void AudioDecoderJob::OnOutputFormatChanged() { | 172 void AudioDecoderJob::OnOutputFormatChanged() { |
172 DCHECK(media_codec_bridge_); | 173 DCHECK(media_codec_bridge_); |
173 | 174 |
174 int old_sampling_rate = output_sampling_rate_; | 175 int old_sampling_rate = output_sampling_rate_; |
175 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 176 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
176 if (output_sampling_rate_ != old_sampling_rate) | 177 if (output_sampling_rate_ != old_sampling_rate) |
177 ResetTimestampHelper(); | 178 ResetTimestampHelper(); |
178 } | 179 } |
179 | 180 |
180 } // namespace media | 181 } // namespace media |
OLD | NEW |