OLD | NEW |
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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(task_runner_->BelongsToCurrentThread()); | 163 DCHECK(task_runner_->BelongsToCurrentThread()); |
164 | 164 |
165 needs_bitstream_conversion_ = needs_bitstream_conversion; | 165 needs_bitstream_conversion_ = needs_bitstream_conversion; |
166 | 166 |
167 if (success) | 167 if (success) |
168 CreateDataPipe(); | 168 CreateDataPipe(); |
169 | 169 |
170 base::ResetAndReturn(&init_cb_).Run(success); | 170 base::ResetAndReturn(&init_cb_).Run(success); |
171 } | 171 } |
172 | 172 |
173 static media::DecodeStatus ConvertDecodeStatus( | 173 void MojoAudioDecoder::OnDecodeStatus(mojom::DecodeStatus status) { |
174 mojom::AudioDecoder::DecodeStatus status) { | |
175 switch (status) { | |
176 case mojom::AudioDecoder::DecodeStatus::OK: | |
177 return media::DecodeStatus::OK; | |
178 case mojom::AudioDecoder::DecodeStatus::ABORTED: | |
179 return media::DecodeStatus::ABORTED; | |
180 case mojom::AudioDecoder::DecodeStatus::DECODE_ERROR: | |
181 return media::DecodeStatus::DECODE_ERROR; | |
182 } | |
183 NOTREACHED(); | |
184 return media::DecodeStatus::DECODE_ERROR; | |
185 } | |
186 | |
187 void MojoAudioDecoder::OnDecodeStatus( | |
188 mojom::AudioDecoder::DecodeStatus status) { | |
189 DVLOG(1) << __FUNCTION__ << ": status:" << status; | 174 DVLOG(1) << __FUNCTION__ << ": status:" << status; |
190 DCHECK(task_runner_->BelongsToCurrentThread()); | 175 DCHECK(task_runner_->BelongsToCurrentThread()); |
191 | 176 |
192 DCHECK(!decode_cb_.is_null()); | 177 DCHECK(!decode_cb_.is_null()); |
193 base::ResetAndReturn(&decode_cb_).Run(ConvertDecodeStatus(status)); | 178 base::ResetAndReturn(&decode_cb_).Run(static_cast<DecodeStatus>(status)); |
194 } | 179 } |
195 | 180 |
196 void MojoAudioDecoder::OnResetDone() { | 181 void MojoAudioDecoder::OnResetDone() { |
197 DVLOG(1) << __FUNCTION__; | 182 DVLOG(1) << __FUNCTION__; |
198 DCHECK(task_runner_->BelongsToCurrentThread()); | 183 DCHECK(task_runner_->BelongsToCurrentThread()); |
199 | 184 |
200 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). | 185 // For pending decodes OnDecodeStatus() should arrive before OnResetDone(). |
201 DCHECK(decode_cb_.is_null()); | 186 DCHECK(decode_cb_.is_null()); |
202 | 187 |
203 DCHECK(!reset_cb_.is_null()); | 188 DCHECK(!reset_cb_.is_null()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); | 220 MOJO_WRITE_DATA_FLAG_ALL_OR_NONE); |
236 if (result != MOJO_RESULT_OK || num_bytes != media_buffer->data_size()) { | 221 if (result != MOJO_RESULT_OK || num_bytes != media_buffer->data_size()) { |
237 DVLOG(1) << __FUNCTION__ << ": writing to data pipe failed"; | 222 DVLOG(1) << __FUNCTION__ << ": writing to data pipe failed"; |
238 return nullptr; | 223 return nullptr; |
239 } | 224 } |
240 | 225 |
241 return buffer; | 226 return buffer; |
242 } | 227 } |
243 | 228 |
244 } // namespace media | 229 } // namespace media |
OLD | NEW |