[vlc-devel] [PATCH] libvlc_media_player: create the audio output on first play

Thomas Guillem thomas at gllm.fr
Thu Jun 25 10:58:28 CEST 2015



On Wed, Jun 24, 2015, at 18:38, Rémi Denis-Courmont wrote:
> Le 2015-06-24 19:30, Thomas Guillem a écrit :
> > This avoids to create an audio output that will be destroyed if you 
> > change it
> > with libvlc_audio_output_set.
> > ---
> >  lib/audio.c                 |  7 +++----
> >  lib/media_player.c          | 15 +++++++++++----
> >  lib/media_player_internal.h |  1 +
> >  3 files changed, 15 insertions(+), 8 deletions(-)
> >
> > diff --git a/lib/audio.c b/lib/audio.c
> > index 7901c64..1fdbc56 100644
> > --- a/lib/audio.c
> > +++ b/lib/audio.c
> > @@ -130,13 +130,12 @@ int libvlc_audio_output_set(
> > libvlc_media_player_t *mp, const char *psz_name )
> >      var_SetString( mp, "aout", value );
> >      free( value );
> >
> > +    vlc_mutex_lock(&mp->object_lock);
> >      /* 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);
> > +    mp->b_aout_init = false;
> > +    vlc_mutex_unlock(&mp->object_lock);
> 
> This breaks volume before play.
> 
> >
> >      return 0;
> >  }
> > diff --git a/lib/media_player.c b/lib/media_player.c
> > index b57acc0..d0f6d10 100644
> > --- a/lib/media_player.c
> > +++ b/lib/media_player.c
> > @@ -599,11 +599,8 @@ 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->b_aout_init = false;
> >      mp->i_refcount = 1;
> >      mp->p_event_manager = libvlc_event_manager_new(mp, instance);
> >      if (unlikely(mp->p_event_manager == NULL))
> > @@ -843,6 +840,16 @@ int libvlc_media_player_play(
> > libvlc_media_player_t *p_mi )
> >      /* Ignore previous exception */
> >      lock(p_mi);
> >
> > +    if( !p_mi->b_aout_init )
> > +    {
> > +        /* Create a new audio output */
> > +        audio_output_t *aout =
> > input_resource_GetAout(p_mi->input.p_resource);
> > +        if( aout != NULL )
> > +            input_resource_PutAout(p_mi->input.p_resource, aout);
> > +
> > +        p_mi->b_aout_init = true;
> > +    }
> 
> And this is utterly pointless, as the decoder will create the missing 
> aout anyhow

Indeed, this patch is wrong, I'll propose an other one.

> 
> > +
> >      if( !p_mi->p_md )
> >      {
> >          unlock(p_mi);
> > diff --git a/lib/media_player_internal.h 
> > b/lib/media_player_internal.h
> > index 27fbf1f..3c073e4 100644
> > --- a/lib/media_player_internal.h
> > +++ b/lib/media_player_internal.h
> > @@ -54,6 +54,7 @@ struct libvlc_media_player_t
> >      libvlc_media_t * p_md; /* current media descriptor */
> >      libvlc_event_manager_t * p_event_manager;
> >      libvlc_state_t state;
> > +    bool b_aout_init;
> >  };
> >
> >  /* Media player - audio, video */
> 
> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list