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/audio_capturer_linux.h" | 5 #include "remoting/host/audio_capturer_linux.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "remoting/proto/audio.pb.h" | 10 #include "remoting/proto/audio.pb.h" |
11 | 11 |
12 namespace remoting { | 12 namespace remoting { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 // PulseAudio's module-pipe-sink must be configured to use the following | 16 // PulseAudio's module-pipe-sink must be configured to use the following |
17 // parameters for the sink we read from. | 17 // parameters for the sink we read from. |
18 const AudioPacket_SamplingRate kSamplingRate = AudioPacket::SAMPLING_RATE_48000; | 18 const AudioPacket_SamplingRate kSamplingRate = AudioPacket::SAMPLING_RATE_48000; |
19 | 19 |
20 base::LazyInstance<scoped_refptr<AudioPipeReader> >::Leaky | 20 base::LazyInstance<scoped_refptr<AudioPipeReader> >::Leaky |
21 g_pulseaudio_pipe_sink_reader = LAZY_INSTANCE_INITIALIZER; | 21 g_pulseaudio_pipe_sink_reader = LAZY_INSTANCE_INITIALIZER; |
22 | 22 |
23 } // namespace | 23 } // namespace |
24 | 24 |
25 // TODO(wez): Remove this and have the DesktopEnvironmentFactory own the | 25 // TODO(wez): Remove this and have the DesktopEnvironmentFactory own the |
26 // AudioPipeReader rather than having it process-global. | 26 // AudioPipeReader rather than having it process-global. |
27 // See crbug.com/161373 and crbug.com/104544. | 27 // See crbug.com/161373 and crbug.com/104544. |
28 void AudioCapturerLinux::InitializePipeReader( | 28 void AudioCapturerLinux::InitializePipeReader( |
29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
30 const FilePath& pipe_name) { | 30 const base::FilePath& pipe_name) { |
31 scoped_refptr<AudioPipeReader> pipe_reader; | 31 scoped_refptr<AudioPipeReader> pipe_reader; |
32 if (!pipe_name.empty()) | 32 if (!pipe_name.empty()) |
33 pipe_reader = AudioPipeReader::Create(task_runner, pipe_name); | 33 pipe_reader = AudioPipeReader::Create(task_runner, pipe_name); |
34 g_pulseaudio_pipe_sink_reader.Get() = pipe_reader; | 34 g_pulseaudio_pipe_sink_reader.Get() = pipe_reader; |
35 } | 35 } |
36 | 36 |
37 AudioCapturerLinux::AudioCapturerLinux( | 37 AudioCapturerLinux::AudioCapturerLinux( |
38 scoped_refptr<AudioPipeReader> pipe_reader) | 38 scoped_refptr<AudioPipeReader> pipe_reader) |
39 : pipe_reader_(pipe_reader), | 39 : pipe_reader_(pipe_reader), |
40 silence_detector_(0) { | 40 silence_detector_(0) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 scoped_ptr<AudioCapturer> AudioCapturer::Create() { | 85 scoped_ptr<AudioCapturer> AudioCapturer::Create() { |
86 scoped_refptr<AudioPipeReader> reader = | 86 scoped_refptr<AudioPipeReader> reader = |
87 g_pulseaudio_pipe_sink_reader.Get(); | 87 g_pulseaudio_pipe_sink_reader.Get(); |
88 if (!reader) | 88 if (!reader) |
89 return scoped_ptr<AudioCapturer>(); | 89 return scoped_ptr<AudioCapturer>(); |
90 return scoped_ptr<AudioCapturer>(new AudioCapturerLinux(reader)); | 90 return scoped_ptr<AudioCapturer>(new AudioCapturerLinux(reader)); |
91 } | 91 } |
92 | 92 |
93 } // namespace remoting | 93 } // namespace remoting |
OLD | NEW |