12 #ifndef ROC_SNDIO_PULSEAUDIO_DEVICE_H_
13 #define ROC_SNDIO_PULSEAUDIO_DEVICE_H_
15 #include <pulse/pulseaudio.h>
35 bool open(
const char* device);
64 static void context_state_cb_(pa_context* context,
void* userdata);
67 device_info_cb_(pa_context* context,
const void* info,
int eol,
void* userdata);
69 static void stream_state_cb_(pa_stream* stream,
void* userdata);
70 static void stream_request_cb_(pa_stream* stream,
size_t length,
void* userdata);
72 static void timer_cb_(pa_mainloop_api* mainloop,
74 const struct timeval* tv,
79 void want_mainloop_()
const;
80 bool start_mainloop_();
81 void stop_mainloop_();
85 void set_opened_(
bool opened);
88 void close_context_();
90 bool start_device_info_op_();
91 void cancel_device_info_op_();
93 void init_stream_params_(
const pa_sample_spec& device_sample_spec);
94 bool check_stream_params_()
const;
100 ssize_t wait_stream_();
103 void report_latency_();
115 size_t record_frag_size_;
116 bool record_frag_flag_;
124 pa_threaded_mainloop* mainloop_;
125 pa_context* context_;
126 pa_operation* device_info_op_;
128 pa_time_event* timer_;
132 pa_sample_spec sample_spec_;
133 pa_buffer_attr buffer_attrs_;
Sample specification. Describes sample rate and channels.
Base class for non-copyable objects.
PulseAudio device. Base class for PulseAudio source and sink.
DeviceState state() const
Get device state.
void pause()
Pause reading.
audio::SampleSpec sample_spec() const
Get sample specification of the sink.
core::nanoseconds_t latency() const
Get latency of the sink.
bool open(const char *device)
Open output device.
bool restart()
Restart reading from the beginning.
PulseaudioDevice(const Config &config, DeviceType device_type)
Initialize.
bool resume()
Resume paused reading.
bool request(audio::Frame &frame)
Process audio frame.
float sample_t
Audio sample.
int64_t nanoseconds_t
Nanoseconds.
Commonly used types and functions.
Various units used in packets.