Chromium Code Reviews| Index: media/audio/linux/pulse_output.h |
| diff --git a/media/audio/linux/pulse_output.h b/media/audio/linux/pulse_output.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b19ab1751f8e8d9a9363ed8d39a63fb4b61fe0b9 |
| --- /dev/null |
| +++ b/media/audio/linux/pulse_output.h |
| @@ -0,0 +1,105 @@ |
| +#ifndef MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ |
|
sjl
2011/07/21 04:58:32
You need a chromium copyright header here.
slock
2011/07/21 17:10:57
Done.
|
| +#define MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ |
| + |
| +#include <pulse/pulseaudio.h> |
| + |
| +#include <string> |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "media/audio/audio_io.h" |
| +#include "media/audio/audio_parameters.h" |
| + |
| +namespace media { |
| +class SeekableBuffer; |
| +} |
| + |
| +class AudioManagerLinux; |
| + |
| +class PulseAudioOutputStream : public AudioOutputStream { |
| + public: |
| + PulseAudioOutputStream(const AudioParameters& params, |
| + AudioManagerLinux* manager); |
| + |
| + virtual ~PulseAudioOutputStream(); |
| + |
| + // Implementation of AudioOutputStream |
|
sjl
2011/07/21 04:58:32
End comments with a period.
slock
2011/07/21 17:10:57
Done.
|
| + virtual bool Open(); |
| + virtual void Close(); |
| + virtual void Start(AudioSourceCallback* callback); |
| + virtual void Stop(); |
| + virtual void SetVolume(double volume); |
| + virtual void GetVolume(double* volume); |
| + |
| + private: |
| + |
|
sjl
2011/07/21 04:58:32
Spurious blank line.
slock
2011/07/21 17:10:57
Done.
|
| + // Flags indicating the state of the stream. |
| + enum InternalState { |
| + kInError = 0, |
| + kCreated, |
| + kIsOpened, |
| + kIsPlaying, |
| + kIsStopped, |
| + kIsClosed |
| + }; |
|
sjl
2011/07/21 04:58:32
Blank line after the enum.
slock
2011/07/21 17:10:57
I should fix this in alsa_output.h too then I take
|
| + friend std::ostream& operator<<(std::ostream& os, InternalState); |
| + |
| + // Functions to safeguard state transitions. All changes to the object state |
| + // should go through these functions. |
| + bool CanTransitionTo(InternalState to); |
| + InternalState TransitionTo(InternalState to); |
| + InternalState state(); |
| + |
| + // API for Proxying calls to the AudioSourceCallback provided during Start(). |
| + uint32 RunDataCallback(uint8* dest, |
| + uint32 max_size, |
| + AudioBuffersState buffers_state); |
| + void RunErrorCallback(int code); |
| + |
| + // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to release |
| + // ownership of the currently registered callback. |
| + void set_source_callback(AudioSourceCallback* callback); |
| + |
| + // Configuration constants from the constructor. Referencable by all threads |
| + // since they are constants. |
| + const ChannelLayout channel_layout_; |
| + const uint32 sample_rate_; |
| + const uint32 bytes_per_sample_; |
| + const uint32 bytes_per_frame_; |
| + |
| + // Device configuration data. Populated after OpenTask() completes. |
| + bool should_downmix_; |
| + bool should_swizzle_; |
| + uint32 packet_size_; |
| + uint32 micros_per_packet_; |
| + uint32 latency_micros_; |
| + uint32 bytes_per_output_frame_; |
| + uint32 pulse_buffer_frames_; |
| + |
| + // 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 Close() has executed. |
| + bool stop_stream_; |
| + |
| + // Audio manager that created us. Used to report that we've closed. |
| + AudioManagerLinux* manager_; |
| + |
| + // PulseAudio API structs. |
| + pa_mainloop* mainloop_; |
| + pa_mainloop_api* mainloop_api_; |
| + pa_context* context_; |
| + |
| + // Handle to the actual PulseAudio playback stream. |
| + pa_stream* playback_handle_; |
| + |
| + scoped_ptr<media::SeekableBuffer> buffer_; |
| + uint32 frames_per_packet_; |
| + |
| + InternalState state_; |
| + float volume_; // Volume level from 0.0 to 1.0. |
| + |
| + AudioSourceCallback* source_callback_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); |
| +}; |
| + |
| +#endif // MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ |