SDL: audio: pipewire: Don't double free properties on init failure

From 0b34f18045a1ea89b06fc9c71dc828e8c257fb30 Mon Sep 17 00:00:00 2001
From: Frank Praznik <[EMAIL REDACTED]>
Date: Sun, 30 Jan 2022 12:00:55 -0500
Subject: [PATCH] audio: pipewire: Don't double free properties on init failure

The context and stream creation functions will destroy the passed properties object on failure, so no need to do it manually.

The pw_properties_free() function pointer is no longer needed, so it can be removed.
---
 src/audio/pipewire/SDL_pipewire.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 5a10b28a8f1..5c6e10495ca 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -100,7 +100,6 @@ static enum pw_stream_state (*PIPEWIRE_pw_stream_get_state)(struct pw_stream *st
 static struct pw_buffer *(*PIPEWIRE_pw_stream_dequeue_buffer)(struct pw_stream *);
 static int (*PIPEWIRE_pw_stream_queue_buffer)(struct pw_stream *, struct pw_buffer *);
 static struct pw_properties *(*PIPEWIRE_pw_properties_new)(const char *, ...)SPA_SENTINEL;
-static void (*PIPEWIRE_pw_properties_free)(struct pw_properties *);
 static int (*PIPEWIRE_pw_properties_set)(struct pw_properties *, const char *, const char *);
 static int (*PIPEWIRE_pw_properties_setf)(struct pw_properties *, const char *, const char *, ...) SPA_PRINTF_FUNC(3, 4);
 
@@ -190,7 +189,6 @@ load_pipewire_syms()
     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);
 
@@ -1129,10 +1127,8 @@ PIPEWIRE_OpenDevice(_THIS, const char *devname)
         return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno);
     }
 
-    /* On success, the context owns the properties object and will free it at destruction time. */
     priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0);
     if (priv->context == NULL) {
-        PIPEWIRE_pw_properties_free(props);
         return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno);
     }
 
@@ -1151,14 +1147,10 @@ PIPEWIRE_OpenDevice(_THIS, const char *devname)
     PIPEWIRE_pw_properties_setf(props, PW_KEY_NODE_RATE, "1/%u", this->spec.freq);
     PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_ALWAYS_PROCESS, "true");
 
-    /*
-     * Create the new stream
-     * On success, the stream owns the properties object and will free it at destruction time.
-     */
+    /* Create the new stream */
     priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props,
                                                  iscapture ? &stream_input_events : &stream_output_events, this);
     if (priv->stream == NULL) {
-        PIPEWIRE_pw_properties_free(props);
         return SDL_SetError("Pipewire: Failed to create stream (%i)", errno);
     }