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

Side by Side Diff: media/mojo/services/mojo_audio_decoder.cc

Issue 1899363002: Finish plumbing MojoVideoDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove CHECKs on GPU side. Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/mojo/services/mojo_audio_decoder.h" 5 #include "media/mojo/services/mojo_audio_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 DCHECK(task_runner_->BelongsToCurrentThread()); 156 DCHECK(task_runner_->BelongsToCurrentThread());
157 157
158 needs_bitstream_conversion_ = needs_bitstream_conversion; 158 needs_bitstream_conversion_ = needs_bitstream_conversion;
159 159
160 if (success) 160 if (success)
161 CreateDataPipe(); 161 CreateDataPipe();
162 162
163 base::ResetAndReturn(&init_cb_).Run(success); 163 base::ResetAndReturn(&init_cb_).Run(success);
164 } 164 }
165 165
166 static media::DecodeStatus ConvertDecodeStatus( 166 void MojoAudioDecoder::OnDecodeStatus(mojom::DecodeStatus status) {
167 mojom::AudioDecoder::DecodeStatus status) {
168 switch (status) {
169 case mojom::AudioDecoder::DecodeStatus::OK:
170 return media::DecodeStatus::OK;
171 case mojom::AudioDecoder::DecodeStatus::ABORTED:
172 return media::DecodeStatus::ABORTED;
173 case mojom::AudioDecoder::DecodeStatus::DECODE_ERROR:
174 return media::DecodeStatus::DECODE_ERROR;
175 }
176 NOTREACHED();
177 return media::DecodeStatus::DECODE_ERROR;
178 }
179
180 void MojoAudioDecoder::OnDecodeStatus(
181 mojom::AudioDecoder::DecodeStatus status) {
182 DVLOG(1) << __FUNCTION__ << ": status:" << status; 167 DVLOG(1) << __FUNCTION__ << ": status:" << status;
183 DCHECK(task_runner_->BelongsToCurrentThread()); 168 DCHECK(task_runner_->BelongsToCurrentThread());
184 169
185 DCHECK(!decode_cb_.is_null()); 170 DCHECK(!decode_cb_.is_null());
186 base::ResetAndReturn(&decode_cb_).Run(ConvertDecodeStatus(status)); 171 base::ResetAndReturn(&decode_cb_).Run(static_cast<DecodeStatus>(status));
187 } 172 }
188 173
189 void MojoAudioDecoder::OnResetDone() { 174 void MojoAudioDecoder::OnResetDone() {
190 DVLOG(1) << __FUNCTION__; 175 DVLOG(1) << __FUNCTION__;
191 DCHECK(task_runner_->BelongsToCurrentThread()); 176 DCHECK(task_runner_->BelongsToCurrentThread());
192 177
193 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). 178 // For pending decodes OnDecodeStatus() should arrive before OnResetDone().
194 DCHECK(decode_cb_.is_null()); 179 DCHECK(decode_cb_.is_null());
195 180
196 DCHECK(!reset_cb_.is_null()); 181 DCHECK(!reset_cb_.is_null());
(...skipping 27 matching lines...) Expand all
224 uint32_t num_bytes = base::checked_cast<uint32_t>(media_buffer->data_size()); 209 uint32_t num_bytes = base::checked_cast<uint32_t>(media_buffer->data_size());
225 DCHECK_GT(num_bytes, 0u); 210 DCHECK_GT(num_bytes, 0u);
226 CHECK_EQ(WriteDataRaw(producer_handle_.get(), media_buffer->data(), 211 CHECK_EQ(WriteDataRaw(producer_handle_.get(), media_buffer->data(),
227 &num_bytes, MOJO_READ_DATA_FLAG_ALL_OR_NONE), 212 &num_bytes, MOJO_READ_DATA_FLAG_ALL_OR_NONE),
228 MOJO_RESULT_OK); 213 MOJO_RESULT_OK);
229 CHECK_EQ(num_bytes, static_cast<uint32_t>(media_buffer->data_size())); 214 CHECK_EQ(num_bytes, static_cast<uint32_t>(media_buffer->data_size()));
230 return buffer; 215 return buffer;
231 } 216 }
232 217
233 } // namespace media 218 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698