SDL: audio: pipewire: Add vim format lines to files and fix indentation

From 7001b531c6c5517d8e0c2824675d11d926afb3d8 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sat, 27 Feb 2021 12:53:08 -0500
Subject: [PATCH] audio: pipewire: Add vim format lines to files and fix
 indentation

Increase indentation spacing from 2 to 4 to comply with style standards.
---
 src/audio/pipewire/SDL_pipewire.c | 1477 ++++++++++++++---------------
 src/audio/pipewire/SDL_pipewire.h |   12 +-
 2 files changed, 745 insertions(+), 744 deletions(-)

diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 68dac925d..b4ec9f49d 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -38,7 +38,7 @@
 #define PW_MIN_SAMPLES 32   /* About 0.67ms at 48kHz */
 #define PW_MAX_SAMPLES 8192 /* About 170.6ms at 48kHz */
 
-#define PW_POD_BUFFER_LENGTH 1024
+#define PW_POD_BUFFER_LENGTH         1024
 #define PW_THREAD_NAME_BUFFER_LENGTH 128
 
 #define PW_ID_TO_HANDLE(x) (void *)((uintptr_t)x)
@@ -86,37 +86,37 @@ static void *      pipewire_handle  = NULL;
 static int
 pipewire_dlsym(const char *fn, void **addr)
 {
-  *addr = SDL_LoadFunction(pipewire_handle, fn);
-  if (*addr == NULL) {
-    /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
-    return 0;
-  }
+    *addr = SDL_LoadFunction(pipewire_handle, fn);
+    if (*addr == NULL) {
+        /* Don't call SDL_SetError(): SDL_LoadFunction already did. */
+        return 0;
+    }
 
-  return 1;
+    return 1;
 }
 
