| 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 #ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | 5 #ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ |
| 6 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | 6 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ |
| 7 | 7 |
| 8 #include <pulse/pulseaudio.h> | 8 #include <pulse/pulseaudio.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // Implementation of AudioInputStream. | 34 // Implementation of AudioInputStream. |
| 35 bool Open() override; | 35 bool Open() override; |
| 36 void Start(AudioInputCallback* callback) override; | 36 void Start(AudioInputCallback* callback) override; |
| 37 void Stop() override; | 37 void Stop() override; |
| 38 void Close() override; | 38 void Close() override; |
| 39 double GetMaxVolume() override; | 39 double GetMaxVolume() override; |
| 40 void SetVolume(double volume) override; | 40 void SetVolume(double volume) override; |
| 41 double GetVolume() override; | 41 double GetVolume() override; |
| 42 bool IsMuted() override; | 42 bool IsMuted() override; |
| 43 | 43 |
| 44 pa_threaded_mainloop* GetPAMainloop(); |
| 45 void SetDefaultSystemDeviceName(const std::string& name); |
| 46 |
| 44 private: | 47 private: |
| 45 // PulseAudio Callbacks. | 48 // PulseAudio Callbacks. |
| 46 static void ReadCallback(pa_stream* handle, size_t length, void* user_data); | 49 static void ReadCallback(pa_stream* handle, size_t length, void* user_data); |
| 47 static void StreamNotifyCallback(pa_stream* stream, void* user_data); | 50 static void StreamNotifyCallback(pa_stream* stream, void* user_data); |
| 48 static void VolumeCallback(pa_context* context, const pa_source_info* info, | 51 static void VolumeCallback(pa_context* context, const pa_source_info* info, |
| 49 int error, void* user_data); | 52 int error, void* user_data); |
| 50 static void MuteCallback(pa_context* context, | 53 static void MuteCallback(pa_context* context, |
| 51 const pa_source_info* info, | 54 const pa_source_info* info, |
| 52 int error, | 55 int error, |
| 53 void* user_data); | 56 void* user_data); |
| 54 | 57 |
| 58 // Get default system input device for the input stream. |
| 59 void GetSystemDefaultInputDevice(); |
| 60 |
| 55 // Helper for the ReadCallback. | 61 // Helper for the ReadCallback. |
| 56 void ReadData(); | 62 void ReadData(); |
| 57 | 63 |
| 58 // Utility method used by GetVolume() and IsMuted(). | 64 // Utility method used by GetVolume() and IsMuted(). |
| 59 bool GetSourceInformation(pa_source_info_cb_t callback); | 65 bool GetSourceInformation(pa_source_info_cb_t callback); |
| 60 | 66 |
| 61 AudioManagerPulse* audio_manager_; | 67 AudioManagerPulse* audio_manager_; |
| 62 AudioInputCallback* callback_; | 68 AudioInputCallback* callback_; |
| 63 std::string device_name_; | 69 const std::string device_name_; |
| 70 // The name of the system default device. Set by |
| 71 // GetSystemDefaultInputDeviceCallback if |device_name_| is set to be the |
| 72 // default device. |
| 73 std::string default_system_device_name_; |
| 74 |
| 64 AudioParameters params_; | 75 AudioParameters params_; |
| 65 int channels_; | 76 int channels_; |
| 66 double volume_; | 77 double volume_; |
| 67 bool stream_started_; | 78 bool stream_started_; |
| 68 | 79 |
| 69 // Set to true in IsMuted() if user has muted the selected microphone in the | 80 // Set to true in IsMuted() if user has muted the selected microphone in the |
| 70 // sound settings UI. | 81 // sound settings UI. |
| 71 bool muted_; | 82 bool muted_; |
| 72 | 83 |
| 73 // Holds the data from the OS. | 84 // Holds the data from the OS. |
| 74 AudioBlockFifo fifo_; | 85 AudioBlockFifo fifo_; |
| 75 | 86 |
| 76 // PulseAudio API structs. | 87 // PulseAudio API structs. |
| 77 pa_threaded_mainloop* pa_mainloop_; // Weak. | 88 pa_threaded_mainloop* pa_mainloop_; // Weak. |
| 78 pa_context* pa_context_; // Weak. | 89 pa_context* pa_context_; // Weak. |
| 79 pa_stream* handle_; | 90 pa_stream* handle_; |
| 80 | 91 |
| 81 base::ThreadChecker thread_checker_; | 92 base::ThreadChecker thread_checker_; |
| 82 | 93 |
| 83 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); | 94 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); |
| 84 }; | 95 }; |
| 85 | 96 |
| 86 } // namespace media | 97 } // namespace media |
| 87 | 98 |
| 88 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | 99 #endif // MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ |
| OLD | NEW |