Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: media/base/android/audio_decoder_job.cc

Issue 1764813002: Catch CodecException in MediaCodecBridge and return MEDIA_CODEC_ERROR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dale's comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 =
202 media_codec_bridge_->GetOutputSamplingRate(&output_sampling_rate_);
203 // TODO(timav,watk): This CHECK maintains the behavior of this call before
204 // we started catching CodecException and returning it as MEDIA_CODEC_ERROR.
205 // It needs to be handled some other way. http://crbug.com/585978
206 CHECK_EQ(status, MEDIA_CODEC_OK);
195 if (output_sampling_rate_ != old_sampling_rate) 207 if (output_sampling_rate_ != old_sampling_rate)
196 ResetTimestampHelper(); 208 ResetTimestampHelper();
197 } 209 }
198 210
199 } // namespace media 211 } // namespace media
OLDNEW
« no previous file with comments | « content/common/gpu/media/android_video_encode_accelerator.cc ('k') | media/base/android/audio_media_codec_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698