[vlc-devel] [PATCH v3 4/8] player: add on_device_changed callback
Romain Vimont
rom1v at videolabs.io
Mon May 20 17:52:38 CEST 2019
On Mon, May 20, 2019 at 06:43:38PM +0300, Rémi Denis-Courmont wrote:
> Looks OK but smwhy don't you use separate callback instead of matching the string?
Because the existing ones were done that way. Could be changed
separately. (I agree)
> Le 20 mai 2019 18:35:13 GMT+03:00, Romain Vimont <rom1v at videolabs.io> a écrit :
> >Expose the "device" event on the aout via a player callback.
> >---
> > include/vlc_player.h | 9 +++++++++
> > src/input/player.c | 11 +++++++++++
> > 2 files changed, 20 insertions(+)
> >
> >diff --git a/include/vlc_player.h b/include/vlc_player.h
> >index d4c49fa89d..054c4abae3 100644
> >--- a/include/vlc_player.h
> >+++ b/include/vlc_player.h
> >@@ -944,6 +944,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 e01701ba65..e81c717f36 100644
> >--- a/src/input/player.c
> >+++ b/src/input/player.c
> >@@ -3044,6 +3044,15 @@ vlc_player_AoutCallback(vlc_object_t *this,
> >const char *var,
> > vlc_player_vout_OSDVolume(player, true);
> > }
> > }
> >+ else if (strcmp(var, "device") == 0)
> >+ {
> >+ const char *old = oldval.psz_string;
> >+ const char *new = newval.psz_string;
> >+ /* support NULL values for string comparison */
> >+ if (old != new && (!old || !new || strcmp(old, new)))
> >+ vlc_player_aout_SendEvent(player, on_device_changed,
> >+ newval.psz_string);
> >+ }
> > else
> > vlc_assert_unreachable();
> >
> >@@ -3513,6 +3522,7 @@ vlc_player_New(vlc_object_t *parent, enum
> >vlc_player_lock_type lock_type,
> > {
> > 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);
> > }
> >@@ -3534,6 +3544,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)
> >--
> >2.20.1
> >
> >_______________________________________________
> >vlc-devel mailing list
> >To unsubscribe or modify your subscription options:
> >https://mailman.videolan.org/listinfo/vlc-devel
>
> --
> Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
> _______________________________________________
> 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