yolobs-studio/libobs/audio-monitoring/pulse/pulseaudio-enum-devices.c

33 lines
773 B
C
Raw Permalink Normal View History

2018-02-19 19:54:37 +00:00
#include <obs-internal.h>
#include "pulseaudio-wrapper.h"
static void pulseaudio_output_info(pa_context *c, const pa_source_info *i,
2019-09-22 21:19:10 +00:00
int eol, void *userdata)
2018-02-19 19:54:37 +00:00
{
UNUSED_PARAMETER(c);
if (eol != 0 || i->monitor_of_sink == PA_INVALID_INDEX)
goto skip;
2019-09-22 21:19:10 +00:00
struct enum_cb *ecb = (struct enum_cb *)userdata;
2018-02-19 19:54:37 +00:00
if (ecb->cont)
ecb->cont = ecb->cb(ecb->data, i->description, i->name);
skip:
pulseaudio_signal(0);
}
2019-09-22 21:19:10 +00:00
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb, void *data)
2018-02-19 19:54:37 +00:00
{
struct enum_cb *ecb = bzalloc(sizeof(struct enum_cb));
ecb->cb = cb;
ecb->data = data;
ecb->cont = 1;
pulseaudio_init();
pa_source_info_cb_t pa_cb = pulseaudio_output_info;
2019-09-22 21:19:10 +00:00
pulseaudio_get_source_info_list(pa_cb, (void *)ecb);
2018-02-19 19:54:37 +00:00
pulseaudio_unref();
bfree(ecb);
}