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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(interfaces::DecodeStatus status) { |
167 interfaces::AudioDecoder::DecodeStatus status) { | |
168 switch (status) { | |
169 case interfaces::AudioDecoder::DecodeStatus::OK: | |
170 return media::DecodeStatus::OK; | |
171 case interfaces::AudioDecoder::DecodeStatus::ABORTED: | |
172 return media::DecodeStatus::ABORTED; | |
173 case interfaces::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 interfaces::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 28 matching lines...) Expand all Loading... |
225 uint32_t num_bytes = base::checked_cast<uint32_t>(media_buffer->data_size()); | 210 uint32_t num_bytes = base::checked_cast<uint32_t>(media_buffer->data_size()); |
226 DCHECK_GT(num_bytes, 0u); | 211 DCHECK_GT(num_bytes, 0u); |
227 CHECK_EQ(WriteDataRaw(producer_handle_.get(), media_buffer->data(), | 212 CHECK_EQ(WriteDataRaw(producer_handle_.get(), media_buffer->data(), |
228 &num_bytes, MOJO_READ_DATA_FLAG_ALL_OR_NONE), | 213 &num_bytes, MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
229 MOJO_RESULT_OK); | 214 MOJO_RESULT_OK); |
230 CHECK_EQ(num_bytes, static_cast<uint32_t>(media_buffer->data_size())); | 215 CHECK_EQ(num_bytes, static_cast<uint32_t>(media_buffer->data_size())); |
231 return buffer; | 216 return buffer; |
232 } | 217 } |
233 | 218 |
234 } // namespace media | 219 } // namespace media |
OLD | NEW |