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

Unified Diff: media/mojo/services/mojo_demuxer_stream_adapter.cc

Issue 2088633002: Handles MOJO_HANDLE_SIGNAL_PEER_CLOSED in MojoDemuxerStreamAdapter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: copied code from audio decoder Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/mojo/services/mojo_demuxer_stream_adapter.cc
diff --git a/media/mojo/services/mojo_demuxer_stream_adapter.cc b/media/mojo/services/mojo_demuxer_stream_adapter.cc
index 9d540c60a3e5590c0fcd4afd75edf04f024e45dd..bd71d3013ec0e9d8777ee4464ba424deb23fd0e0 100644
--- a/media/mojo/services/mojo_demuxer_stream_adapter.cc
+++ b/media/mojo/services/mojo_demuxer_stream_adapter.cc
@@ -112,24 +112,34 @@ void MojoDemuxerStreamAdapter::OnBufferReady(
scoped_refptr<DecoderBuffer> media_buffer(
buffer.To<scoped_refptr<DecoderBuffer>>());
- if (!media_buffer->end_of_stream()) {
- DCHECK_GT(media_buffer->data_size(), 0u);
-
- // Wait for the data to become available in the DataPipe.
- MojoHandleSignalsState state;
- CHECK_EQ(MOJO_RESULT_OK,
- MojoWait(stream_pipe_.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
- MOJO_DEADLINE_INDEFINITE, &state));
- CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, state.satisfied_signals);
-
- // Read the inner data for the DecoderBuffer from our DataPipe.
- uint32_t bytes_to_read =
- base::checked_cast<uint32_t>(media_buffer->data_size());
- uint32_t bytes_read = bytes_to_read;
- CHECK_EQ(ReadDataRaw(stream_pipe_.get(), media_buffer->writable_data(),
- &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE),
- MOJO_RESULT_OK);
- CHECK_EQ(bytes_to_read, bytes_read);
+ if (media_buffer->end_of_stream()) {
+ base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, media_buffer);
+ return;
+ }
+
+ DCHECK_GT(media_buffer->data_size(), 0u);
+
+ // Wait for the data to become available in the DataPipe.
+ MojoHandleSignalsState state;
+ MojoResult result =
+ MojoWait(stream_pipe_.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
+ MOJO_DEADLINE_INDEFINITE, &state);
+ if (result != MOJO_RESULT_OK) {
+ DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe";
+ base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr);
+ return;
+ }
+
+ // Read the inner data for the DecoderBuffer from our DataPipe.
+ uint32_t bytes_to_read =
+ base::checked_cast<uint32_t>(media_buffer->data_size());
+ uint32_t bytes_read = bytes_to_read;
+ result = ReadDataRaw(stream_pipe_.get(), media_buffer->writable_data(),
+ &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE);
+ if (result != MOJO_RESULT_OK || bytes_read != bytes_to_read) {
+ DVLOG(1) << __FUNCTION__ << ": reading from pipe failed";
+ base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr);
+ return;
}
base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, media_buffer);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698