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

Unified Diff: remoting/host/linux/audio_pipe_reader.cc

Issue 2394883003: Use FileDescriptorWatcher in AudioPipeReader. (Closed)
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/linux/audio_pipe_reader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/linux/audio_pipe_reader.cc
diff --git a/remoting/host/linux/audio_pipe_reader.cc b/remoting/host/linux/audio_pipe_reader.cc
index c8d090ec0a96a302bca5fbb7af529385363a25e0..ac9f094e1fe1530ba66e767736672a722522d65c 100644
--- a/remoting/host/linux/audio_pipe_reader.cc
+++ b/remoting/host/linux/audio_pipe_reader.cc
@@ -63,15 +63,6 @@ void AudioPipeReader::RemoveObserver(StreamObserver* observer) {
observers_->RemoveObserver(observer);
}
-void AudioPipeReader::OnFileCanReadWithoutBlocking(int fd) {
- DCHECK_EQ(fd, pipe_.GetPlatformFile());
- StartTimer();
-}
-
-void AudioPipeReader::OnFileCanWriteWithoutBlocking(int fd) {
- NOTREACHED();
-}
-
void AudioPipeReader::StartOnAudioThread() {
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -115,7 +106,7 @@ void AudioPipeReader::TryOpenPipe() {
}
}
- file_descriptor_watcher_.StopWatchingFileDescriptor();
+ pipe_watch_controller_.reset();
timer_.Stop();
pipe_ = std::move(new_pipe);
@@ -138,6 +129,8 @@ void AudioPipeReader::TryOpenPipe() {
void AudioPipeReader::StartTimer() {
DCHECK(task_runner_->BelongsToCurrentThread());
+ DCHECK(pipe_watch_controller_);
+ pipe_watch_controller_.reset();
started_time_ = base::TimeTicks::Now();
last_capture_position_ = 0;
timer_.Start(FROM_HERE, capture_period_, this, &AudioPipeReader::DoCapture);
@@ -202,9 +195,10 @@ void AudioPipeReader::DoCapture() {
void AudioPipeReader::WaitForPipeReadable() {
timer_.Stop();
- base::MessageLoopForIO::current()->WatchFileDescriptor(
- pipe_.GetPlatformFile(), false, base::MessageLoopForIO::WATCH_READ,
- &file_descriptor_watcher_, this);
+ DCHECK(!pipe_watch_controller_);
+ pipe_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
+ pipe_.GetPlatformFile(),
+ base::Bind(&AudioPipeReader::StartTimer, base::Unretained(this)));
}
// static
« no previous file with comments | « remoting/host/linux/audio_pipe_reader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698