Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
|
scherkus (not reviewing)
2013/02/14 00:51:35
remove line
no longer working on chromium
2013/02/14 11:36:07
Done.
| |
| 5 | |
| 6 #ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | |
| 7 #define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ | |
| 8 | |
| 9 #include <pulse/pulseaudio.h> | |
|
scherkus (not reviewing)
2013/02/14 00:51:35
it appears that all pa_xxx types can be forward de
no longer working on chromium
2013/02/14 11:36:07
Done.
| |
| 10 | |
| 11 #include <string> | |
| 12 | |
| 13 #include "media/audio/audio_device_name.h" | |
| 14 #include "media/audio/audio_input_stream_impl.h" | |
| 15 #include "media/audio/audio_io.h" | |
| 16 #include "media/audio/audio_parameters.h" | |
| 17 | |
| 18 namespace media { | |
| 19 | |
| 20 class AudioManagerBase; | |
| 21 class SeekableBuffer; | |
| 22 | |
| 23 class PulseAudioInputStream : public AudioInputStreamImpl { | |
| 24 public: | |
| 25 PulseAudioInputStream(AudioManagerBase* audio_manager, | |
| 26 const std::string& device_name, | |
| 27 const AudioParameters& params, | |
| 28 pa_threaded_mainloop* mainloop, | |
| 29 pa_context* context); | |
| 30 | |
| 31 virtual ~PulseAudioInputStream(); | |
| 32 | |
| 33 // Implementation of AudioInputStream. | |
| 34 virtual bool Open() OVERRIDE; | |
| 35 virtual void Start(AudioInputCallback* callback) OVERRIDE; | |
| 36 virtual void Stop() OVERRIDE; | |
| 37 virtual void Close() OVERRIDE; | |
| 38 virtual double GetMaxVolume() OVERRIDE; | |
| 39 virtual void SetVolume(double volume) OVERRIDE; | |
| 40 virtual double GetVolume() OVERRIDE; | |
| 41 | |
| 42 private: | |
| 43 // PulseAudio Callbacks. | |
| 44 static void ContextStateCallback(pa_context* context, void* user_data); | |
| 45 static void ReadCallback(pa_stream* handle, size_t length, void* user_data); | |
| 46 static void StreamNotifyCallback(pa_stream* stream, void* user_data); | |
| 47 static void VolumeCallback(pa_context* context, const pa_source_info* info, | |
| 48 int error, void* user_data); | |
| 49 | |
| 50 // Helper for the ReadCallback. | |
| 51 void ReadData(); | |
| 52 | |
| 53 // Flag indicating the state of the context has been changed. | |
| 54 bool context_state_changed_; | |
| 55 | |
| 56 AudioManagerBase* audio_manager_; | |
|
scherkus (not reviewing)
2013/02/14 00:51:35
make this AudioManagerPulse -- I hope AudioManager
no longer working on chromium
2013/02/14 11:36:07
Done.
| |
| 57 AudioInputCallback* callback_; | |
| 58 std::string device_name_; | |
| 59 AudioParameters params_; | |
| 60 int channels_; | |
| 61 double volume_; | |
| 62 | |
| 63 // Flag indicating the code should stop reading from the data source or | |
| 64 // writing to the PulseAudio server. This is set because the device has | |
| 65 // entered an unrecoverable error state, or the Stio() has executed. | |
| 66 bool stream_started_; | |
| 67 | |
| 68 // Holds the data from the OS. | |
| 69 scoped_ptr<media::SeekableBuffer> buffer_; | |
| 70 | |
| 71 // Temporary storage for recorded data. It gets a packet of data from | |
| 72 // |buffer_| and deliver the data to OnData() callback. | |
| 73 scoped_array<uint8> audio_data_buffer_; | |
| 74 | |
| 75 // PulseAudio API structs. | |
| 76 pa_threaded_mainloop* pa_mainloop_; // Weak. | |
| 77 pa_context* pa_context_; // Weak. | |
| 78 pa_stream* handle_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); | |
| 81 }; | |
| 82 | |
| 83 } // namespace media | |
| 84 | |
| 85 #endif // MEDIA_AUDIO_PULSE_PULSE_OUTPUT_H_ | |
|
scherkus (not reviewing)
2013/02/14 00:51:35
fix
no longer working on chromium
2013/02/14 11:36:07
Done.
| |
| OLD | NEW |