summaryrefslogtreecommitdiffstats
path: root/remoting/host/audio_capturer_linux.h
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 01:15:17 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-01 01:15:17 +0000
commitdcb41734dcf22b7a2150209e26e42bf3447077fc (patch)
tree2836275e33b3f1795f4ca338b9947e47c192b735 /remoting/host/audio_capturer_linux.h
parent904e9138fb2ca78ba6ae1f1054f9ce8cfe19eda5 (diff)
downloadchromium_src-dcb41734dcf22b7a2150209e26e42bf3447077fc.zip
chromium_src-dcb41734dcf22b7a2150209e26e42bf3447077fc.tar.gz
chromium_src-dcb41734dcf22b7a2150209e26e42bf3447077fc.tar.bz2
Fix AudioCapturer implementation to read from audio pipe even when there are no active clients.
Pulseaudio blocks playback when the host stops reading from the audio pipe. Previously the host was reading from the pipe only when there is an active client. Fixed the capturer to always read from the pipe, so that we don't halt playback when user disconnects. Also changed sampling rate to 48000 to avoid resampling in the host. BUG=153090 Review URL: https://codereview.chromium.org/11316010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165275 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host/audio_capturer_linux.h')
-rw-r--r--remoting/host/audio_capturer_linux.h47
1 files changed, 17 insertions, 30 deletions
diff --git a/remoting/host/audio_capturer_linux.h b/remoting/host/audio_capturer_linux.h
index 8a825ff..1a9453c 100644
--- a/remoting/host/audio_capturer_linux.h
+++ b/remoting/host/audio_capturer_linux.h
@@ -5,24 +5,28 @@
#ifndef REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_
#define REMOTING_HOST_AUDIO_CAPTURER_LINUX_H_
+#include "base/memory/ref_counted.h"
#include "remoting/host/audio_capturer.h"
-
-#include "base/message_loop.h"
-#include "base/time.h"
-#include "base/timer.h"
+#include "remoting/host/linux/audio_pipe_reader.h"
class FilePath;
namespace remoting {
+// Linux implementation of AudioCapturer interface which captures audio by
+// reading samples from a Pulseaudio "pipe" sink.
class AudioCapturerLinux : public AudioCapturer,
- public MessageLoopForIO::Watcher {
+ public AudioPipeReader::StreamObserver {
public:
- // Must be called to configure the capturer before the first instance is
- // created.
- static void SetPipeName(const FilePath& pipe_name);
-
- explicit AudioCapturerLinux(const FilePath& pipe_name);
+ // Must be called to configure the capturer before the first capturer instance
+ // is created. |task_runner| is an IO thread that is passed to AudioPipeReader
+ // to read from the pipe.
+ static void InitializePipeReader(
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ const FilePath& pipe_name);
+
+ explicit AudioCapturerLinux(
+ scoped_refptr<AudioPipeReader> pipe_reader);
virtual ~AudioCapturerLinux();
// AudioCapturer interface.
@@ -30,30 +34,13 @@ class AudioCapturerLinux : public AudioCapturer,
virtual void Stop() OVERRIDE;
virtual bool IsStarted() OVERRIDE;
- // MessageLoopForIO::Watcher interface.
- virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE;
- virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE;
+ // AudioPipeReader::StreamObserver interface.
+ virtual void OnDataRead(scoped_refptr<base::RefCountedString> data) OVERRIDE;
private:
- void StartTimer();
- void DoCapture();
- void WaitForPipeReadable();
-
- int pipe_fd_;
- base::RepeatingTimer<AudioCapturerLinux> timer_;
+ scoped_refptr<AudioPipeReader> pipe_reader_;
PacketCapturedCallback callback_;
- // Time when capturing was started.
- base::TimeTicks started_time_;
-
- // Stream position of the last capture.
- int64 last_capture_samples_;
-
- // Bytes left from the previous read.
- std::string left_over_bytes_;
-
- MessageLoopForIO::FileDescriptorWatcher file_descriptor_watcher_;
-
DISALLOW_COPY_AND_ASSIGN(AudioCapturerLinux);
};