[vlc-commits] libvlc_media_player: create the aout when first setting audio options

Thomas Guillem git at videolan.org
Thu Jun 25 19:08:46 CEST 2015


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jun 24 18:23:33 2015 +0200| [1d7c55982727b20796e0d5f95434ea02b4e23614] | committer: Thomas Guillem

libvlc_media_player: create the aout when first setting audio options

If not setting any audio options, the aout will be created by the decoder
thread.

This avoids to create an audio output that will be destroyed if you change it
with libvlc_audio_output_set.

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

 lib/audio.c        |   17 +++++++++++------
 lib/media_player.c |    4 ----
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/audio.c b/lib/audio.c
index 7901c64..262c8d9 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -51,7 +51,17 @@ static audio_output_t *GetAOut( libvlc_media_player_t *mp )
 
     audio_output_t *p_aout = input_resource_HoldAout( mp->input.p_resource );
     if( p_aout == NULL )
-        libvlc_printerr( "No active audio output" );
+    {
+        p_aout = input_resource_GetAout( mp->input.p_resource );
+        if( p_aout != NULL )
+        {
+            input_resource_PutAout( mp->input.p_resource, p_aout );
+            p_aout = input_resource_HoldAout( mp->input.p_resource );
+        }
+        else
+            libvlc_printerr( "No active audio output" );
+    }
+
     return p_aout;
 }
 
@@ -133,11 +143,6 @@ int libvlc_audio_output_set( libvlc_media_player_t *mp, const char *psz_name )
     /* Forget the existing audio output */
     input_resource_ResetAout(mp->input.p_resource);
 
-    /* Create a new audio output */
-    audio_output_t *aout = input_resource_GetAout(mp->input.p_resource);
-    if( aout != NULL )
-        input_resource_PutAout(mp->input.p_resource, aout);
-
     return 0;
 }
 
diff --git a/lib/media_player.c b/lib/media_player.c
index f35c0cb..885c3f1 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -595,10 +595,6 @@ libvlc_media_player_new( libvlc_instance_t *instance )
         vlc_object_release(mp);
         return NULL;
     }
-    audio_output_t *aout = input_resource_GetAout(mp->input.p_resource);
-    if( aout != NULL )
-        input_resource_PutAout(mp->input.p_resource, aout);
-
     vlc_mutex_init (&mp->input.lock);
     mp->i_refcount = 1;
     mp->p_event_manager = libvlc_event_manager_new(mp, instance);



More information about the vlc-commits mailing list