-#define SDL_PIPEWIRE_SYM(x)                                                                                                        \
-  if (!pipewire_dlsym(#x, (void **)(char *)&PIPEWIRE_##x)) {                                                                       \
-    return -1;                                                                                                                     \
-  }
+#define SDL_PIPEWIRE_SYM(x)                                    \
+    if (!pipewire_dlsym(#x, (void **)(char *)&PIPEWIRE_##x)) { \
+        return -1;                                             \
+    }
 
 static int
 load_pipewire_library()
 {
-  if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
-    return 0;
-  }
+    if ((pipewire_handle = SDL_LoadObject(pipewire_library))) {
+        return 0;
+    }
 
-  return -1;
+    return -1;
 }
 
 static void
 unload_pipewire_library()
 {
-  if (pipewire_handle) {
-    SDL_UnloadObject(pipewire_handle);
-    pipewire_handle = NULL;
-  }
+    if (pipewire_handle) {
+        SDL_UnloadObject(pipewire_handle);
+        pipewire_handle = NULL;
+    }
 }
 
 #else
@@ -126,7 +126,7 @@ unload_pipewire_library()
 static int
 load_pipewire_library()
 {
-  return 0;
+    return 0;
 }
 
 static void
@@ -139,90 +139,90 @@ unload_pipewire_library()
 static int
 load_pipewire_syms()
 {
-  SDL_PIPEWIRE_SYM(pw_init);
-  SDL_PIPEWIRE_SYM(pw_deinit);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_new);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_destroy);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_stop);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_get_loop);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_lock);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_unlock);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_signal);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_wait);
-  SDL_PIPEWIRE_SYM(pw_thread_loop_start);
-  SDL_PIPEWIRE_SYM(pw_context_new);
-  SDL_PIPEWIRE_SYM(pw_context_destroy);
-  SDL_PIPEWIRE_SYM(pw_context_connect);
-  SDL_PIPEWIRE_SYM(pw_proxy_add_object_listener);
-  SDL_PIPEWIRE_SYM(pw_proxy_get_user_data);
-  SDL_PIPEWIRE_SYM(pw_proxy_destroy);
-  SDL_PIPEWIRE_SYM(pw_core_disconnect);
-  SDL_PIPEWIRE_SYM(pw_stream_new_simple);
-  SDL_PIPEWIRE_SYM(pw_stream_destroy);
-  SDL_PIPEWIRE_SYM(pw_stream_connect);
-  SDL_PIPEWIRE_SYM(pw_stream_get_state);
-  SDL_PIPEWIRE_SYM(pw_stream_dequeue_buffer);
-  SDL_PIPEWIRE_SYM(pw_stream_queue_buffer);
-  SDL_PIPEWIRE_SYM(pw_properties_new);
-  SDL_PIPEWIRE_SYM(pw_properties_free);
-  SDL_PIPEWIRE_SYM(pw_properties_set);
-  SDL_PIPEWIRE_SYM(pw_properties_setf);
-
-  return 0;
+    SDL_PIPEWIRE_SYM(pw_init);
+    SDL_PIPEWIRE_SYM(pw_deinit);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_new);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_destroy);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_stop);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_get_loop);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_lock);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_unlock);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_signal);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_wait);
+    SDL_PIPEWIRE_SYM(pw_thread_loop_start);
+    SDL_PIPEWIRE_SYM(pw_context_new);
+    SDL_PIPEWIRE_SYM(pw_context_destroy);
+    SDL_PIPEWIRE_SYM(pw_context_connect);
+    SDL_PIPEWIRE_SYM(pw_proxy_add_object_listener);
+    SDL_PIPEWIRE_SYM(pw_proxy_get_user_data);
+    SDL_PIPEWIRE_SYM(pw_proxy_destroy);
+    SDL_PIPEWIRE_SYM(pw_core_disconnect);
+    SDL_PIPEWIRE_SYM(pw_stream_new_simple);
+    SDL_PIPEWIRE_SYM(pw_stream_destroy);
+    SDL_PIPEWIRE_SYM(pw_stream_connect);
+    SDL_PIPEWIRE_SYM(pw_stream_get_state);
+    SDL_PIPEWIRE_SYM(pw_stream_dequeue_buffer);
+    SDL_PIPEWIRE_SYM(pw_stream_queue_buffer);
+    SDL_PIPEWIRE_SYM(pw_properties_new);
+    SDL_PIPEWIRE_SYM(pw_properties_free);
+    SDL_PIPEWIRE_SYM(pw_properties_set);
+    SDL_PIPEWIRE_SYM(pw_properties_setf);
+
+    return 0;
 }
 
 static int
 init_pipewire_library()
 {
-  if (!load_pipewire_library()) {
-    if (!load_pipewire_syms()) {
-      PIPEWIRE_pw_init(NULL, NULL);
-      return 0;
+    if (!load_pipewire_library()) {
+        if (!load_pipewire_syms()) {
+            PIPEWIRE_pw_init(NULL, NULL);
+            return 0;
+        }
     }
-  }
 
-  return -1;
+    return -1;
 }
 
 static void
 deinit_pipewire_library()
 {
-  PIPEWIRE_pw_deinit();
-  unload_pipewire_library();
+    PIPEWIRE_pw_deinit();
+    unload_pipewire_library();
 }
 
 /* A generic Pipewire node object used for enumeration. */
 struct node_object
 {
-  struct spa_list link;
-
-  Uint32 id;
-  int    seq;
-
-  /*
-   * NOTE: If used, this is *must* be allocated with SDL_malloc() or similar
-   * as SDL_free() will be called on it when the node_object is destroyed.
-   *
-   * If ownership of the referenced memory is transferred, this must be set
-   * to NULL or the memory will be freed when the node_object is destroyed.
-   */
-  void *userdata;
-
-  struct pw_proxy *proxy;
-  struct spa_hook  node_listener;
-  struct spa_hook  core_listener;
+    struct spa_list link;
+
+    Uint32 id;
+    int    seq;
+
+    /*
+     * NOTE: If used, this is *must* be allocated with SDL_malloc() or similar
+     * as SDL_free() will be called on it when the node_object is destroyed.
+     *
+     * If ownership of the referenced memory is transferred, this must be set
+     * to NULL or the memory will be freed when the node_object is destroyed.
+     */
+    void *userdata;
+
+    struct pw_proxy *proxy;
+    struct spa_hook  node_listener;
+    struct spa_hook  core_listener;
 };
 
 /* A sink/source node used for stream I/O. */
 struct io_node
 {
-  struct spa_list link;
+    struct spa_list link;
 
-  Uint32        id;
-  SDL_bool      is_capture;
-  SDL_AudioSpec spec;
+    Uint32        id;
+    SDL_bool      is_capture;
+    SDL_AudioSpec spec;
 
-  char name[];
+    char name[];
 };
 
 /* The global hotplug thread and associated objects. */
@@ -245,214 +245,214 @@ Uint32 pipewire_default_source_id = SPA_ID_INVALID;
 static SDL_bool
 io_list_check_add(struct io_node *node)
 {
-  struct io_node *n;
-  SDL_bool        ret = SDL_TRUE;
+    struct io_node *n;
+    SDL_bool        ret = SDL_TRUE;
 
-  PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
 
-  /* See if the node is already in the list */
-  spa_list_for_each (n, &hotplug_io_list, link) {
-    if (n->id == node->id) {
-      ret = SDL_FALSE;
-      goto dup_found;
+    /* See if the node is already in the list */
+    spa_list_for_each (n, &hotplug_io_list, link) {
+        if (n->id == node->id) {
+            ret = SDL_FALSE;
+            goto dup_found;
+        }
     }
-  }
 
-  /* Add to the list if the node doesn't already exist */
-  spa_list_append(&hotplug_io_list, &node->link);
+    /* Add to the list if the node doesn't already exist */
+    spa_list_append(&hotplug_io_list, &node->link);
 
-  if (SDL_AtomicGet(&hotplug_events_enabled)) {
-    SDL_AddAudioDevice(node->is_capture, node->name, PW_ID_TO_HANDLE(node->id));
-  }
+    if (SDL_AtomicGet(&hotplug_events_enabled)) {
+        SDL_AddAudioDevice(node->is_capture, node->name, PW_ID_TO_HANDLE(node->id));
+    }
 
 dup_found:
 
-  PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
 
-  return ret;
+    return ret;
 }
 
 static void
 io_list_remove(Uint32 id)
 {
-  struct io_node *n, *temp;
+    struct io_node *n, *temp;
 
-  PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
 
-  /* Find and remove the node from the list */
-  spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
-    if (n->id == id) {
-      spa_list_remove(&n->link);
+    /* Find and remove the node from the list */
+    spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
+        if (n->id == id) {
+            spa_list_remove(&n->link);
 
-      if (SDL_AtomicGet(&hotplug_events_enabled)) {
-        SDL_RemoveAudioDevice(n->is_capture, PW_ID_TO_HANDLE(id));
-      }
+            if (SDL_AtomicGet(&hotplug_events_enabled)) {
+                SDL_RemoveAudioDevice(n->is_capture, PW_ID_TO_HANDLE(id));
+            }
 
-      SDL_free(n);
+            SDL_free(n);
 
-      break;
+            break;
+        }
     }
-  }
 
-  PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
 }
 
 static void
 io_list_sort()
 {
-  struct io_node *n, *temp, *default_sink, *default_source;
+    struct io_node *n, *temp, *default_sink, *default_source;
 
-  PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
 
-  /* Find and move the default nodes to the beginning of the list */
-  spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
-    if (n->id == pipewire_default_sink_id) {
-      default_sink = n;
-      spa_list_remove(&n->link);
-    } else if (n->id == pipewire_default_source_id) {
-      default_source = n;
-      spa_list_remove(&n->link);
+    /* Find and move the default nodes to the beginning of the list */
+    spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
+        if (n->id == pipewire_default_sink_id) {
+            default_sink = n;
+            spa_list_remove(&n->link);
+        } else if (n->id == pipewire_default_source_id) {
+            default_source = n;
+            spa_list_remove(&n->link);
+        }
     }
-  }
 
-  if (default_source) {
-    spa_list_prepend(&hotplug_io_list, &default_source->link);
-  }
+    if (default_source) {
+        spa_list_prepend(&hotplug_io_list, &default_source->link);
+    }
 
-  if (default_sink) {
-    spa_list_prepend(&hotplug_io_list, &default_sink->link);
-  }
+    if (default_sink) {
+        spa_list_prepend(&hotplug_io_list, &default_sink->link);
+    }
 
-  PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
+    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
 }
 
 static void
 io_list_clear()
 {
-  struct io_node *n, *temp;
+    struct io_node *n, *temp;
 
-  spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
-    spa_list_remove(&n->link);
-    SDL_free(n);
-  }
+    spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
+        spa_list_remove(&n->link);
+        SDL_free(n);
+    }
 }
 
 static void
 node_object_destroy(struct node_object *node)
 {
-  SDL_assert(node);
+    SDL_assert(node);
 
-  spa_list_remove(&node->link);
-  spa_hook_remove(&node->node_listener);
-  spa_hook_remove(&node->core_listener);
-  SDL_free(node->userdata);
-  PIPEWIRE_pw_proxy_destroy(node->proxy);
+    spa_list_remove(&node->link);
+    spa_hook_remove(&node->node_listener);
+    spa_hook_remove(&node->core_listener);
+    SDL_free(node->userdata);
+    PIPEWIRE_pw_proxy_destroy(node->proxy);
 }
 
 /* The pending node list */
 static void
 pending_list_add(struct node_object *node)
 {
-  SDL_assert(node);
-  spa_list_append(&hotplug_pending_list, &node->link);
+    SDL_assert(node);
+    spa_list_append(&hotplug_pending_list, &node->link);
 }
 
 static void
 pending_list_remove(Uint32 id)
 {
-  struct node_object *node, *temp;
+    struct node_object *node, *temp;
 
-  spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) {
-    if (node->id == id) {
-      node_object_destroy(node);
+    spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) {
+        if (node->id == id) {
+            node_object_destroy(node);
+        }
     }
-  }
 }
 
 static void
 pending_list_clear()
 {
-  struct node_object *node, *temp;
+    struct node_object *node, *temp;
 
-  spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) {
-    node_object_destroy(node);
-  }
+    spa_list_for_each_safe (node, temp, &hotplug_pending_list, link) {
+        node_object_destroy(node);
+    }
 }
 
 static void *
 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 node_object *node;
