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_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 Loading... | |
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 wait_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 (wait_result != MOJO_RESULT_OK || |
161 state.satisfied_signals & MOJO_HANDLE_SIGNAL_PEER_CLOSED) { | |
Ken Rockot(use gerrit already)
2016/05/17 23:54:53
It's possible for PEER_CLOSED to be set while READ
Tima Vaisburd
2016/05/18 01:17:16
Done.
| |
161 DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe"; | 162 DVLOG(1) << __FUNCTION__ << ": Peer closed the data pipe"; |
162 return scoped_refptr<DecoderBuffer>(); | 163 return scoped_refptr<DecoderBuffer>(); |
163 } | 164 } |
164 | 165 |
165 CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, | 166 CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, |
Ken Rockot(use gerrit already)
2016/05/17 23:54:53
Please reserve CHECK usage for exceptional conditi
Tima Vaisburd
2016/05/18 01:17:16
Removed this check.
| |
166 state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); | 167 state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE); |
167 | 168 |
168 // Read the inner data for the DecoderBuffer from our DataPipe. | 169 // Read the inner data for the DecoderBuffer from our DataPipe. |
169 uint32_t bytes_to_read = | 170 uint32_t bytes_to_read = |
170 base::checked_cast<uint32_t>(media_buffer->data_size()); | 171 base::checked_cast<uint32_t>(media_buffer->data_size()); |
171 DCHECK_GT(bytes_to_read, 0u); | 172 DCHECK_GT(bytes_to_read, 0u); |
172 uint32_t bytes_read = bytes_to_read; | 173 uint32_t bytes_read = bytes_to_read; |
173 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), | 174 CHECK_EQ(ReadDataRaw(consumer_handle_.get(), media_buffer->writable_data(), |
174 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), | 175 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), |
175 MOJO_RESULT_OK); | 176 MOJO_RESULT_OK); |
176 CHECK_EQ(bytes_to_read, bytes_read); | 177 CHECK_EQ(bytes_to_read, bytes_read); |
Ken Rockot(use gerrit already)
2016/05/17 23:54:53
What guarantee do you have that the sender sent th
Tima Vaisburd
2016/05/18 01:17:16
The sender calls WriteDataRaw() with ALL_OR_NONE.
Ken Rockot(use gerrit already)
2016/05/18 03:10:47
If the sender is not always running in a trusted p
| |
177 | 178 |
178 return media_buffer; | 179 return media_buffer; |
179 } | 180 } |
180 | 181 |
181 } // namespace media | 182 } // namespace media |
OLD | NEW |