| 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 head_position = (static_cast<AudioCodecBridge*>( | 108 int64_t head_position = |
| 109 media_codec_bridge_.get()))->PlayOutputBuffer( | 109 (static_cast<AudioCodecBridge*>(media_codec_bridge_.get())) |
| 110 output_buffer_index, size, offset); | 110 ->PlayOutputBuffer(output_buffer_index, size, offset); |
| 111 | 111 |
| 112 base::TimeTicks current_time = base::TimeTicks::Now(); | 112 base::TimeTicks current_time = base::TimeTicks::Now(); |
| 113 | 113 |
| 114 size_t new_frames_count = size / bytes_per_frame_; | 114 size_t new_frames_count = size / bytes_per_frame_; |
| 115 frame_count_ += new_frames_count; | 115 frame_count_ += new_frames_count; |
| 116 audio_timestamp_helper_->AddFrames(new_frames_count); | 116 audio_timestamp_helper_->AddFrames(new_frames_count); |
| 117 int64 frames_to_play = frame_count_ - head_position; | 117 int64_t frames_to_play = frame_count_ - head_position; |
| 118 DCHECK_GE(frames_to_play, 0); | 118 DCHECK_GE(frames_to_play, 0); |
| 119 | 119 |
| 120 const base::TimeDelta last_buffered = | 120 const base::TimeDelta last_buffered = |
| 121 audio_timestamp_helper_->GetTimestamp(); | 121 audio_timestamp_helper_->GetTimestamp(); |
| 122 | 122 |
| 123 current_presentation_timestamp = | 123 current_presentation_timestamp = |
| 124 last_buffered - | 124 last_buffered - |
| 125 audio_timestamp_helper_->GetFrameDuration(frames_to_play); | 125 audio_timestamp_helper_->GetFrameDuration(frames_to_play); |
| 126 | 126 |
| 127 // Potential audio underrun is considered a late frame for UMA. | 127 // Potential audio underrun is considered a late frame for UMA. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void AudioDecoderJob::OnOutputFormatChanged() { | 190 void AudioDecoderJob::OnOutputFormatChanged() { |
| 191 DCHECK(media_codec_bridge_); | 191 DCHECK(media_codec_bridge_); |
| 192 | 192 |
| 193 int old_sampling_rate = output_sampling_rate_; | 193 int old_sampling_rate = output_sampling_rate_; |
| 194 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); | 194 output_sampling_rate_ = media_codec_bridge_->GetOutputSamplingRate(); |
| 195 if (output_sampling_rate_ != old_sampling_rate) | 195 if (output_sampling_rate_ != old_sampling_rate) |
| 196 ResetTimestampHelper(); | 196 ResetTimestampHelper(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 } // namespace media | 199 } // namespace media |
| OLD | NEW |