Commit 5b36a527edabaccb481a88e4aaecbf0bd95315cf

Frank Praznik 2022-02-08T12:30:28

audio: pipewire: Remove redundant locks The io_list_check_add() and io_list_remove() functions are only ever called from within the Pipewire thread loop, so the locks are redundant. io_list_sort() is called from within a lock in the device detection function, so those additional locks are redundant as well.

diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index 8e48a22..0c1436f 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -275,8 +275,6 @@ io_list_check_add(struct io_node *node)
     struct io_node *n;
     SDL_bool        ret = SDL_TRUE;
 
-    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) {
@@ -294,8 +292,6 @@ io_list_check_add(struct io_node *node)
 
 dup_found:
 
-    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
-
     return ret;
 }
 
@@ -304,8 +300,6 @@ io_list_remove(Uint32 id)
 {
     struct io_node *n, *temp;
 
-    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) {
@@ -320,8 +314,6 @@ io_list_remove(Uint32 id)
             break;
         }
     }
-
-    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
 }
 
 static void
@@ -330,8 +322,6 @@ io_list_sort()
     struct io_node *default_sink = NULL, *default_source = NULL;
     struct io_node *n, *temp;
 
-    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) {
@@ -350,8 +340,6 @@ io_list_sort()
     if (default_sink) {
         spa_list_prepend(&hotplug_io_list, &default_sink->link);
     }
-
-    PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
 }
 
 static void