[vlc-commits] player: refactor aout first initialisation

Thomas Guillem git at videolan.org
Fri Jul 24 09:16:21 CEST 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul 22 15:41:51 2020 +0200| [77c5b2d4467a3f7c918b28654e9511be34a5ebeb] | committer: Thomas Guillem

player: refactor aout first initialisation

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=77c5b2d4467a3f7c918b28654e9511be34a5ebeb
---

 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 8d19d04ba2..840d0e01fe 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 d70e9fe672..fd072e414b 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 9d0182b2ac..87b9e43033 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



More information about the vlc-commits mailing list