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

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

Issue 14314026: remoting: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 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
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 #ifndef REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_ 5 #ifndef REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_
6 #define REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_ 6 #define REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/ref_counted_memory.h" 9 #include "base/memory/ref_counted_memory.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/observer_list_threadsafe.h" 11 #include "base/observer_list_threadsafe.h"
12 #include "base/time.h" 12 #include "base/time.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 14
15 namespace base { 15 namespace base {
16 class FilePath; 16 class FilePath;
17 } 17 }
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 struct AudioPipeReaderTraits; 21 struct AudioPipeReaderTraits;
22 22
23 // AudioPipeReader class reads from a named pipe to which an audio server (e.g. 23 // AudioPipeReader class reads from a named pipe to which an audio server (e.g.
24 // pulseaudio) writes the sound that's being played back and then sends data to 24 // pulseaudio) writes the sound that's being played back and then sends data to
25 // all registered observers. 25 // all registered observers.
26 class AudioPipeReader 26 class AudioPipeReader
27 : public base::RefCountedThreadSafe<AudioPipeReader, AudioPipeReaderTraits>, 27 : public base::RefCountedThreadSafe<AudioPipeReader, AudioPipeReaderTraits>,
28 public MessageLoopForIO::Watcher { 28 public base::MessageLoopForIO::Watcher {
29 public: 29 public:
30 class StreamObserver { 30 class StreamObserver {
31 public: 31 public:
32 virtual void OnDataRead(scoped_refptr<base::RefCountedString> data) = 0; 32 virtual void OnDataRead(scoped_refptr<base::RefCountedString> data) = 0;
33 }; 33 };
34 34
35 // |task_runner| specifies the IO thread to use to read data from the pipe. 35 // |task_runner| specifies the IO thread to use to read data from the pipe.
36 static scoped_refptr<AudioPipeReader> Create( 36 static scoped_refptr<AudioPipeReader> Create(
37 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 37 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
38 const base::FilePath& pipe_name); 38 const base::FilePath& pipe_name);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 base::TimeTicks started_time_; 70 base::TimeTicks started_time_;
71 71
72 // Stream position of the last capture in bytes with zero position 72 // Stream position of the last capture in bytes with zero position
73 // corresponding to |started_time_|. Must always be a multiple of the sample 73 // corresponding to |started_time_|. Must always be a multiple of the sample
74 // size. 74 // size.
75 int64 last_capture_position_; 75 int64 last_capture_position_;
76 76
77 // Bytes left from the previous read. 77 // Bytes left from the previous read.
78 std::string left_over_bytes_; 78 std::string left_over_bytes_;
79 79
80 MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_; 80 base::MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_;
81 81
82 DISALLOW_COPY_AND_ASSIGN(AudioPipeReader); 82 DISALLOW_COPY_AND_ASSIGN(AudioPipeReader);
83 }; 83 };
84 84
85 // Destroys |audio_pipe_reader| on the audio thread. 85 // Destroys |audio_pipe_reader| on the audio thread.
86 struct AudioPipeReaderTraits { 86 struct AudioPipeReaderTraits {
87 static void Destruct(const AudioPipeReader* audio_pipe_reader); 87 static void Destruct(const AudioPipeReader* audio_pipe_reader);
88 }; 88 };
89 89
90 } // namespace remoting 90 } // namespace remoting
91 91
92 #endif // REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_ 92 #endif // REMOTING_HOST_LINUX_AUDIO_PIPE_READER_H_
OLDNEW
« no previous file with comments | « remoting/host/ipc_desktop_environment_unittest.cc ('k') | remoting/host/linux/audio_pipe_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698