[vlc-commits] libvlc: expose events for the audio mute status (refs #14568)
Rémi Denis-Courmont
git at videolan.org
Mon Jul 27 15:45:08 CEST 2015
vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 27 14:00:08 2015 +0300| [0efcbbc983e167a1b7ccd8594653af1758824565] | committer: Jean-Baptiste Kempf
libvlc: expose events for the audio mute status (refs #14568)
Cc: Harald Sitter <sitter at kde.org>
(cherry picked from commit 2f3c3ca8c604f50ca9ae7da4487c73a70a75d82c)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=0efcbbc983e167a1b7ccd8594653af1758824565
---
include/vlc/libvlc_events.h | 2 ++
lib/event.c | 2 ++
lib/media_player.c | 23 +++++++++++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index fa6b738..1102209 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -76,6 +76,8 @@ enum libvlc_event_e {
libvlc_MediaPlayerScrambledChanged,
libvlc_MediaPlayerCorked = libvlc_MediaPlayerScrambledChanged + 3 + 1,
libvlc_MediaPlayerUncorked,
+ libvlc_MediaPlayerMuted,
+ libvlc_MediaPlayerUnmuted,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
diff --git a/lib/event.c b/lib/event.c
index 8ae3b8c..a17eade 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -283,6 +283,8 @@ static const event_name_t event_list[] = {
DEF(MediaPlayerScrambledChanged)
DEF(MediaPlayerCorked)
DEF(MediaPlayerUncorked)
+ DEF(MediaPlayerMuted)
+ DEF(MediaPlayerUnmuted)
DEF(MediaListItemAdded)
DEF(MediaListWillAddItem)
diff --git a/lib/media_player.c b/lib/media_player.c
index 8938965..b23ac3a 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -62,6 +62,10 @@ corks_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
vlc_value_t cur, void *opaque);
static int
+mute_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
+ vlc_value_t cur, void *opaque);
+
+static int
snapshot_was_taken( vlc_object_t *p_this, char const *psz_cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data );
@@ -389,6 +393,23 @@ static int corks_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
return VLC_SUCCESS;
}
+static int mute_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
+ vlc_value_t cur, void *opaque)
+{
+ libvlc_media_player_t *mp = (libvlc_media_player_t *)obj;
+
+ if (old.b_bool != cur.b_bool)
+ {
+ libvlc_event_t event;
+
+ event.type = cur.b_bool ? libvlc_MediaPlayerMuted
+ : libvlc_MediaPlayerUnmuted;
+ libvlc_event_send(mp->p_event_manager, &event);
+ }
+ VLC_UNUSED(name); VLC_UNUSED(opaque);
+ return VLC_SUCCESS;
+}
+
/**************************************************************************
* Create a Media Instance object.
*
@@ -563,6 +584,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, Uncorked);
var_AddCallback(mp, "corks", corks_changed, NULL);
+ var_AddCallback(mp, "mute", mute_changed, NULL);
/* Snapshot initialization */
register_event(mp, SnapshotTaken);
@@ -614,6 +636,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
"snapshot-file", snapshot_was_taken, p_mi );
/* Detach callback from the media player / input manager object */
+ var_DelCallback( p_mi, "mute", mute_changed, NULL );
var_DelCallback( p_mi, "corks", corks_changed, NULL );
/* No need for lock_input() because no other threads knows us anymore */
More information about the vlc-commits
mailing list