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> |
11 #include <unistd.h> | 11 #include <unistd.h> |
12 | 12 |
| 13 #include <utility> |
| 14 |
13 #include "base/logging.h" | 15 #include "base/logging.h" |
14 #include "base/posix/eintr_wrapper.h" | 16 #include "base/posix/eintr_wrapper.h" |
15 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
16 | 18 |
17 namespace remoting { | 19 namespace remoting { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 const int kSampleBytesPerSecond = AudioPipeReader::kSamplingRate * | 23 const int kSampleBytesPerSecond = AudioPipeReader::kSamplingRate * |
22 AudioPipeReader::kChannels * | 24 AudioPipeReader::kChannels * |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 if (fstat(pipe_.GetPlatformFile(), &old_stat) == 0 && | 111 if (fstat(pipe_.GetPlatformFile(), &old_stat) == 0 && |
110 fstat(new_pipe.GetPlatformFile(), &new_stat) == 0 && | 112 fstat(new_pipe.GetPlatformFile(), &new_stat) == 0 && |
111 old_stat.st_ino == new_stat.st_ino) { | 113 old_stat.st_ino == new_stat.st_ino) { |
112 return; | 114 return; |
113 } | 115 } |
114 } | 116 } |
115 | 117 |
116 file_descriptor_watcher_.StopWatchingFileDescriptor(); | 118 file_descriptor_watcher_.StopWatchingFileDescriptor(); |
117 timer_.Stop(); | 119 timer_.Stop(); |
118 | 120 |
119 pipe_ = new_pipe.Pass(); | 121 pipe_ = std::move(new_pipe); |
120 | 122 |
121 if (pipe_.IsValid()) { | 123 if (pipe_.IsValid()) { |
122 // Get buffer size for the pipe. | 124 // Get buffer size for the pipe. |
123 pipe_buffer_size_ = fpathconf(pipe_.GetPlatformFile(), _PC_PIPE_BUF); | 125 pipe_buffer_size_ = fpathconf(pipe_.GetPlatformFile(), _PC_PIPE_BUF); |
124 if (pipe_buffer_size_ < 0) { | 126 if (pipe_buffer_size_ < 0) { |
125 PLOG(ERROR) << "fpathconf(_PC_PIPE_BUF)"; | 127 PLOG(ERROR) << "fpathconf(_PC_PIPE_BUF)"; |
126 pipe_buffer_size_ = 4096; | 128 pipe_buffer_size_ = 4096; |
127 } | 129 } |
128 | 130 |
129 // Read from the pipe twice per buffer length, to avoid starving the stream. | 131 // Read from the pipe twice per buffer length, to avoid starving the stream. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 pipe_.GetPlatformFile(), false, base::MessageLoopForIO::WATCH_READ, | 206 pipe_.GetPlatformFile(), false, base::MessageLoopForIO::WATCH_READ, |
205 &file_descriptor_watcher_, this); | 207 &file_descriptor_watcher_, this); |
206 } | 208 } |
207 | 209 |
208 // static | 210 // static |
209 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) { | 211 void AudioPipeReaderTraits::Destruct(const AudioPipeReader* audio_pipe_reader) { |
210 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader); | 212 audio_pipe_reader->task_runner_->DeleteSoon(FROM_HERE, audio_pipe_reader); |
211 } | 213 } |
212 | 214 |
213 } // namespace remoting | 215 } // namespace remoting |
OLD | NEW |