-
-  /* Create the proxy object */
-  proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object));
-  if (proxy == NULL) {
-    SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno);
-    return NULL;
-  }
+    struct pw_proxy *   proxy;
+    struct node_object *node;
+
+    /* Create the proxy object */
+    proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object));
+    if (proxy == NULL) {
+        SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno);
+        return NULL;
+    }
 
-  node = PIPEWIRE_pw_proxy_get_user_data(proxy);
-  SDL_zerop(node);
+    node = PIPEWIRE_pw_proxy_get_user_data(proxy);
+    SDL_zerop(node);
 
-  node->id    = id;
-  node->proxy = proxy;
+    node->id    = id;
+    node->proxy = proxy;
 
-  /* Add the callbacks */
-  pw_core_add_listener(hotplug_core, &node->core_listener, core_events, node);
-  PIPEWIRE_pw_proxy_add_object_listener(node->proxy, &node->node_listener, funcs, node);
+    /* Add the callbacks */
+    pw_core_add_listener(hotplug_core, &node->core_listener, core_events, node);
+    PIPEWIRE_pw_proxy_add_object_listener(node->proxy, &node->node_listener, funcs, node);
 
-  /* Add the node to the active list */
-  pending_list_add(node);
+    /* Add the node to the active list */
+    pending_list_add(node);
 
