[vlc-commits] libvlc: expose event for audio output device change
Rémi Denis-Courmont
git at videolan.org
Mon Jul 27 15:36:11 CEST 2015
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 27 16:30:33 2015 +0300| [7e64f62b0b05e6e9313a79e40ae5c38a22d6b9d7] | committer: Rémi Denis-Courmont
libvlc: expose event for audio output device change
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7e64f62b0b05e6e9313a79e40ae5c38a22d6b9d7
---
include/vlc/libvlc_events.h | 6 ++++++
lib/event.c | 1 +
lib/media_player.c | 15 +++++++++++++++
3 files changed, 22 insertions(+)
diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
index 3ee57c1..a770b06 100644
--- a/include/vlc/libvlc_events.h
+++ b/include/vlc/libvlc_events.h
@@ -82,6 +82,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerMuted,
libvlc_MediaPlayerUnmuted,
libvlc_MediaPlayerAudioVolume,
+ libvlc_MediaPlayerAudioDevice,
libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem,
@@ -250,6 +251,11 @@ typedef struct libvlc_event_t
{
float volume;
} media_player_audio_volume;
+
+ struct
+ {
+ const char *device;
+ } media_player_audio_device;
} u; /**< Type-dependent event description */
} libvlc_event_t;
diff --git a/lib/event.c b/lib/event.c
index b13fc92..7b42c53 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -288,6 +288,7 @@ static const event_name_t event_list[] = {
DEF(MediaPlayerMuted)
DEF(MediaPlayerUnmuted)
DEF(MediaPlayerAudioVolume)
+ DEF(MediaPlayerAudioDevice)
DEF(MediaListItemAdded)
DEF(MediaListWillAddItem)
diff --git a/lib/media_player.c b/lib/media_player.c
index 9a687d5..778ef80 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -491,6 +491,19 @@ static int corks_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
return VLC_SUCCESS;
}
+static int audio_device_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;
+ libvlc_event_t event;
+
+ event.type = libvlc_MediaPlayerAudioDevice;
+ event.u.media_player_audio_device.device = cur.psz_string;
+ libvlc_event_send(mp->p_event_manager, &event);
+ VLC_UNUSED(name); VLC_UNUSED(old); VLC_UNUSED(opaque);
+ return VLC_SUCCESS;
+}
+
static int mute_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
vlc_value_t cur, void *opaque)
{
@@ -701,6 +714,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, Uncorked);
var_AddCallback(mp, "corks", corks_changed, NULL);
+ var_AddCallback(mp, "audio-device", audio_device_changed, NULL);
var_AddCallback(mp, "mute", mute_changed, NULL);
var_AddCallback(mp, "volume", volume_changed, NULL);
@@ -756,6 +770,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
/* Detach callback from the media player / input manager object */
var_DelCallback( p_mi, "volume", volume_changed, NULL );
var_DelCallback( p_mi, "mute", mute_changed, NULL );
+ var_DelCallback( p_mi, "audio-device", audio_device_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