Chromium Code Reviews| Index: media/audio/pulse/pulse_output.h |
| diff --git a/media/audio/pulse/pulse_output.h b/media/audio/pulse/pulse_output.h |
| index 1d39af47f4598022f338a273984856199e1c3ea2..0c7d36ec9ec2fab988188a694fb9624835d649b5 100644 |
| --- a/media/audio/pulse/pulse_output.h |
| +++ b/media/audio/pulse/pulse_output.h |
| @@ -22,9 +22,8 @@ |
| #include <pulse/pulseaudio.h> |
| #include "base/memory/scoped_ptr.h" |
| -#include "base/memory/weak_ptr.h" |
| #include "media/audio/audio_io.h" |
| -#include "media/base/channel_layout.h" |
| +#include "media/audio/audio_parameters.h" |
| namespace media { |
| @@ -38,9 +37,6 @@ typedef AudioManagerOpenBSD AudioManagerPulse; |
| #error Unsupported platform |
| #endif |
| -class AudioParameters; |
| -class SeekableBuffer; |
| - |
| class PulseAudioOutputStream : public AudioOutputStream { |
| public: |
| PulseAudioOutputStream(const AudioParameters& params, |
| @@ -58,54 +54,38 @@ class PulseAudioOutputStream : public AudioOutputStream { |
| private: |
| // PulseAudio Callbacks. |
| - static void ContextStateCallback(pa_context* context, void* state_addr); |
| + static void ContextStateCallback(pa_context* context, void* p_this); |
| + static void StreamStateCallback(pa_stream* stream, void* p_this); |
| static void WriteRequestCallback(pa_stream* playback_handle, size_t length, |
| void* stream_addr); |
| - // Iterate the PulseAudio mainloop to get write requests. |
| - void WaitForWriteRequest(); |
| - |
| - // Get another packet from the data source and write it to the client buffer. |
| - bool BufferPacketFromSource(); |
| + // Retrieve a packet of audio data from |source_callback_| and write it to |
| + // |interleaved_audio_data_|. Returns the number of frames written. |
| + int FillBuffer(); |
| - // Fulfill a write request from the write request callback. If the write |
| - // can't be finished a first, post a new attempt to the message loop. |
| + // Fulfill a write request from the write request callback. Outputs silence |
| + // if the request could not be fulfilled. |
| void FulfillWriteRequest(size_t requested_bytes); |
| - // Write data from the client buffer to the PulseAudio stream. |
| - void WriteToStream(size_t bytes_to_write, size_t* bytes_written); |
| - |
| // API for Proxying calls to the AudioSourceCallback provided during Start(). |
| int RunDataCallback(AudioBus* audio_bus, AudioBuffersState buffers_state); |
| // Close() helper function to free internal structs. |
| void Reset(); |
| - // Configuration constants from the constructor. Referencable by all threads |
| - // since they are constants. |
| - const ChannelLayout channel_layout_; |
| - const uint32 channel_count_; |
| - const pa_sample_format_t sample_format_; |
| - const uint32 sample_rate_; |
| - const uint32 bytes_per_frame_; |
| + // AudioParameters from the constructor. |
| + const AudioParameters params_; |
| // Audio manager that created us. Used to report that we've closed. |
| AudioManagerPulse* manager_; |
| // PulseAudio API structs. |
| pa_context* pa_context_; |
| - pa_mainloop* pa_mainloop_; |
| + pa_threaded_mainloop* pa_mainloop_; |
| // Handle to the actual PulseAudio playback stream. |
| pa_stream* playback_handle_; |
| - // Device configuration data. Populated after Open() completes. |
| - uint32 packet_size_; |
| - uint32 frames_per_packet_; |
| - |
| - // Client side audio buffer feeding pulse audio's server side buffer. |
| - scoped_ptr<media::SeekableBuffer> client_buffer_; |
| - |
| // Float representation of volume from 0.0 to 1.0. |
| float volume_; |
| @@ -114,19 +94,15 @@ class PulseAudioOutputStream : public AudioOutputStream { |
| // entered an unrecoverable error state, or the Close() has executed. |
| bool stream_stopped_; |
| - // Whether or not PulseAudio has called the WriteCallback for the most recent |
| - // set of pa_mainloop iterations. |
| - bool write_callback_handled_; |
| - |
| - // Allows us to run tasks on the PulseAudioOutputStream instance which are |
| - // bound by its lifetime. |
| - base::WeakPtrFactory<PulseAudioOutputStream> weak_factory_; |
| - |
| // Callback to audio data source. |
| AudioSourceCallback* source_callback_; |
| // Container for retrieving data from AudioSourceCallback::OnMoreData(). |
| scoped_ptr<AudioBus> audio_bus_; |
| + scoped_array<uint8> interleaved_audio_data_; |
|
DaleCurtis
2012/10/10 18:19:05
Looks like I can remove this too by using pa_strea
|
| + |
| + volatile pa_stream_state_t stream_state_; |
| + volatile pa_context_state_t context_state_; |
| DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); |
| }; |