-  return node;
+    return node;
 }
 
 /* Core sync points */
 static void
 core_events_hotplug_init_callback(void *object, uint32_t id, int seq)
 {
-  if (id == PW_ID_CORE && seq == hotplug_init_seq_val) {
-    PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
+    if (id == PW_ID_CORE && seq == hotplug_init_seq_val) {
+        PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
 
-    /* This core listener is no longer needed. */
-    spa_hook_remove(&hotplug_core_listener);
+        /* This core listener is no longer needed. */
+        spa_hook_remove(&hotplug_core_listener);
 
-    /* Signal that the initial I/O list is populated */
-    SDL_AtomicSet(&hotplug_init_complete, 1);
-    PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false);
+        /* Signal that the initial I/O list is populated */
+        SDL_AtomicSet(&hotplug_init_complete, 1);
+        PIPEWIRE_pw_thread_loop_signal(hotplug_loop, false);
 
-    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
-  }
+        PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
+    }
 }
 
 static void
 core_events_interface_callback(void *object, uint32_t id, int seq)
 {
-  struct node_object *node = object;
-  struct io_node *    io   = node->userdata;
+    struct node_object *node = object;
+    struct io_node *    io   = node->userdata;
+
+    if (id == PW_ID_CORE && seq == node->seq) {
+        /*
+         * Move the I/O node to the connected list.
+         * On success, the list owns the I/O node object.
+         */
+        if (io_list_check_add(io)) {
+            node->userdata = NULL;
+        }
 
-  if (id == PW_ID_CORE && seq == node->seq) {
-    /*
-     * Move the I/O node to the connected list.
-     * On success, the list owns the I/O node object.
-     */
-    if (io_list_check_add(io)) {
-      node->userdata = NULL;
+        node_object_destroy(node);
     }
-
-    node_object_destroy(node);
-  }
 }
 
 static void
 core_events_metadata_callback(void *object, uint32_t id, int seq)
 {
-  struct node_object *node = object;
+    struct node_object *node = object;
 
-  if (id == PW_ID_CORE && seq == node->seq) {
-    node_object_destroy(node);
-  }
+    if (id == PW_ID_CORE && seq == node->seq) {
+        node_object_destroy(node);
+    }
 }
 
 const struct pw_core_events hotplug_init_core_events = { PW_VERSION_CORE_EVENTS, .done = core_events_hotplug_init_callback };
@@ -462,120 +462,120 @@ const struct pw_core_events metadata_core_events     = { PW_VERSION_CORE_EVENTS,
 static void
 hotplug_core_sync(struct node_object *node)
 {
-  /*
-   * Node sync events *must* come before the hotplug init sync events or the initial
-   * I/O list will be incomplete when the main hotplug sync point is hit.
-   */
-  if (node) {
-    node->seq = pw_core_sync(hotplug_core, PW_ID_CORE, node->seq);
-  }
-
-  if (!SDL_AtomicGet(&hotplug_init_complete)) {
-    hotplug_init_seq_val = pw_core_sync(hotplug_core, PW_ID_CORE, hotplug_init_seq_val);
-  }
+    /*
+     * Node sync events *must* come before the hotplug init sync events or the initial
+     * I/O list will be incomplete when the main hotplug sync point is hit.
+     */
+    if (node) {
+        node->seq = pw_core_sync(hotplug_core, PW_ID_CORE, node->seq);
+    }
+
+    if (!SDL_AtomicGet(&hotplug_init_complete)) {
+        hotplug_init_seq_val = pw_core_sync(hotplug_core, PW_ID_CORE, hotplug_init_seq_val);
+    }
 }
 
 /* Helpers for retrieving values from params */
 static SDL_bool
 get_range_param(const struct spa_pod *param, Uint32 key, int *def, int *min, int *max)
 {
-  const struct spa_pod_prop *prop;
-  struct spa_pod *           value;
-  Uint32                     n_values, choice;
-
-  prop = spa_pod_find_prop(param, NULL, key);
-
-  if (prop && prop->value.type == SPA_TYPE_Choice) {
-    value = spa_pod_get_values(&prop->value, &n_values, &choice);
-
-    if (n_values == 3 && choice == SPA_CHOICE_Range) {
-      Uint32 *v = SPA_POD_BODY(value);
-
-      if (v) {
-        if (def) {
-          *def = (int)v[0];
-        }
-        if (min) {
-          *min = (int)v[1];
-        }
-        if (max) {
-          *max = (int)v[2];
+    const struct spa_pod_prop *prop;
+    struct spa_pod *           value;
+    Uint32                     n_values, choice;
+
+    prop = spa_pod_find_prop(param, NULL, key);
+
+    if (prop && prop->value.type == SPA_TYPE_Choice) {
+        value = spa_pod_get_values(&prop->value, &n_values, &choice);
+
+        if (n_values == 3 && choice == SPA_CHOICE_Range) {
+            Uint32 *v = SPA_POD_BODY(value);
+
+            if (v) {
+                if (def) {
+                    *def = (int)v[0];
+                }
+                if (min) {
+                    *min = (int)v[1];
+                }
+                if (max) {
+                    *max = (int)v[2];
+                }
+
+                return SDL_TRUE;
+            }
         }
-
-        return SDL_TRUE;
-      }
     }
-  }
 
-  return SDL_FALSE;
+    return SDL_FALSE;
 }
 
 static SDL_bool
 get_int_param(const struct spa_pod *param, Uint32 key, int *val)
 {
-  const struct spa_pod_prop *prop;
-  Sint32                     v;
+    const struct spa_pod_prop *prop;
+    Sint32                     v;
 
-  prop = spa_pod_find_prop(param, NULL, key);
+    prop = spa_pod_find_prop(param, NULL, key);
 
-  if (prop && prop->value.type == SPA_TYPE_Int) {
-    spa_pod_get_int(&prop->value, &v);
+    if (prop && prop->value.type == SPA_TYPE_Int) {
+        spa_pod_get_int(&prop->value, &v);
 
-    if (val) {
-      *val = (int)v;
-    }
+        if (val) {
+            *val = (int)v;
+        }
 
-    return SDL_TRUE;
-  }
+        return SDL_TRUE;
+    }
 
-  return SDL_FALSE;
+    return SDL_FALSE;
 }
 
 /* Interface node callbacks */
 static void
 node_event_info(void *object, const struct pw_node_info *info)
 {
-  struct node_object *node = object;
-  struct io_node *    io   = node->userdata;
-  const char *        prop_val;
-  Uint32              i;
+    struct node_object *node = object;
+    struct io_node *    io   = node->userdata;
+    const char *        prop_val;
+    Uint32              i;
+
+    if (info) {
+        prop_val = spa_dict_lookup(info->props, PW_KEY_AUDIO_CHANNELS);
+        if (prop_val) {
+            io->spec.channels = (Uint8)SDL_atoi(prop_val);
+        }
 
-  if (info) {
-    prop_val = spa_dict_lookup(info->props, PW_KEY_AUDIO_CHANNELS);
-    if (prop_val) {
-      io->spec.channels = (Uint8)SDL_atoi(prop_val);
-    }
+        /* Need to parse the parameters to get the sample rate */
+        for (i = 0; i < info->n_params; ++i) {
+            pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL);
+        }
 
-    /* Need to parse the parameters to get the sample rate */
-    for (i = 0; i < info->n_params; ++i) {
-      pw_node_enum_params(node->proxy, 0, info->params[i].id, 0, 0, NULL);
+        hotplug_core_sync(node);
     }
-
-    hotplug_core_sync(node);
-  }
 }
 
 static void
 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 io_node *    io   = node->userdata;
-
-  /* Get the default frequency */
-  if (io->spec.freq == 0) {
-    get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL);
-  }
-
-  /*
-   * The channel count should have come from the node properties,
-   * but it is stored here as well. If one failed, try the other.
-   */
-  if (io->spec.channels == 0) {
-    int channels;
-    if (get_int_param(param, SPA_FORMAT_AUDIO_channels, &channels)) {
-      io->spec.channels = (Uint8)channels;
-    }
-  }
+    struct node_object *node = object;
+    struct io_node *    io   = node->userdata;
+
+    /* Get the default frequency */
+    if (io->spec.freq == 0) {
+        get_range_param(param, SPA_FORMAT_AUDIO_rate, &io->spec.freq, NULL, NULL);
+    }
+
+    /*
+     * The channel count should have come from the node properties,
+     * but it is stored here as well. If one failed, try the other.
+     */
+    if (io->spec.channels == 0) {
+        int channels;
+        if (get_int_param(param, SPA_FORMAT_AUDIO_channels, &channels)) {
+            io->spec.channels = (Uint8)channels;
+        }
+    }
 }
 
 static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVENTS, .info = node_event_info,
@@ -585,17 +585,17 @@ static const struct pw_node_events interface_node_events = { PW_VERSION_NODE_EVE
 static int
 metadata_property(void *object, Uint32 subject, const char *key, const char *type, const char *value)
 {
-  if (subject == PW_ID_CORE && key != NULL && value != NULL) {
-    Uint32 val = SDL_atoi(value);
+    if (subject == PW_ID_CORE && key != NULL && value != NULL) {
+        Uint32 val = SDL_atoi(value);
 
-    if (!SDL_strcmp(key, "default.audio.sink")) {
-      pipewire_default_sink_id = val;
-    } else if (!SDL_strcmp(key, "default.audio.source")) {
-      pipewire_default_source_id = val;
+        if (!SDL_strcmp(key, "default.audio.sink")) {
+            pipewire_default_sink_id = val;
+        } else if (!SDL_strcmp(key, "default.audio.source")) {
+            pipewire_default_source_id = val;
+        }
     }
-  }
 
-  return 0;
+    return 0;
 }
 
 static const struct pw_metadata_events metadata_node_events = { PW_VERSION_METADATA_EVENTS, .property = metadata_property };
@@ -605,73 +605,73 @@ static void
 registry_event_global_callback(void *object, uint32_t id, uint32_t permissions, const char *type, uint32_t version,
                                const struct spa_dict *props)
 {
-  struct node_object *node;
-
-  /* We're only interested in interface and metadata nodes. */
-  if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Node)) {
-    const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
-
-    if (media_class) {
-      const char *    node_nick, *node_desc;
-      struct io_node *io;
-      SDL_bool        is_capture;
-      int             str_buffer_len;
-
-      /* Just want sink and capture */
-      if (!SDL_strcasecmp(media_class, "Audio/Sink")) {
-        is_capture = SDL_FALSE;
-      } else if (!SDL_strcasecmp(media_class, "Audio/Source")) {
-        is_capture = SDL_TRUE;
-      } else {
-        return;
-      }
-
-      node_nick = spa_dict_lookup(props, PW_KEY_NODE_NICK);
-      node_desc = spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION);
-
-      if (node_nick && node_desc) {
-        node = node_object_new(id, type, version, &interface_node_events, &interface_core_events);
-        if (node == NULL) {
-          SDL_SetError("Pipewire: Failed to allocate interface node");
-          return;
+    struct node_object *node;
+
+    /* We're only interested in interface and metadata nodes. */
+    if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Node)) {
+        const char *media_class = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
+
+        if (media_class) {
+            const char *    node_nick, *node_desc;
+            struct io_node *io;
+            SDL_bool        is_capture;
+            int             str_buffer_len;
+
+            /* Just want sink and capture */
+            if (!SDL_strcasecmp(media_class, "Audio/Sink")) {
+                is_capture = SDL_FALSE;
+            } else if (!SDL_strcasecmp(media_class, "Audio/Source")) {
+                is_capture = SDL_TRUE;
+            } else {
+                return;
+            }
+
+            node_nick = spa_dict_lookup(props, PW_KEY_NODE_NICK);
+            node_desc = spa_dict_lookup(props, PW_KEY_NODE_DESCRIPTION);
+
+            if (node_nick && node_desc) {
+                node = node_object_new(id, type, version, &interface_node_events, &interface_core_events);
+                if (node == NULL) {
+                    SDL_SetError("Pipewire: Failed to allocate interface node");
+                    return;
+                }
+
+                /* Allocate and initialize the I/O node information struct */
+                str_buffer_len = SDL_strlen(node_nick) + SDL_strlen(node_desc) + 3;
+                node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + str_buffer_len);
+                if (io == NULL) {
+                    node_object_destroy(node);
+                    SDL_OutOfMemory();
+                    return;
+                }
+
+                /* Begin setting the node properties */
+                io->id          = id;
+                io->is_capture  = is_capture;
+                io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */
+                SDL_snprintf(io->name, str_buffer_len, "%s: %s", node_nick, node_desc);
+
+                /* Update sync points */
+                hotplug_core_sync(node);
+            }
         }
-
-        /* Allocate and initialize the I/O node information struct */
-        str_buffer_len = SDL_strlen(node_nick) + SDL_strlen(node_desc) + 3;
-        node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + str_buffer_len);
-        if (io == NULL) {
-          node_object_destroy(node);
-          SDL_OutOfMemory();
-          return;
+    } else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) {
+        node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events);
+        if (node == NULL) {
+            SDL_SetError("Pipewire: Failed to allocate metadata node");
+            return;
         }
 
-        /* Begin setting the node properties */
-        io->id          = id;
-        io->is_capture  = is_capture;
-        io->spec.format = AUDIO_F32; /* Pipewire uses floats internally, other formats require conversion. */
-        SDL_snprintf(io->name, str_buffer_len, "%s: %s", node_nick, node_desc);
-
         /* Update sync points */
         hotplug_core_sync(node);
-      }
     }
