[vlc-devel] [PATCH 3/5] player: refactor aout first initialisation

Thomas Guillem thomas at gllm.fr
Wed Jul 22 15:51:09 CEST 2020


---
 src/player/aout.c   | 22 ++++++++++++++++++++--
 src/player/player.c | 11 +++--------
 src/player/player.h |  6 +++---
 3 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/player/aout.c b/src/player/aout.c
index 8d19d04ba20..840d0e01fec 100644
--- a/src/player/aout.c
+++ b/src/player/aout.c
@@ -192,7 +192,7 @@ vlc_player_aout_EnableFilter(vlc_player_t *player, const char *name, bool add)
 }
 
 
-void
+static void
 vlc_player_aout_AddCallbacks(vlc_player_t *player)
 {
     audio_output_t *aout = vlc_player_aout_Hold(player);
@@ -206,7 +206,7 @@ vlc_player_aout_AddCallbacks(vlc_player_t *player)
     aout_Release(aout);
 }
 
-void
+static void
 vlc_player_aout_DelCallbacks(vlc_player_t *player)
 {
     audio_output_t *aout = vlc_player_aout_Hold(player);
@@ -219,3 +219,21 @@ vlc_player_aout_DelCallbacks(vlc_player_t *player)
 
     aout_Release(aout);
 }
+
+audio_output_t *
+vlc_player_aout_Init(vlc_player_t *player)
+{
+    audio_output_t *aout = input_resource_GetAout(player->resource);
+    if (aout != NULL)
+    {
+        vlc_player_aout_AddCallbacks(player);
+        input_resource_PutAout(player->resource, aout);
+    }
+    return aout;
+}
+
+void
+vlc_player_aout_Deinit(vlc_player_t *player)
+{
+    vlc_player_aout_DelCallbacks(player);
+}
diff --git a/src/player/player.c b/src/player/player.c
index d70e9fe672e..fd072e414b5 100644
--- a/src/player/player.c
+++ b/src/player/player.c
@@ -1909,7 +1909,7 @@ vlc_player_Delete(vlc_player_t *player)
 
     vlc_player_DestroyTimer(player);
 
-    vlc_player_aout_DelCallbacks(player);
+    vlc_player_aout_Deinit(player);
     var_DelCallback(player, "corks", vlc_player_CorkCallback, player);
 
     input_resource_Release(player->resource);
@@ -1998,12 +1998,7 @@ vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,
         goto error;
 
     /* Ensure the player has a valid aout */
-    aout = input_resource_GetAout(player->resource);
-    if (aout != NULL)
-    {
-        vlc_player_aout_AddCallbacks(player);
-        input_resource_PutAout(player->resource, aout);
-    }
+    aout = vlc_player_aout_Init(player);
     var_AddCallback(player, "corks", vlc_player_CorkCallback, player);
 
     player->deleting = false;
@@ -2021,7 +2016,7 @@ vlc_player_New(vlc_object_t *parent, enum vlc_player_lock_type lock_type,
 
 error:
     if (aout)
-        vlc_player_aout_DelCallbacks(player);
+        vlc_player_aout_Deinit(player);
     var_DelCallback(player, "corks", vlc_player_CorkCallback, player);
     if (player->resource)
         input_resource_Release(player->resource);
diff --git a/src/player/player.h b/src/player/player.h
index 9d0182b2ace..87b9e430330 100644
--- a/src/player/player.h
+++ b/src/player/player.h
@@ -467,11 +467,11 @@ vlc_player_vout_DelCallbacks(vlc_player_t *player, vout_thread_t *vout);
  * player_aout.c
  */
 
-void
-vlc_player_aout_AddCallbacks(vlc_player_t *player);
+audio_output_t *
+vlc_player_aout_Init(vlc_player_t *player);
 
 void
-vlc_player_aout_DelCallbacks(vlc_player_t *player);
+vlc_player_aout_Deinit(vlc_player_t *player);
 
 /*
  * player_osd.c
-- 
2.27.0



More information about the vlc-devel mailing list