| OLD | NEW |
| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 kSampleBytesPerSecond / | 154 kSampleBytesPerSecond / |
| 155 base::Time::kMillisecondsPerSecond; | 155 base::Time::kMillisecondsPerSecond; |
| 156 int64_t bytes_to_read = stream_position_bytes - last_capture_position_; | 156 int64_t bytes_to_read = stream_position_bytes - last_capture_position_; |
| 157 | 157 |
| 158 std::string data = left_over_bytes_; | 158 std::string data = left_over_bytes_; |
| 159 size_t pos = data.size(); | 159 size_t pos = data.size(); |
| 160 left_over_bytes_.clear(); | 160 left_over_bytes_.clear(); |
| 161 data.resize(pos + bytes_to_read); | 161 data.resize(pos + bytes_to_read); |
| 162 | 162 |
| 163 while (pos < data.size()) { | 163 while (pos < data.size()) { |
| 164 int read_result = | 164 int read_result = pipe_.ReadAtCurrentPos(base::string_as_array(&data) + pos, |
| 165 pipe_.ReadAtCurrentPos(string_as_array(&data) + pos, data.size() - pos); | 165 data.size() - pos); |
| 166 if (read_result > 0) { | 166 if (read_result > 0) { |
| 167 pos += read_result; | 167 pos += read_result; |
| 168 } else { | 168 } else { |
| 169 if (read_result < 0 && errno != EWOULDBLOCK && errno != EAGAIN) | 169 if (read_result < 0 && errno != EWOULDBLOCK && errno != EAGAIN) |
| 170 PLOG(ERROR) << "read"; | 170 PLOG(ERROR) << "read"; |
| 171 break; | 171 break; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 // Stop reading from the pipe if PulseAudio isn't writing anything. | 175 // Stop reading from the pipe if PulseAudio isn't writing anything. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 206 pipe_.GetPlatformFile(), false, base::MessageLoopForIO::WATCH_READ, | 206 pipe_.GetPlatformFile(), false, base::MessageLoopForIO::WATCH_READ, |
| 207 &file_descriptor_watcher_, this); | 207 &file_descriptor_watcher_, this); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // static | 210 // static |
| 211 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) { | 211 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) { |
| 212 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader); | 212 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader); |
| 213 } | 213 } |
| 214 | 214 |
| 215 } // namespace remoting | 215 } // namespace remoting |
| OLD | NEW |