audio: pipewire: Tidy up formatting

This commit is contained in:
Frank Praznik 2022-02-08 13:29:40 -05:00 committed by Ethan Lee
parent 9da9e85cba
commit 228db35287

View file

@ -57,7 +57,7 @@
* This seems to be a sane lower limit as Pipewire * This seems to be a sane lower limit as Pipewire
* uses it in several of it's own modules. * uses it in several of it's own modules.
*/ */
#define PW_MIN_SAMPLES 32 /* About 0.67ms at 48kHz */ #define PW_MIN_SAMPLES 32 /* About 0.67ms at 48kHz */
#define PW_BASE_CLOCK_RATE 48000 #define PW_BASE_CLOCK_RATE 48000
#define PW_POD_BUFFER_LENGTH 1024 #define PW_POD_BUFFER_LENGTH 1024
@ -109,7 +109,7 @@ static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *,
#ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC #ifdef SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC
static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC; static const char *pipewire_library = SDL_AUDIO_DRIVER_PIPEWIRE_DYNAMIC;
static void * pipewire_handle = NULL; static void *pipewire_handle = NULL;
static int static int
pipewire_dlsym(const char *fn, void **addr) pipewire_dlsym(const char *fn, void **addr)
@ -254,9 +254,9 @@ struct io_node
/* The global hotplug thread and associated objects. */ /* The global hotplug thread and associated objects. */
static struct pw_thread_loop *hotplug_loop; static struct pw_thread_loop *hotplug_loop;
static struct pw_core * hotplug_core; static struct pw_core *hotplug_core;
static struct pw_context * hotplug_context; static struct pw_context *hotplug_context;
static struct pw_registry * hotplug_registry; static struct pw_registry *hotplug_registry;
static struct spa_hook hotplug_registry_listener; static struct spa_hook hotplug_registry_listener;
static struct spa_hook hotplug_core_listener; static struct spa_hook hotplug_core_listener;
static struct spa_list hotplug_pending_list; static struct spa_list hotplug_pending_list;
@ -398,7 +398,7 @@ pending_list_clear()
static void * static void *
node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events) node_object_new(Uint32 id, const char *type, Uint32 version, const void *funcs, const struct pw_core_events *core_events)
{ {
struct pw_proxy * proxy; struct pw_proxy *proxy;
struct node_object *node; struct node_object *node;
/* Create the proxy object */ /* Create the proxy object */
@ -442,7 +442,7 @@ static void
core_events_interface_callback(void *object, uint32_t id, int seq) core_events_interface_callback(void *object, uint32_t id, int seq)
{ {
struct node_object *node = object; struct node_object *node = object;
struct io_node * io = node->userdata; struct io_node *io = node->userdata;
if (id == PW_ID_CORE && seq == node->seq) { if (id == PW_ID_CORE && seq == node->seq) {
/* /*
@ -492,7 +492,7 @@ static SDL_bool
get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max) get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
{ {
const struct spa_pod_prop *prop; const struct spa_pod_prop *prop;
struct spa_pod * value; struct spa_pod *value;
Uint32 n_values, choice; Uint32 n_values, choice;
prop = spa_pod_find_prop(param, NULL, key); prop = spa_pod_find_prop(param, NULL, key);
@ -546,8 +546,8 @@ static void
node_event_info(void *object, const struct pw_node_info *info) node_event_info(void *object, const struct pw_node_info *info)
{ {
struct node_object *node = object; struct node_object *node = object;
struct io_node * io = node->userdata; struct io_node *io = node->userdata;
const char * prop_val; const char *prop_val;
Uint32 i; Uint32 i;
if (info) { if (info) {
@ -569,7 +569,7 @@ static void
node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param) node_event_param(void *object, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
{ {
struct node_object *node = object; struct node_object *node = object;
struct io_node * io = node->userdata; struct io_node *io = node->userdata;
/* Get the default frequency */ /* Get the default frequency */
if (io->spec.freq == 0) { if (io->spec.freq == 0) {
@ -622,7 +622,7 @@ registry_event_global_callback(void *object, uint32_t id, uint32_t permissions,
const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS); const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
if (media_class) { if (media_class) {
const char * node_desc; const char *node_desc;
struct io_node *io; struct io_node *io;
SDL_bool is_capture; SDL_bool is_capture;
int str_buffer_len; int str_buffer_len;
@ -800,14 +800,14 @@ static const enum spa_audio_channel PIPEWIRE_channel_map_4[] = { SPA_AUDIO_CHANN
SPA_AUDIO_CHANNEL_RR }; SPA_AUDIO_CHANNEL_RR };
static const enum spa_audio_channel PIPEWIRE_channel_map_5[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, static const enum spa_audio_channel PIPEWIRE_channel_map_5[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC,
SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR }; SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR };
static const enum spa_audio_channel PIPEWIRE_channel_map_6[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, static const enum spa_audio_channel PIPEWIRE_channel_map_6[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC,
SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR }; SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR };
static const enum spa_audio_channel PIPEWIRE_channel_map_7[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, static const enum spa_audio_channel PIPEWIRE_channel_map_7[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC,
SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RC, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RC, SPA_AUDIO_CHANNEL_RL,
SPA_AUDIO_CHANNEL_RR }; SPA_AUDIO_CHANNEL_RR };
static const enum spa_audio_channel PIPEWIRE_channel_map_8[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC, static const enum spa_audio_channel PIPEWIRE_channel_map_8[] = { SPA_AUDIO_CHANNEL_FL, SPA_AUDIO_CHANNEL_FR, SPA_AUDIO_CHANNEL_FC,
SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR, SPA_AUDIO_CHANNEL_LFE, SPA_AUDIO_CHANNEL_RL, SPA_AUDIO_CHANNEL_RR,
SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR }; SPA_AUDIO_CHANNEL_SL, SPA_AUDIO_CHANNEL_SR };
#define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c)) #define COPY_CHANNEL_MAP(c) SDL_memcpy(info->position, PIPEWIRE_channel_map_##c, sizeof(PIPEWIRE_channel_map_##c))
@ -882,9 +882,9 @@ initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info_raw *info)
static void static void
output_callback(void *data) output_callback(void *data)
{ {
struct pw_buffer * pw_buf; struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf; struct spa_buffer *spa_buf;
Uint8 * dst; Uint8 *dst;
_THIS = (SDL_AudioDevice *)data; _THIS = (SDL_AudioDevice *)data;
struct pw_stream *stream = this->hidden->stream; struct pw_stream *stream = this->hidden->stream;
@ -951,9 +951,9 @@ output_callback(void *data)
static void static void
input_callback(void *data) input_callback(void *data)
{ {
struct pw_buffer * pw_buf; struct pw_buffer *pw_buf;
struct spa_buffer *spa_buf; struct spa_buffer *spa_buf;
Uint8 * src; Uint8 *src;
_THIS = (SDL_AudioDevice *)data; _THIS = (SDL_AudioDevice *)data;
struct pw_stream *stream = this->hidden->stream; struct pw_stream *stream = this->hidden->stream;
@ -1015,8 +1015,8 @@ stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
* If they exceed the maximum size of the Pipewire buffer, double buffering will be used. * If they exceed the maximum size of the Pipewire buffer, double buffering will be used.
*/ */
if (this->spec.size > buffer->buffer->datas[0].maxsize) { if (this->spec.size > buffer->buffer->datas[0].maxsize) {
this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride; this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride;
this->spec.size = buffer->buffer->datas[0].maxsize; this->spec.size = buffer->buffer->datas[0].maxsize;
} }
} else if (this->hidden->buffer == NULL) { } else if (this->hidden->buffer == NULL) {
/* /*
@ -1054,9 +1054,9 @@ static const struct pw_stream_events stream_output_events = { PW_VERSION_STREAM_
.add_buffer = stream_add_buffer_callback, .add_buffer = stream_add_buffer_callback,
.process = output_callback }; .process = output_callback };
static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_EVENTS, static const struct pw_stream_events stream_input_events = { PW_VERSION_STREAM_EVENTS,
.state_changed = stream_state_changed_callback, .state_changed = stream_state_changed_callback,
.add_buffer = stream_add_buffer_callback, .add_buffer = stream_add_buffer_callback,
.process = input_callback }; .process = input_callback };
static int static int
PIPEWIRE_OpenDevice(_THIS, const char *devname) PIPEWIRE_OpenDevice(_THIS, const char *devname)
@ -1074,10 +1074,10 @@ PIPEWIRE_OpenDevice(_THIS, const char *devname)
Uint8 pod_buffer[PW_POD_BUFFER_LENGTH]; Uint8 pod_buffer[PW_POD_BUFFER_LENGTH];
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(pod_buffer, sizeof(pod_buffer)); struct spa_pod_builder b = SPA_POD_BUILDER_INIT(pod_buffer, sizeof(pod_buffer));
struct spa_audio_info_raw spa_info = { 0 }; struct spa_audio_info_raw spa_info = { 0 };
const struct spa_pod * params = NULL; const struct spa_pod *params = NULL;
struct SDL_PrivateAudioData *priv; struct SDL_PrivateAudioData *priv;
struct pw_properties * props; struct pw_properties *props;
const char * app_name, *stream_name, *stream_role, *error; const char *app_name, *stream_name, *stream_role, *error;
const Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); const Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle);
SDL_bool iscapture = this->iscapture; SDL_bool iscapture = this->iscapture;
int res; int res;