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

Side by Side Diff: remoting/host/linux/audio_pipe_reader.cc

Issue 11744009: Fix AudioPipeReader to handle EOF properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/linux/audio_pipe_reader.h" 5 #include "remoting/host/linux/audio_pipe_reader.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int64 bytes_to_read = stream_position_bytes - last_capture_position_; 138 int64 bytes_to_read = stream_position_bytes - last_capture_position_;
139 139
140 std::string data = left_over_bytes_; 140 std::string data = left_over_bytes_;
141 size_t pos = data.size(); 141 size_t pos = data.size();
142 left_over_bytes_.clear(); 142 left_over_bytes_.clear();
143 data.resize(pos + bytes_to_read); 143 data.resize(pos + bytes_to_read);
144 144
145 while (pos < data.size()) { 145 while (pos < data.size()) {
146 int read_result = HANDLE_EINTR( 146 int read_result = HANDLE_EINTR(
147 read(pipe_fd_, string_as_array(&data) + pos, data.size() - pos)); 147 read(pipe_fd_, string_as_array(&data) + pos, data.size() - pos));
148 if (read_result >= 0) { 148 if (read_result > 0) {
149 pos += read_result; 149 pos += read_result;
150 } else { 150 } else {
151 if (errno != EWOULDBLOCK && errno != EAGAIN) 151 if (read_result < 0 && errno != EWOULDBLOCK && errno != EAGAIN)
152 PLOG(ERROR) << "read"; 152 PLOG(ERROR) << "read";
Lambros 2013/01/02 22:51:28 optional: PLOG_IF(ERROR, condition) <<..
Sergey Ulanov 2013/01/02 23:02:20 I don't think PLOG_IF() would make this code more
153 break; 153 break;
154 } 154 }
155 } 155 }
156 156
157 // Stop reading from the pipe if PulseAudio isn't writing anything. 157 // Stop reading from the pipe if PulseAudio isn't writing anything.
158 if (pos == 0) { 158 if (pos == 0) {
159 WaitForPipeReadable(); 159 WaitForPipeReadable();
160 return; 160 return;
161 } 161 }
162 162
(...skipping 28 matching lines...) Expand all
191 pipe_fd_, false, MessageLoopForIO::WATCH_READ, 191 pipe_fd_, false, MessageLoopForIO::WATCH_READ,
192 &file_descriptor_watcher_, this); 192 &file_descriptor_watcher_, this);
193 } 193 }
194 194
195 // static 195 // static
196 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) { 196 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) {
197 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader); 197 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader);
198 } 198 }
199 199
200 } // namespace remoting 200 } // namespace remoting
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