-  } else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) {
-    node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events);
-    if (node == NULL) {
-      SDL_SetError("Pipewire: Failed to allocate metadata node");
-      return;
-    }
-
-    /* Update sync points */
-    hotplug_core_sync(node);
-  }
 }
 
 static void
 registry_event_remove_callback(void *object, uint32_t id)
 {
-  io_list_remove(id);
-  pending_list_remove(id);
+    io_list_remove(id);
+    pending_list_remove(id);
 }
 
 static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_EVENTS, .global = registry_event_global_callback,
@@ -681,111 +681,108 @@ static const struct pw_registry_events registry_events = { PW_VERSION_REGISTRY_E
 static int
 hotplug_loop_init()
 {
-  int res;
+    int res;
 
-  spa_list_init(&hotplug_pending_list);
-  spa_list_init(&hotplug_io_list);
+    spa_list_init(&hotplug_pending_list);
+    spa_list_init(&hotplug_io_list);
 
-  hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL);
-  if (hotplug_loop == NULL) {
-    return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno);
-  }
+    hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL);
+    if (hotplug_loop == NULL) {
+        return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno);
+    }
 
-  hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0);
-  if (hotplug_context == NULL) {
-    return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno);
-  }
+    hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0);
+    if (hotplug_context == NULL) {
+        return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno);
+    }
 
-  hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0);
-  if (hotplug_core == NULL) {
-    return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno);
-  }
+    hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0);
+    if (hotplug_core == NULL) {
+        return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno);
+    }
 
-  hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0);
-  if (hotplug_registry == NULL) {
-    return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno);
-  }
+    hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0);
+    if (hotplug_registry == NULL) {
+        return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno);
+    }
 
-  spa_zero(hotplug_registry_listener);
-  pw_registry_add_listener(hotplug_registry, &hotplug_registry_listener, &registry_events, NULL);
+    spa_zero(hotplug_registry_listener);
+    pw_registry_add_listener(hotplug_registry, &hotplug_registry_listener, &registry_events, NULL);
 
-  spa_zero(hotplug_core_listener);
-  pw_core_add_listener(hotplug_core, &hotplug_core_listener, &hotplug_init_core_events, NULL);
+    spa_zero(hotplug_core_listener);
+    pw_core_add_listener(hotplug_core, 

(Patch may be truncated, please check the link at the top of this post.)