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

Side by Side Diff: media/audio/pulse/audio_manager_pulse.h

Issue 10952024: Adding pulseaudio input support to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and addressed Dale's final comments. Created 7 years, 10 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
« no previous file with comments | « media/audio/linux/audio_manager_linux.cc ('k') | media/audio/pulse/audio_manager_pulse.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_ 5 #ifndef MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
6 #define MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_ 6 #define MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
7 7
8 #include <pulse/pulseaudio.h>
8 #include <string> 9 #include <string>
10
9 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
11 #include "base/threading/thread.h"
12 #include "media/audio/audio_manager_base.h" 13 #include "media/audio/audio_manager_base.h"
13 14
14 namespace media { 15 namespace media {
15 16
16 class AlsaWrapper; 17 class MEDIA_EXPORT AudioManagerPulse : public AudioManagerBase {
18 public:
19 AudioManagerPulse();
20 virtual ~AudioManagerPulse();
17 21
18 class MEDIA_EXPORT AudioManagerLinux : public AudioManagerBase { 22 static AudioManager* Create();
19 public:
20 AudioManagerLinux();
21 23
22 // Implementation of AudioManager. 24 // Implementation of AudioManager.
23 virtual bool HasAudioOutputDevices() OVERRIDE; 25 virtual bool HasAudioOutputDevices() OVERRIDE;
24 virtual bool HasAudioInputDevices() OVERRIDE; 26 virtual bool HasAudioInputDevices() OVERRIDE;
25 virtual void ShowAudioInputSettings() OVERRIDE; 27 virtual void ShowAudioInputSettings() OVERRIDE;
26 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names) 28 virtual void GetAudioInputDeviceNames(media::AudioDeviceNames* device_names)
27 OVERRIDE; 29 OVERRIDE;
28 30
29 // Implementation of AudioManagerBase. 31 // Implementation of AudioManagerBase.
30 virtual AudioOutputStream* MakeLinearOutputStream( 32 virtual AudioOutputStream* MakeLinearOutputStream(
31 const AudioParameters& params) OVERRIDE; 33 const AudioParameters& params) OVERRIDE;
32 virtual AudioOutputStream* MakeLowLatencyOutputStream( 34 virtual AudioOutputStream* MakeLowLatencyOutputStream(
33 const AudioParameters& params) OVERRIDE; 35 const AudioParameters& params) OVERRIDE;
34 virtual AudioInputStream* MakeLinearInputStream( 36 virtual AudioInputStream* MakeLinearInputStream(
35 const AudioParameters& params, const std::string& device_id) OVERRIDE; 37 const AudioParameters& params, const std::string& device_id) OVERRIDE;
36 virtual AudioInputStream* MakeLowLatencyInputStream( 38 virtual AudioInputStream* MakeLowLatencyInputStream(
37 const AudioParameters& params, const std::string& device_id) OVERRIDE; 39 const AudioParameters& params, const std::string& device_id) OVERRIDE;
38 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters( 40 virtual AudioParameters GetPreferredLowLatencyOutputStreamParameters(
39 const AudioParameters& input_params) OVERRIDE; 41 const AudioParameters& input_params) OVERRIDE;
40 42
41 protected: 43 int GetNativeSampleRate();
42 virtual ~AudioManagerLinux();
43 44
44 private: 45 private:
45 enum StreamType { 46 bool Init();
46 kStreamPlayback = 0, 47 void DestroyPulse();
47 kStreamCapture,
48 };
49 48
50 // Gets a list of available ALSA input devices. 49 // Callback to get the devices' info like names, used by GetInputDevices().
51 void GetAlsaAudioInputDevices(media::AudioDeviceNames* device_names); 50 static void DevicesInfoCallback(pa_context* context,
51 const pa_source_info* info,
52 int error, void* user_data);
52 53
53 // Gets the ALSA devices' names and ids. 54 // Callback to get the native sample rate of PulseAudio, used by
54 void GetAlsaDevicesInfo(void** hint, media::AudioDeviceNames* device_names); 55 // GetNativeSampleRate().
55 56 static void SampleRateInfoCallback(pa_context* context,
56 // Checks if the specific ALSA device is available. 57 const pa_server_info* info,
57 bool IsAlsaDeviceAvailable(const char* device_name); 58 void* user_data);
58
59 // Returns true if a device is present for the given stream type.
60 bool HasAnyAlsaAudioDevice(StreamType stream);
61 59
62 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream. 60 // Called by MakeLinearOutputStream and MakeLowLatencyOutputStream.
63 AudioOutputStream* MakeOutputStream(const AudioParameters& params); 61 AudioOutputStream* MakeOutputStream(const AudioParameters& params);
64 62
65 // Called by MakeLinearInputStream and MakeLowLatencyInputStream. 63 // Called by MakeLinearInputStream and MakeLowLatencyInputStream.
66 AudioInputStream* MakeInputStream(const AudioParameters& params, 64 AudioInputStream* MakeInputStream(const AudioParameters& params,
67 const std::string& device_id); 65 const std::string& device_id);
68 66
69 scoped_ptr<AlsaWrapper> wrapper_; 67 pa_threaded_mainloop* input_mainloop_;
68 pa_context* input_context_;
69 AudioDeviceNames* devices_;
70 int native_input_sample_rate_;
70 71
71 DISALLOW_COPY_AND_ASSIGN(AudioManagerLinux); 72 DISALLOW_COPY_AND_ASSIGN(AudioManagerPulse);
72 }; 73 };
73 74
74 } // namespace media 75 } // namespace media
75 76
76 #endif // MEDIA_AUDIO_LINUX_AUDIO_MANAGER_LINUX_H_ 77 #endif // MEDIA_AUDIO_PULSE_AUDIO_MANAGER_PULSE_H_
OLDNEW
« no previous file with comments | « media/audio/linux/audio_manager_linux.cc ('k') | media/audio/pulse/audio_manager_pulse.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698