OLD | NEW |
---|---|
(Empty) | |
1 #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.
| |
2 #define MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ | |
3 | |
4 #include <pulse/pulseaudio.h> | |
5 | |
6 #include <string> | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "media/audio/audio_io.h" | |
10 #include "media/audio/audio_parameters.h" | |
11 | |
12 namespace media { | |
13 class SeekableBuffer; | |
14 } | |
15 | |
16 class AudioManagerLinux; | |
17 | |
18 class PulseAudioOutputStream : public AudioOutputStream { | |
19 public: | |
20 PulseAudioOutputStream(const AudioParameters& params, | |
21 AudioManagerLinux* manager); | |
22 | |
23 virtual ~PulseAudioOutputStream(); | |
24 | |
25 // Implementation of AudioOutputStream | |
sjl
2011/07/21 04:58:32
End comments with a period.
slock
2011/07/21 17:10:57
Done.
| |
26 virtual bool Open(); | |
27 virtual void Close(); | |
28 virtual void Start(AudioSourceCallback* callback); | |
29 virtual void Stop(); | |
30 virtual void SetVolume(double volume); | |
31 virtual void GetVolume(double* volume); | |
32 | |
33 private: | |
34 | |
sjl
2011/07/21 04:58:32
Spurious blank line.
slock
2011/07/21 17:10:57
Done.
| |
35 // Flags indicating the state of the stream. | |
36 enum InternalState { | |
37 kInError = 0, | |
38 kCreated, | |
39 kIsOpened, | |
40 kIsPlaying, | |
41 kIsStopped, | |
42 kIsClosed | |
43 }; | |
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
| |
44 friend std::ostream& operator<<(std::ostream& os, InternalState); | |
45 | |
46 // Functions to safeguard state transitions. All changes to the object state | |
47 // should go through these functions. | |
48 bool CanTransitionTo(InternalState to); | |
49 InternalState TransitionTo(InternalState to); | |
50 InternalState state(); | |
51 | |
52 // API for Proxying calls to the AudioSourceCallback provided during Start(). | |
53 uint32 RunDataCallback(uint8* dest, | |
54 uint32 max_size, | |
55 AudioBuffersState buffers_state); | |
56 void RunErrorCallback(int code); | |
57 | |
58 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to release | |
59 // ownership of the currently registered callback. | |
60 void set_source_callback(AudioSourceCallback* callback); | |
61 | |
62 // Configuration constants from the constructor. Referencable by all threads | |
63 // since they are constants. | |
64 const ChannelLayout channel_layout_; | |
65 const uint32 sample_rate_; | |
66 const uint32 bytes_per_sample_; | |
67 const uint32 bytes_per_frame_; | |
68 | |
69 // Device configuration data. Populated after OpenTask() completes. | |
70 bool should_downmix_; | |
71 bool should_swizzle_; | |
72 uint32 packet_size_; | |
73 uint32 micros_per_packet_; | |
74 uint32 latency_micros_; | |
75 uint32 bytes_per_output_frame_; | |
76 uint32 pulse_buffer_frames_; | |
77 | |
78 // Flag indicating the code should stop reading from the data source or | |
79 // writing to the PulseAudio server. This is set because the device has | |
80 // entered an unrecoverable error state, or the Close() has executed. | |
81 bool stop_stream_; | |
82 | |
83 // Audio manager that created us. Used to report that we've closed. | |
84 AudioManagerLinux* manager_; | |
85 | |
86 // PulseAudio API structs. | |
87 pa_mainloop* mainloop_; | |
88 pa_mainloop_api* mainloop_api_; | |
89 pa_context* context_; | |
90 | |
91 // Handle to the actual PulseAudio playback stream. | |
92 pa_stream* playback_handle_; | |
93 | |
94 scoped_ptr<media::SeekableBuffer> buffer_; | |
95 uint32 frames_per_packet_; | |
96 | |
97 InternalState state_; | |
98 float volume_; // Volume level from 0.0 to 1.0. | |
99 | |
100 AudioSourceCallback* source_callback_; | |
101 | |
102 DISALLOW_COPY_AND_ASSIGN(PulseAudioOutputStream); | |
103 }; | |
104 | |
105 #endif // MEDIA_AUDIO_LINUX_PULSE_OUTPUT_H_ | |
OLD | NEW |