mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
Merge pull request #2913 from lakkatv/master
Copy alsa device list implementation to alsathread
This commit is contained in:
commit
28cc81bfe7
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <lists/string_list.h>
|
||||||
|
|
||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
#include <rthreads/rthreads.h>
|
#include <rthreads/rthreads.h>
|
||||||
@ -342,6 +344,64 @@ static size_t alsa_thread_buffer_size(void *data)
|
|||||||
return alsa->buffer_size;
|
return alsa->buffer_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *alsa_device_list_new(void *data)
|
||||||
|
{
|
||||||
|
void **hints, **n;
|
||||||
|
union string_list_elem_attr attr;
|
||||||
|
struct string_list *s = string_list_new();
|
||||||
|
|
||||||
|
if (!s)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
attr.i = 0;
|
||||||
|
|
||||||
|
if (snd_device_name_hint(-1, "pcm", &hints) != 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
n = hints;
|
||||||
|
|
||||||
|
while (*n != NULL)
|
||||||
|
{
|
||||||
|
char *name = snd_device_name_get_hint(*n, "NAME");
|
||||||
|
char *io = snd_device_name_get_hint(*n, "IOID");
|
||||||
|
char *desc = snd_device_name_get_hint(*n, "DESC");
|
||||||
|
|
||||||
|
/* description of device IOID - input / output identifcation
|
||||||
|
* ("Input" or "Output"), NULL means both) */
|
||||||
|
|
||||||
|
if (io == NULL)
|
||||||
|
string_list_append(s, name, attr);
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
free(name);
|
||||||
|
if (io)
|
||||||
|
free(io);
|
||||||
|
if (desc)
|
||||||
|
free(desc);
|
||||||
|
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free hint buffer too */
|
||||||
|
snd_device_name_free_hint(hints);
|
||||||
|
|
||||||
|
return s;
|
||||||
|
|
||||||
|
error:
|
||||||
|
string_list_free(s);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void alsa_device_list_free(void *data, void *array_list_data)
|
||||||
|
{
|
||||||
|
struct string_list *s = (struct string_list*)array_list_data;
|
||||||
|
|
||||||
|
if (!s)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string_list_free(s);
|
||||||
|
}
|
||||||
|
|
||||||
audio_driver_t audio_alsathread = {
|
audio_driver_t audio_alsathread = {
|
||||||
alsa_thread_init,
|
alsa_thread_init,
|
||||||
alsa_thread_write,
|
alsa_thread_write,
|
||||||
@ -352,8 +412,8 @@ audio_driver_t audio_alsathread = {
|
|||||||
alsa_thread_free,
|
alsa_thread_free,
|
||||||
alsa_thread_use_float,
|
alsa_thread_use_float,
|
||||||
"alsathread",
|
"alsathread",
|
||||||
NULL,
|
alsa_device_list_new,
|
||||||
NULL,
|
alsa_device_list_free,
|
||||||
alsa_thread_write_avail,
|
alsa_thread_write_avail,
|
||||||
alsa_thread_buffer_size,
|
alsa_thread_buffer_size,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user