[vlc-commits] libvlc: expose events for the audio mute status (refs #14568)
Rémi Denis-Courmont
git at videolan.org
Tue Jul 28 09:05:46 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 27 14:00:08 2015 +0300| [09bea7fa994ce66fcfe68efd7fd03f5ba4dc5f36] | committer: Rémi Denis-Courmont
libvlc: expose events for the audio mute status (refs #14568)
Cc: Harald Sitter <sitter at kde.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=09bea7fa994ce66fcfe68efd7fd03f5ba4dc5f36
---
include/vlc/libvlc_events.h | 2 ++
lib/event.c | 2 ++
lib/media_player.c | 25 +++++++++++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 171b8d5..a997d22 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -79,6 +79,8 @@ enum libvlc_event_e {
libvlc_MediaPlayerESSelected,
libvlc_MediaPlayerCorked,
libvlc_MediaPlayerUncorked,
+ libvlc_MediaPlayerMuted,
+ libvlc_MediaPlayerUnmuted,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
diff --git a/lib/event.c b/lib/event.c
index b164376..f26af5c 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -285,6 +285,8 @@ static const event_name_t event_list[] = {
DEF(MediaPlayerESSelected)
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 462dceb..1075586 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -71,6 +71,10 @@ static int
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 void
add_es_callbacks( input_thread_t *p_input_thread, libvlc_media_player_t *p_mi );
@@ -483,6 +487,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.
*
@@ -660,8 +681,11 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, ESSelected);
register_event(mp, Corked);
register_event(mp, Uncorked);
+ register_event(mp, Muted);
+ register_event(mp, Unmuted);
var_AddCallback(mp, "corks", corks_changed, NULL);
+ var_AddCallback(mp, "mute", mute_changed, NULL);
/* Snapshot initialization */
register_event(mp, SnapshotTaken);
@@ -713,6 +737,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