Chromium Code Reviews| Index: media/audio/pulse/pulse_input.h |
| diff --git a/media/audio/pulse/pulse_input.h b/media/audio/pulse/pulse_input.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..52432d87a8cfaa55a7c819a9ab518f007c6891ea |
| --- /dev/null |
| +++ b/media/audio/pulse/pulse_input.h |
| @@ -0,0 +1,85 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| +// |
|
scherkus (not reviewing)
2013/02/14 00:51:35
remove line
no longer working on chromium
2013/02/14 11:36:07
Done.
|
| + |
| +#ifndef MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ |
| +#define MEDIA_AUDIO_PULSE_PULSE_INPUT_H_ |
| + |
| +#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.
|
| + |
| +#include <string> |
| + |
| +#include "media/audio/audio_device_name.h" |
| +#include "media/audio/audio_input_stream_impl.h" |
| +#include "media/audio/audio_io.h" |
| +#include "media/audio/audio_parameters.h" |
| + |
| +namespace media { |
| + |
| +class AudioManagerBase; |
| +class SeekableBuffer; |
| + |
| +class PulseAudioInputStream : public AudioInputStreamImpl { |
| + public: |
| + PulseAudioInputStream(AudioManagerBase* audio_manager, |
| + const std::string& device_name, |
| + const AudioParameters& params, |
| + pa_threaded_mainloop* mainloop, |
| + pa_context* context); |
| + |
| + virtual ~PulseAudioInputStream(); |
| + |
| + // Implementation of AudioInputStream. |
| + virtual bool Open() OVERRIDE; |
| + virtual void Start(AudioInputCallback* callback) OVERRIDE; |
| + virtual void Stop() OVERRIDE; |
| + virtual void Close() OVERRIDE; |
| + virtual double GetMaxVolume() OVERRIDE; |
| + virtual void SetVolume(double volume) OVERRIDE; |
| + virtual double GetVolume() OVERRIDE; |
| + |
| + private: |
| + // PulseAudio Callbacks. |
| + static void ContextStateCallback(pa_context* context, void* user_data); |
| + static void ReadCallback(pa_stream* handle, size_t length, void* user_data); |
| + static void StreamNotifyCallback(pa_stream* stream, void* user_data); |
| + static void VolumeCallback(pa_context* context, const pa_source_info* info, |
| + int error, void* user_data); |
| + |
| + // Helper for the ReadCallback. |
| + void ReadData(); |
| + |
| + // Flag indicating the state of the context has been changed. |
| + bool context_state_changed_; |
| + |
| + 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.
|
| + AudioInputCallback* callback_; |
| + std::string device_name_; |
| + AudioParameters params_; |
| + int channels_; |
| + double volume_; |
| + |
| + // Flag indicating the code should stop reading from the data source or |
| + // writing to the PulseAudio server. This is set because the device has |
| + // entered an unrecoverable error state, or the Stio() has executed. |
| + bool stream_started_; |
| + |
| + // Holds the data from the OS. |
| + scoped_ptr<media::SeekableBuffer> buffer_; |
| + |
| + // Temporary storage for recorded data. It gets a packet of data from |
| + // |buffer_| and deliver the data to OnData() callback. |
| + scoped_array<uint8> audio_data_buffer_; |
| + |
| + // PulseAudio API structs. |
| + pa_threaded_mainloop* pa_mainloop_; // Weak. |
| + pa_context* pa_context_; // Weak. |
| + pa_stream* handle_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PulseAudioInputStream); |
| +}; |
| + |
| +} // namespace media |
| + |
| +#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.
|