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

audio: support for enumerating devices of current aoout (fixes #10720)

parent b90f1b90
......@@ -1473,6 +1473,27 @@ char *libvlc_audio_output_device_longname( libvlc_instance_t *, const char *,
LIBVLC_DEPRECATED LIBVLC_API
char *libvlc_audio_output_device_id( libvlc_instance_t *, const char *, int );
/**
* Gets a list of potential audio output devices,
* \see libvlc_audio_output_device_set().
*
* \note Not all audio outputs support enumerating devices.
* The audio output may be functional even if the list is empty (NULL).
*
* \note The list may not be exhaustive.
*
* \warning Some audio output devices in the list might not actually work in
* some circumstances. By default, it is recommended to not specify any
* explicit audio device.
*
* \param mp media player
* \return A NULL-terminated linked list of potential audio output devices.
* It must be freed it with libvlc_audio_output_device_list_release()
* \version LibVLC 2.2.0 or later.
*/
LIBVLC_API libvlc_audio_output_device_t *
libvlc_audio_output_device_enum( libvlc_media_player_t *mp );
/**
* Gets a list of audio output devices for a given audio output module,
* \see libvlc_audio_output_device_set().
......@@ -1514,6 +1535,9 @@ LIBVLC_API void libvlc_audio_output_device_list_release(
* specified by the device identifier string immediately. This is the
* recommended usage.
*
* A list of adequate potential device strings can be obtained with
* libvlc_audio_output_device_enum().
*
* However passing NULL is supported in LibVLC version 2.2.0 and later only;
* in earlier versions, this function would have no effects when the module
* parameter was NULL.
......
......@@ -139,6 +139,42 @@ int libvlc_audio_output_set( libvlc_media_player_t *mp, const char *psz_name )
return 0;
}
libvlc_audio_output_device_t *
libvlc_audio_output_device_enum( libvlc_media_player_t *mp )
{
audio_output_t *aout = GetAOut( mp );
if( aout == NULL )
return NULL;
libvlc_audio_output_device_t *list = NULL, **pp = &list;
char **values, **texts;
int n = aout_DevicesList( aout, &values, &texts );
if( n < 0 )
goto err;
for (int i = 0; i < n; i++)
{
libvlc_audio_output_device_t *item = malloc( sizeof(*item) );
if( unlikely(item == NULL) )
{
free( texts[i] );
free( values[i] );
continue;
}
*pp = item;
pp = &item->p_next;
item->psz_device = values[i];
item->psz_description = texts[i];
}
free( texts );
free( values );
err:
return list;
}
libvlc_audio_output_device_t *
libvlc_audio_output_device_list_get( libvlc_instance_t *p_instance,
const char *aout )
......
......@@ -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_enum
libvlc_audio_output_device_id
libvlc_audio_output_device_list_get
libvlc_audio_output_device_list_release
......
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