2015-07-01 08:02:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Andrew Kelley
|
|
|
|
*
|
|
|
|
* This file is part of libsoundio, which is MIT licensed.
|
|
|
|
* See http://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
#ifndef SOUNDIO_PULSEAUDIO_H
|
|
|
|
#define SOUNDIO_PULSEAUDIO_H
|
2015-07-01 08:02:44 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
#include "soundio_internal.h"
|
|
|
|
#include "atomics.h"
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
#include <pulse/pulseaudio.h>
|
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoPrivate;
|
2015-07-13 16:17:20 +00:00
|
|
|
int soundio_pulseaudio_init(struct SoundIoPrivate *si);
|
2015-07-01 08:02:44 +00:00
|
|
|
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoDevicePulseAudio { int make_the_struct_not_empty; };
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
struct SoundIoPulseAudio {
|
2015-08-28 03:53:28 +00:00
|
|
|
int device_query_err;
|
2015-07-30 07:46:13 +00:00
|
|
|
int connection_err;
|
2015-08-28 03:53:28 +00:00
|
|
|
bool emitted_shutdown_cb;
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
pa_context *pulse_context;
|
2015-08-28 03:53:28 +00:00
|
|
|
bool device_scan_queued;
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
// the one that we're working on building
|
|
|
|
struct SoundIoDevicesInfo *current_devices_info;
|
|
|
|
char *default_sink_name;
|
|
|
|
char *default_source_name;
|
|
|
|
|
|
|
|
// this one is ready to be read with flush_events. protected by mutex
|
|
|
|
struct SoundIoDevicesInfo *ready_devices_info;
|
|
|
|
|
2015-08-28 03:53:28 +00:00
|
|
|
bool ready_flag;
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
pa_threaded_mainloop *main_loop;
|
|
|
|
pa_proplist *props;
|
|
|
|
};
|
|
|
|
|
2015-07-28 00:06:12 +00:00
|
|
|
struct SoundIoOutStreamPulseAudio {
|
|
|
|
pa_stream *stream;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoAtomicBool stream_ready;
|
2015-07-28 00:06:12 +00:00
|
|
|
pa_buffer_attr buffer_attr;
|
|
|
|
char *write_ptr;
|
2015-08-05 04:57:46 +00:00
|
|
|
size_t write_byte_count;
|
2015-12-05 13:25:44 +00:00
|
|
|
struct SoundIoAtomicFlag clear_buffer_flag;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
2015-07-28 00:06:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundIoInStreamPulseAudio {
|
|
|
|
pa_stream *stream;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoAtomicBool stream_ready;
|
2015-07-28 00:06:12 +00:00
|
|
|
pa_buffer_attr buffer_attr;
|
2015-08-05 04:57:46 +00:00
|
|
|
char *peek_buf;
|
|
|
|
size_t peek_buf_index;
|
|
|
|
size_t peek_buf_size;
|
|
|
|
int peek_buf_frames_left;
|
|
|
|
int read_frame_count;
|
2015-11-01 22:18:37 +00:00
|
|
|
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
2015-07-28 00:06:12 +00:00
|
|
|
};
|
|
|
|
|
2015-07-01 08:02:44 +00:00
|
|
|
#endif
|