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

Side by Side Diff: remoting/host/audio_capturer_linux.cc

Issue 10911271: Remove CommandLine dependency from the Linux's AudioCapturer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 #include "remoting/host/audio_capturer_linux.h" 5 #include "remoting/host/audio_capturer_linux.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <unistd.h> 10 #include <unistd.h>
11 11
12 #include "base/command_line.h"
13 #include "base/eintr_wrapper.h" 12 #include "base/eintr_wrapper.h"
14 #include "base/file_path.h" 13 #include "base/file_path.h"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/stl_util.h" 15 #include "base/stl_util.h"
17 #include "remoting/proto/audio.pb.h" 16 #include "remoting/proto/audio.pb.h"
17 #include "remoting/host/chromoting_host_context.h"
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 namespace { 21 namespace {
22 22
23 const char kAudioPipeOptionName[] = "audio-pipe-name";
24
25 // PulseAudio's module-pipe-sink must be configured to use the following 23 // PulseAudio's module-pipe-sink must be configured to use the following
26 // parameters for the sink we read from. 24 // parameters for the sink we read from.
27 const AudioPacket_SamplingRate kSamplingRate = AudioPacket::SAMPLING_RATE_44100; 25 const AudioPacket_SamplingRate kSamplingRate = AudioPacket::SAMPLING_RATE_44100;
28 const int kChannels = 2; 26 const int kChannels = 2;
29 const int kBytesPerSample = 2; 27 const int kBytesPerSample = 2;
30 28
31 // Read data from the pipe every 40ms. 29 // Read data from the pipe every 40ms.
32 const int kCapturingPeriodMs = 40; 30 const int kCapturingPeriodMs = 40;
33 31
34 #if !defined(F_SETPIPE_SZ) 32 #if !defined(F_SETPIPE_SZ)
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 callback_.Run(packet.Pass()); 166 callback_.Run(packet.Pass());
169 } 167 }
170 168
171 void AudioCapturerLinux::WaitForPipeReadable() { 169 void AudioCapturerLinux::WaitForPipeReadable() {
172 timer_.Stop(); 170 timer_.Stop();
173 MessageLoopForIO::current()->WatchFileDescriptor( 171 MessageLoopForIO::current()->WatchFileDescriptor(
174 pipe_fd_, false, MessageLoopForIO::WATCH_READ, 172 pipe_fd_, false, MessageLoopForIO::WATCH_READ,
175 &file_descriptor_watcher_, this); 173 &file_descriptor_watcher_, this);
176 } 174 }
177 175
178 bool AudioCapturer::IsSupported() { 176 bool AudioCapturer::IsSupported(
179 CommandLine* cl = CommandLine::ForCurrentProcess(); 177 ChromotingHostContext* context) {
180 return !cl->GetSwitchValuePath(kAudioPipeOptionName).empty(); 178 return !context->audio_capturer_pipe().empty();
181 } 179 }
182 180
183 scoped_ptr<AudioCapturer> AudioCapturer::Create() { 181 scoped_ptr<AudioCapturer> AudioCapturer::Create(
184 CommandLine* cl = CommandLine::ForCurrentProcess(); 182 ChromotingHostContext* context) {
185 FilePath path = cl->GetSwitchValuePath(kAudioPipeOptionName); 183 FilePath path = context->audio_capturer_pipe();
186 if (path.empty()) 184 if (path.empty())
187 return scoped_ptr<AudioCapturer>(); 185 return scoped_ptr<AudioCapturer>();
188 return scoped_ptr<AudioCapturer>(new AudioCapturerLinux(path)); 186 return scoped_ptr<AudioCapturer>(new AudioCapturerLinux(path));
189 } 187 }
190 188
191 } // namespace remoting 189 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698