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

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

Issue 1982883003: Handle unexpected MojoWait() result in MojoAudioDecoderService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only 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
« no previous file with comments | « media/mojo/services/mojo_audio_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_service.h" 5 #include "media/mojo/services/mojo_audio_decoder_service.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/logging.h" 9 #include "base/logging.h"
10 #include "media/base/cdm_context.h" 10 #include "media/base/cdm_context.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer( 146 scoped_refptr<DecoderBuffer> MojoAudioDecoderService::ReadDecoderBuffer(
147 mojom::DecoderBufferPtr buffer) { 147 mojom::DecoderBufferPtr buffer) {
148 scoped_refptr<DecoderBuffer> media_buffer( 148 scoped_refptr<DecoderBuffer> media_buffer(
149 buffer.To<scoped_refptr<DecoderBuffer>>()); 149 buffer.To<scoped_refptr<DecoderBuffer>>());
150 150
151 if (media_buffer->end_of_stream()) 151 if (media_buffer->end_of_stream())
152 return media_buffer; 152 return media_buffer;
153 153
154 // Wait for the data to become available in the DataPipe. 154 // Wait for the data to become available in the DataPipe.
155 MojoHandleSignalsState state; 155 MojoHandleSignalsState state;
156 CHECK_EQ(MOJO_RESULT_OK, 156 MojoResult result =
157 MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE, 157 MojoWait(consumer_handle_.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
158 MOJO_DEADLINE_INDEFINITE, &state)); 158 MOJO_DEADLINE_INDEFINITE, &state);
159 159
160 if (state.satisfied_signals & MOJO_HANDLE_SIGNAL_PEER_CLOSED) { 160 if (result != MOJO_RESULT_OK) {
161 DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe"; 161 DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe";
162 return scoped_refptr<DecoderBuffer>(); 162 return nullptr;
163 } 163 }
164 164
165 CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, 165 // Read the inner data for the DecoderBuffer from our DataPipe.
166 state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); 166 uint32_t data_size = static_cast<uint32_t>(media_buffer->data_size());
167 DCHECK_EQ(data_size, buffer->data_size);
168 DCHECK_GT(data_size, 0u);
167 169
168 // Read the inner data for the DecoderBuffer from our DataPipe. 170 uint32_t bytes_read = data_size;
169 uint32_t bytes_to_read = 171 result = ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(),
170 base::checked_cast<uint32_t>(media_buffer->data_size()); 172 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE);
171 DCHECK_GT(bytes_to_read, 0u); 173 if (result != MOJO_RESULT_OK || bytes_read != data_size) {
172 uint32_t bytes_read = bytes_to_read; 174 DVLOG(1) << __FUNCTION__ << ": reading from pipe failed";
173 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), 175 return nullptr;
174 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), 176 }
175 MOJO_RESULT_OK);
176 CHECK_EQ(bytes_to_read, bytes_read);
177 177
178 return media_buffer; 178 return media_buffer;
179 } 179 }
180 180
181 } // namespace media 181 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_audio_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698