[vlc-devel] [PATCH] lib: add libvlc_audio_output_device_get()
Mark Lee
mark.lee at capricasoftware.co.uk
Tue Jan 27 11:58:02 CET 2015
This function gets the active device identifier for the current
audio output, if there is one, and is the complementary function
to libvlc_audio_output_device_set().
---
NEWS | 2 ++
include/vlc/libvlc_media_player.h | 24 ++++++++++++++++++++++++
lib/audio.c | 13 +++++++++++++
lib/libvlc.sym | 1 +
4 files changed, 40 insertions(+)
diff --git a/NEWS b/NEWS
index e290634..1e674f6 100644
--- a/NEWS
+++ b/NEWS
@@ -87,6 +87,8 @@ libVLC:
* Add libvlc_media_get_codec_description to get a human readable description of a codec
* Add libvlc_MediaListEndReached Event to get notified when a media list reached the end
* Add libvlc_media_parse_with_options that uses a flag to specify parse options
+ * Add libvlc_audio_output_device_get to get the currently selected audio output device
+ identifier (if there is one available)
Changes between 2.1.x and 2.2.0:
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 1c73cf2..48aadba 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1571,6 +1571,30 @@ LIBVLC_API void libvlc_audio_output_device_set( libvlc_media_player_t *mp,
const char *device_id );
/**
+ * Get the current audio output device identifier.
+ *
+ * This complements libvlc_audio_output_device_set().
+ *
+ * \warning The initial value for the current audio output device identifier
+ * may not be set or may be some unknown value. A LibVLC application should
+ * compare this value against the known device identifiers (e.g. those that
+ * were previously retrieved by a call to libvlc_audio_output_device_enum or
+ * libvlc_audio_output_device_list_get) to find the current audio output device.
+ *
+ * It is possible that the selected audio output device changes (an external
+ * change) without a call to libvlc_audio_output_device_set. That may make this
+ * method unsuitable to use if a LibVLC application is attempting to track
+ * dynamic audio device changes as they happen.
+ *
+ * \param mp media player
+ * \return the current audio output device identifier
+ * NULL if no device is selected or in case of error
+ * (the result must be released with free() or libvlc_free()).
+ * \version LibVLC 3.0.0 or later.
+ */
+LIBVLC_API char *libvlc_audio_output_device_get( libvlc_media_player_t *mp );
+
+/**
* Stub for backward compatibility.
* \return always -1.
*/
diff --git a/lib/audio.c b/lib/audio.c
index c919eb2..0165d16 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -277,6 +277,19 @@ void libvlc_audio_output_device_set( libvlc_media_player_t *mp,
vlc_object_release( aout );
}
+char *libvlc_audio_output_device_get( libvlc_media_player_t *mp )
+{
+ audio_output_t *aout = GetAOut( mp );
+ if( aout == NULL )
+ return NULL;
+
+ char *devid = aout_DeviceGet( aout );
+
+ vlc_object_release( aout );
+
+ return devid;
+}
+
int libvlc_audio_output_get_device_type( libvlc_media_player_t *mp )
{
(void) mp;
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 551e3b2..4fd2378 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -15,6 +15,7 @@ libvlc_audio_equalizer_release
libvlc_audio_equalizer_set_amp_at_index
libvlc_audio_equalizer_set_preamp
libvlc_audio_output_device_count
+libvlc_audio_output_device_get
libvlc_audio_output_device_enum
libvlc_audio_output_device_id
libvlc_audio_output_device_list_get
--
2.1.0
More information about the vlc-devel
mailing list