[vlc-devel] [PATCH 1/5] player: add on_device_changed callback

Thomas Guillem thomas at gllm.fr
Thu May 9 18:14:05 CEST 2019


YOu can then remove the hack done on "audio-device" variables.

On Thu, May 9, 2019, at 18:13, Rémi Denis-Courmont wrote:
> Le torstaina 9. toukokuuta 2019, 18.56.54 EEST Romain Vimont a écrit :
> > Expose the "device" event on the aout via a player callback.
> > ---
> >  include/vlc_player.h | 9 +++++++++
> >  src/input/player.c   | 8 ++++++++
> >  2 files changed, 17 insertions(+)
> > 
> > diff --git a/include/vlc_player.h b/include/vlc_player.h
> > index 17e927c948..fdd2709ac3 100644
> > --- a/include/vlc_player.h
> > +++ b/include/vlc_player.h
> > @@ -923,6 +923,15 @@ struct vlc_player_aout_cbs
> >       */
> >      void (*on_mute_changed)(vlc_player_t *player,
> >          bool new_muted, void *data);
> > +
> > +    /**
> > +     * Called when the audio device has changed
> > +     *
> > +     * @param player unlocked player instance
> > +     * @param device the device name
> > +     */
> > +    void (*on_device_changed)(vlc_player_t *player, const char *device,
> > +                              void *data);
> >  };
> > 
> >  /**
> > diff --git a/src/input/player.c b/src/input/player.c
> > index f43f9f71a5..2045028aab 100644
> > --- a/src/input/player.c
> > +++ b/src/input/player.c
> > @@ -3043,6 +3043,12 @@ vlc_player_AoutCallback(vlc_object_t *this, const
> > char *var, vlc_player_vout_OSDVolume(player, true);
> >          }
> >      }
> > +    else if (strcmp(var, "device") == 0)
> > +    {
> > +        if (strcmp(oldval.psz_string, newval.psz_string) != 0)
> > +            vlc_player_aout_SendEvent(player, on_device_changed,
> > +                                      newval.psz_string);
> > +    }
> 
> Not a huge fan of muxing callbacks only to demux them back again.
> 
> >      else
> >          vlc_assert_unreachable();
> > 
> > @@ -3569,6 +3575,7 @@ vlc_player_New(vlc_object_t *parent,
> >      {
> >          var_AddCallback(aout, "volume", vlc_player_AoutCallback, player);
> >          var_AddCallback(aout, "mute", vlc_player_AoutCallback, player);
> > +        var_AddCallback(aout, "device", vlc_player_AoutCallback, player);
> >          var_AddCallback(player, "corks", vlc_player_CorkCallback, NULL);
> >          input_resource_PutAout(player->resource, aout);
> >      }
> > @@ -3590,6 +3597,7 @@ error:
> >      {
> >          var_DelCallback(aout, "volume", vlc_player_AoutCallback, player);
> >          var_DelCallback(aout, "mute", vlc_player_AoutCallback, player);
> > +        var_DelCallback(aout, "device", vlc_player_AoutCallback, player);
> >          var_DelCallback(player, "corks", vlc_player_AoutCallback, NULL);
> >      }
> >      if (player->resource)
> 
> 
> -- 
> 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