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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_demuxer_stream_adapter.h" 5 #include "media/mojo/services/mojo_demuxer_stream_adapter.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 if (status == mojom::DemuxerStream::Status::ABORTED) { 106 if (status == mojom::DemuxerStream::Status::ABORTED) {
107 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr); 107 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr);
108 return; 108 return;
109 } 109 }
110 110
111 DCHECK_EQ(status, mojom::DemuxerStream::Status::OK); 111 DCHECK_EQ(status, mojom::DemuxerStream::Status::OK);
112 scoped_refptr<DecoderBuffer> media_buffer( 112 scoped_refptr<DecoderBuffer> media_buffer(
113 buffer.To<scoped_refptr<DecoderBuffer>>()); 113 buffer.To<scoped_refptr<DecoderBuffer>>());
114 114
115 if (!media_buffer->end_of_stream()) { 115 if (media_buffer->end_of_stream()) {
116 DCHECK_GT(media_buffer->data_size(), 0u); 116 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, media_buffer);
117 return;
118 }
117 119
118 // Wait for the data to become available in the DataPipe. 120 DCHECK_GT(media_buffer->data_size(), 0u);
119 MojoHandleSignalsState state;
120 CHECK_EQ(MOJO_RESULT_OK,
121 MojoWait(stream_pipe_.get().value(), MOJO_HANDLE_SIGNAL_READABLE,
122 MOJO_DEADLINE_INDEFINITE, &state));
123 CHECK_EQ(MOJO_HANDLE_SIGNAL_READABLE, state.satisfied_signals);
alokp 2016/06/20 23:52:14 I started hitting this CHECK after https://coderev
124 121
122 // Wait for the data to become available in the DataPipe.
xhwang 2016/06/21 05:15:21 timav@ has fixed this on MojoAudioDecoder recently
alokp 2016/06/21 17:09:32 OK. I copied the implementation from MojoAudioDeco
123 MojoHandleSignalsState state;
124 CHECK_EQ(MOJO_RESULT_OK, MojoWait(stream_pipe_.get().value(),
Ken Rockot(use gerrit already) 2016/06/21 00:15:50 I don't think a CHECK was ever appropriate here re
alokp 2016/06/21 17:09:32 Thanks Ken. The code in MojoAudioDecoder does exac
125 MOJO_HANDLE_SIGNAL_READABLE |
126 MOJO_HANDLE_SIGNAL_PEER_CLOSED,
127 MOJO_DEADLINE_INDEFINITE, &state));
128
129 if (state.satisfied_signals & MOJO_HANDLE_SIGNAL_READABLE) {
125 // Read the inner data for the DecoderBuffer from our DataPipe. 130 // Read the inner data for the DecoderBuffer from our DataPipe.
126 uint32_t bytes_to_read = 131 uint32_t bytes_to_read =
127 base::checked_cast<uint32_t>(media_buffer->data_size()); 132 base::checked_cast<uint32_t>(media_buffer->data_size());
128 uint32_t bytes_read = bytes_to_read; 133 uint32_t bytes_read = bytes_to_read;
129 CHECK_EQ(ReadDataRaw(stream_pipe_.get(), media_buffer->writable_data(), 134 CHECK_EQ(MOJO_RESULT_OK,
130 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE), 135 ReadDataRaw(stream_pipe_.get(), media_buffer->writable_data(),
131 MOJO_RESULT_OK); 136 &bytes_read, MOJO_READ_DATA_FLAG_ALL_OR_NONE));
132 CHECK_EQ(bytes_to_read, bytes_read); 137 CHECK_EQ(bytes_to_read, bytes_read);
138 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, media_buffer);
139 } else {
140 CHECK_EQ(MOJO_HANDLE_SIGNAL_PEER_CLOSED, state.satisfied_signals);
141 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kAborted, nullptr);
alokp 2016/06/20 23:52:14 Should I reset stream_pipe_ here and early return
Ken Rockot(use gerrit already) 2016/06/21 00:15:50 I'll let xhwang comment on this. I don't understan
xhwang 2016/06/21 05:15:21 The Renderer hosted by MojoRendererService will ge
alokp 2016/06/21 17:09:32 Acknowledged.
142 return;
133 } 143 }
134
135 base::ResetAndReturn(&read_cb_).Run(DemuxerStream::kOk, media_buffer);
136 } 144 }
137 145
138 void MojoDemuxerStreamAdapter::UpdateConfig( 146 void MojoDemuxerStreamAdapter::UpdateConfig(
139 mojom::AudioDecoderConfigPtr audio_config, 147 mojom::AudioDecoderConfigPtr audio_config,
140 mojom::VideoDecoderConfigPtr video_config) { 148 mojom::VideoDecoderConfigPtr video_config) {
141 DCHECK_NE(type_, DemuxerStream::UNKNOWN); 149 DCHECK_NE(type_, DemuxerStream::UNKNOWN);
142 150
143 switch(type_) { 151 switch(type_) {
144 case DemuxerStream::AUDIO: 152 case DemuxerStream::AUDIO:
145 DCHECK(audio_config && !video_config); 153 DCHECK(audio_config && !video_config);
146 audio_config_ = audio_config.To<AudioDecoderConfig>(); 154 audio_config_ = audio_config.To<AudioDecoderConfig>();
147 break; 155 break;
148 case DemuxerStream::VIDEO: 156 case DemuxerStream::VIDEO:
149 DCHECK(video_config && !audio_config); 157 DCHECK(video_config && !audio_config);
150 video_config_ = video_config.To<VideoDecoderConfig>(); 158 video_config_ = video_config.To<VideoDecoderConfig>();
151 break; 159 break;
152 default: 160 default:
153 NOTREACHED(); 161 NOTREACHED();
154 } 162 }
155 } 163 }
156 164
157 } // namespace media 165 } // namespace media
OLDNEW
« 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