Commit fc15c20e authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

libvlc: expose event for audio output device change

parent a8ffc3b8
...@@ -82,6 +82,7 @@ enum libvlc_event_e { ...@@ -82,6 +82,7 @@ enum libvlc_event_e {
libvlc_MediaPlayerMuted, libvlc_MediaPlayerMuted,
libvlc_MediaPlayerUnmuted, libvlc_MediaPlayerUnmuted,
libvlc_MediaPlayerAudioVolume, libvlc_MediaPlayerAudioVolume,
libvlc_MediaPlayerAudioDevice,
libvlc_MediaListItemAdded=0x200, libvlc_MediaListItemAdded=0x200,
libvlc_MediaListWillAddItem, libvlc_MediaListWillAddItem,
...@@ -250,6 +251,11 @@ typedef struct libvlc_event_t ...@@ -250,6 +251,11 @@ typedef struct libvlc_event_t
{ {
float volume; float volume;
} media_player_audio_volume; } media_player_audio_volume;
struct
{
const char *device;
} media_player_audio_device;
} u; /**< Type-dependent event description */ } u; /**< Type-dependent event description */
} libvlc_event_t; } libvlc_event_t;
......
...@@ -288,6 +288,7 @@ static const event_name_t event_list[] = { ...@@ -288,6 +288,7 @@ static const event_name_t event_list[] = {
DEF(MediaPlayerMuted) DEF(MediaPlayerMuted)
DEF(MediaPlayerUnmuted) DEF(MediaPlayerUnmuted)
DEF(MediaPlayerAudioVolume) DEF(MediaPlayerAudioVolume)
DEF(MediaPlayerAudioDevice)
DEF(MediaListItemAdded) DEF(MediaListItemAdded)
DEF(MediaListWillAddItem) DEF(MediaListWillAddItem)
......
...@@ -491,6 +491,19 @@ static int corks_changed(vlc_object_t *obj, const char *name, vlc_value_t old, ...@@ -491,6 +491,19 @@ static int corks_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
return VLC_SUCCESS; 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, static int mute_changed(vlc_object_t *obj, const char *name, vlc_value_t old,
vlc_value_t cur, void *opaque) vlc_value_t cur, void *opaque)
{ {
...@@ -702,8 +715,10 @@ libvlc_media_player_new( libvlc_instance_t *instance ) ...@@ -702,8 +715,10 @@ libvlc_media_player_new( libvlc_instance_t *instance )
register_event(mp, Muted); register_event(mp, Muted);
register_event(mp, Unmuted); register_event(mp, Unmuted);
register_event(mp, AudioVolume); register_event(mp, AudioVolume);
register_event(mp, AudioDevice);
var_AddCallback(mp, "corks", corks_changed, NULL); 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, "mute", mute_changed, NULL);
var_AddCallback(mp, "volume", volume_changed, NULL); var_AddCallback(mp, "volume", volume_changed, NULL);
...@@ -759,6 +774,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi ) ...@@ -759,6 +774,7 @@ static void libvlc_media_player_destroy( libvlc_media_player_t *p_mi )
/* Detach callback from the media player / input manager object */ /* Detach callback from the media player / input manager object */
var_DelCallback( p_mi, "volume", volume_changed, NULL ); var_DelCallback( p_mi, "volume", volume_changed, NULL );
var_DelCallback( p_mi, "mute", mute_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 ); var_DelCallback( p_mi, "corks", corks_changed, NULL );
/* No need for lock_input() because no other threads knows us anymore */ /* No need for lock_input() because no other threads knows us anymore */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment