Chromium Code Reviews| Index: media/mojo/services/mojo_audio_decoder_service.cc |
| diff --git a/media/mojo/services/mojo_audio_decoder_service.cc b/media/mojo/services/mojo_audio_decoder_service.cc |
| index 91d0b9bf8b479dff3c424076f24f208fd43ff4a1..f2724aab9680e0feb9d4eacd3f4fd5137b043dec 100644 |
| --- a/media/mojo/services/mojo_audio_decoder_service.cc |
| +++ b/media/mojo/services/mojo_audio_decoder_service.cc |
| @@ -14,20 +14,6 @@ |
| namespace media { |
| -static mojom::AudioDecoder::DecodeStatus ConvertDecodeStatus( |
| - media::DecodeStatus status) { |
| - switch (status) { |
| - case media::DecodeStatus::OK: |
| - return mojom::AudioDecoder::DecodeStatus::OK; |
| - case media::DecodeStatus::ABORTED: |
| - return mojom::AudioDecoder::DecodeStatus::ABORTED; |
| - case media::DecodeStatus::DECODE_ERROR: |
| - return mojom::AudioDecoder::DecodeStatus::DECODE_ERROR; |
| - } |
| - NOTREACHED(); |
| - return mojom::AudioDecoder::DecodeStatus::DECODE_ERROR; |
| -} |
| - |
| MojoAudioDecoderService::MojoAudioDecoderService( |
| base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
| std::unique_ptr<media::AudioDecoder> decoder, |
| @@ -95,7 +81,7 @@ void MojoAudioDecoderService::Decode(mojom::DecoderBufferPtr buffer, |
| scoped_refptr<DecoderBuffer> media_buffer = |
| ReadDecoderBuffer(std::move(buffer)); |
| if (!media_buffer) { |
| - callback.Run(ConvertDecodeStatus(media::DecodeStatus::DECODE_ERROR)); |
| + callback.Run(mojom::DecodeStatus::DECODE_ERROR); |
| return; |
| } |
| @@ -127,7 +113,7 @@ void MojoAudioDecoderService::OnInitialized(const InitializeCallback& callback, |
| void MojoAudioDecoderService::OnDecodeStatus(const DecodeCallback& callback, |
| media::DecodeStatus status) { |
| DVLOG(3) << __FUNCTION__ << " status:" << status; |
| - callback.Run(ConvertDecodeStatus(status)); |
| + callback.Run(static_cast<mojom::DecodeStatus>(status)); |
| } |
| void MojoAudioDecoderService::OnResetDone(const ResetCallback& callback) { |
| @@ -152,28 +138,29 @@ scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer( |
| return media_buffer; |
| // Wait for the data to become available in the DataPipe. |
| + MojoResult result; |
| MojoHandleSignalsState state; |
| - CHECK_EQ(MOJO_RESULT_OK, |
| - MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
| - MOJO_DEADLINE_INDEFINITE, &state)); |
| - |
| + result = MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE, |
| + MOJO_DEADLINE_INDEFINITE, &state); |
| + if (result != MOJO_RESULT_OK || |
| + !(state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE)) { |
| + return nullptr; |
| + } |
| if (state.satisfied_signals & MOJO_HANDLE_SIGNAL_PEER_CLOSED) { |
| DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe"; |
| - return scoped_refptr<DecoderBuffer>(); |
| + return nullptr; |
| } |
| - CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, |
| - state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); |
| - |
| // Read the inner data for the DecoderBuffer from our DataPipe. |
| - uint32_t bytes_to_read = |
| - base::checked_cast<uint32_t>(media_buffer->data_size()); |
| - DCHECK_GT(bytes_to_read, 0u); |
| - uint32_t bytes_read = bytes_to_read; |
| - CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), |
| - &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
| - MOJO_RESULT_OK); |
| - CHECK_EQ(bytes_to_read, bytes_read); |
| + uint32_t data_size = buffer->data_size; |
| + if (data_size != media_buffer->data_size()) |
|
Tima Vaisburd
2016/05/18 00:32:16
Drive-by: how can they be different?
sandersd (OOO until July 31)
2016/05/18 00:49:29
They can't (assuming size_t is of higher integer r
sandersd (OOO until July 31)
2016/05/18 00:50:42
*same or higher
dcheng
2016/05/20 21:18:22
I'd suggest DCHECK() or static_assert in the TypeC
sandersd (OOO until July 31)
2016/05/20 22:27:14
Converted to a CHECK() (in MojoVideoDecoderService
|
| + return nullptr; |
| + |
| + uint32_t bytes_read = data_size; |
| + result = ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), |
| + &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE); |
| + if (result != MOJO_RESULT_OK || bytes_read != data_size) |
| + return nullptr; |
| return media_buffer; |
| } |