New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -2,13 +2,13 @@
|
|||
#include "pulseaudio-wrapper.h"
|
||||
|
||||
static void pulseaudio_output_info(pa_context *c, const pa_source_info *i,
|
||||
int eol, void *userdata)
|
||||
int eol, void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
if (eol != 0 || i->monitor_of_sink == PA_INVALID_INDEX)
|
||||
goto skip;
|
||||
|
||||
struct enum_cb *ecb = (struct enum_cb *) userdata;
|
||||
struct enum_cb *ecb = (struct enum_cb *)userdata;
|
||||
if (ecb->cont)
|
||||
ecb->cont = ecb->cb(ecb->data, i->description, i->name);
|
||||
|
||||
|
|
@ -16,8 +16,7 @@ skip:
|
|||
pulseaudio_signal(0);
|
||||
}
|
||||
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
||||
void *data)
|
||||
void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb, void *data)
|
||||
{
|
||||
struct enum_cb *ecb = bzalloc(sizeof(struct enum_cb));
|
||||
ecb->cb = cb;
|
||||
|
|
@ -26,7 +25,7 @@ void obs_enum_audio_monitoring_devices(obs_enum_audio_device_cb cb,
|
|||
|
||||
pulseaudio_init();
|
||||
pa_source_info_cb_t pa_cb = pulseaudio_output_info;
|
||||
pulseaudio_get_source_info_list(pa_cb, (void *) ecb);
|
||||
pulseaudio_get_source_info_list(pa_cb, (void *)ecb);
|
||||
pulseaudio_unref();
|
||||
|
||||
bfree(ecb);
|
||||
|
|
|
|||
|
|
@ -5,47 +5,56 @@
|
|||
#define blog(level, msg, ...) blog(level, "pulse-am: " msg, ##__VA_ARGS__)
|
||||
|
||||
struct audio_monitor {
|
||||
obs_source_t *source;
|
||||
pa_stream *stream;
|
||||
char *device;
|
||||
pa_buffer_attr attr;
|
||||
enum speaker_layout speakers;
|
||||
pa_sample_format_t format;
|
||||
uint_fast32_t samples_per_sec;
|
||||
uint_fast32_t bytes_per_frame;
|
||||
uint_fast8_t channels;
|
||||
obs_source_t *source;
|
||||
pa_stream *stream;
|
||||
char *device;
|
||||
pa_buffer_attr attr;
|
||||
enum speaker_layout speakers;
|
||||
pa_sample_format_t format;
|
||||
uint_fast32_t samples_per_sec;
|
||||
uint_fast32_t bytes_per_frame;
|
||||
uint_fast8_t channels;
|
||||
|
||||
uint_fast32_t packets;
|
||||
uint_fast64_t frames;
|
||||
uint_fast32_t packets;
|
||||
uint_fast64_t frames;
|
||||
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t bytesRemaining;
|
||||
size_t bytes_per_channel;
|
||||
struct circlebuf new_data;
|
||||
audio_resampler_t *resampler;
|
||||
size_t buffer_size;
|
||||
size_t bytesRemaining;
|
||||
size_t bytes_per_channel;
|
||||
|
||||
bool ignore;
|
||||
pthread_mutex_t playback_mutex;
|
||||
bool ignore;
|
||||
pthread_mutex_t playback_mutex;
|
||||
};
|
||||
|
||||
static enum speaker_layout pulseaudio_channels_to_obs_speakers(
|
||||
uint_fast32_t channels)
|
||||
static enum speaker_layout
|
||||
pulseaudio_channels_to_obs_speakers(uint_fast32_t channels)
|
||||
{
|
||||
switch (channels) {
|
||||
case 0: return SPEAKERS_UNKNOWN;
|
||||
case 1: return SPEAKERS_MONO;
|
||||
case 2: return SPEAKERS_STEREO;
|
||||
case 3: return SPEAKERS_2POINT1;
|
||||
case 4: return SPEAKERS_4POINT0;
|
||||
case 5: return SPEAKERS_4POINT1;
|
||||
case 6: return SPEAKERS_5POINT1;
|
||||
case 8: return SPEAKERS_7POINT1;
|
||||
default: return SPEAKERS_UNKNOWN;
|
||||
case 0:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
case 1:
|
||||
return SPEAKERS_MONO;
|
||||
case 2:
|
||||
return SPEAKERS_STEREO;
|
||||
case 3:
|
||||
return SPEAKERS_2POINT1;
|
||||
case 4:
|
||||
return SPEAKERS_4POINT0;
|
||||
case 5:
|
||||
return SPEAKERS_4POINT1;
|
||||
case 6:
|
||||
return SPEAKERS_5POINT1;
|
||||
case 8:
|
||||
return SPEAKERS_7POINT1;
|
||||
default:
|
||||
return SPEAKERS_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
static enum audio_format pulseaudio_to_obs_audio_format(
|
||||
pa_sample_format_t format)
|
||||
static enum audio_format
|
||||
pulseaudio_to_obs_audio_format(pa_sample_format_t format)
|
||||
{
|
||||
switch (format) {
|
||||
case PA_SAMPLE_U8:
|
||||
|
|
@ -118,7 +127,7 @@ static pa_channel_map pulseaudio_channel_map(enum speaker_layout layout)
|
|||
|
||||
static void process_byte(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register char *cur = (char *) p;
|
||||
register char *cur = (char *)p;
|
||||
register char *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -127,7 +136,7 @@ static void process_byte(void *p, size_t frames, size_t channels, float vol)
|
|||
|
||||
static void process_short(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register short *cur = (short *) p;
|
||||
register short *cur = (short *)p;
|
||||
register short *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -136,7 +145,7 @@ static void process_short(void *p, size_t frames, size_t channels, float vol)
|
|||
|
||||
static void process_float(void *p, size_t frames, size_t channels, float vol)
|
||||
{
|
||||
register float *cur = (float *) p;
|
||||
register float *cur = (float *)p;
|
||||
register float *end = cur + frames * channels;
|
||||
|
||||
while (cur < end)
|
||||
|
|
@ -144,20 +153,20 @@ static void process_float(void *p, size_t frames, size_t channels, float vol)
|
|||
}
|
||||
|
||||
void process_volume(const struct audio_monitor *monitor, float vol,
|
||||
uint8_t *const *resample_data, uint32_t resample_frames)
|
||||
uint8_t *const *resample_data, uint32_t resample_frames)
|
||||
{
|
||||
switch (monitor->bytes_per_channel) {
|
||||
case 1:
|
||||
process_byte(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
case 2:
|
||||
process_short(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
default:
|
||||
process_float(resample_data[0], resample_frames,
|
||||
monitor->channels, vol);
|
||||
monitor->channels, vol);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -168,20 +177,20 @@ static void do_stream_write(void *param)
|
|||
uint8_t *buffer = NULL;
|
||||
|
||||
while (data->new_data.size >= data->buffer_size &&
|
||||
data->bytesRemaining > 0) {
|
||||
data->bytesRemaining > 0) {
|
||||
size_t bytesToFill = data->buffer_size;
|
||||
|
||||
if (bytesToFill > data->bytesRemaining)
|
||||
bytesToFill = data->bytesRemaining;
|
||||
|
||||
pa_stream_begin_write(data->stream, (void **) &buffer,
|
||||
&bytesToFill);
|
||||
pa_stream_begin_write(data->stream, (void **)&buffer,
|
||||
&bytesToFill);
|
||||
|
||||
circlebuf_pop_front(&data->new_data, buffer, bytesToFill);
|
||||
|
||||
pulseaudio_lock();
|
||||
pa_stream_write(data->stream, buffer, bytesToFill, NULL,
|
||||
0LL, PA_SEEK_RELATIVE);
|
||||
pa_stream_write(data->stream, buffer, bytesToFill, NULL, 0LL,
|
||||
PA_SEEK_RELATIVE);
|
||||
pulseaudio_unlock();
|
||||
|
||||
data->bytesRemaining -= bytesToFill;
|
||||
|
|
@ -189,7 +198,7 @@ static void do_stream_write(void *param)
|
|||
}
|
||||
|
||||
static void on_audio_playback(void *param, obs_source_t *source,
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
const struct audio_data *audio_data, bool muted)
|
||||
{
|
||||
struct audio_monitor *monitor = param;
|
||||
float vol = source->user_volume;
|
||||
|
|
@ -206,10 +215,10 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
if (os_atomic_load_long(&source->activate_refs) == 0)
|
||||
goto unlock;
|
||||
|
||||
success = audio_resampler_resample(monitor->resampler, resample_data,
|
||||
&resample_frames, &ts_offset,
|
||||
(const uint8_t *const *) audio_data->data,
|
||||
(uint32_t) audio_data->frames);
|
||||
success = audio_resampler_resample(
|
||||
monitor->resampler, resample_data, &resample_frames, &ts_offset,
|
||||
(const uint8_t *const *)audio_data->data,
|
||||
(uint32_t)audio_data->frames);
|
||||
|
||||
if (!success)
|
||||
goto unlock;
|
||||
|
|
@ -221,7 +230,7 @@ static void on_audio_playback(void *param, obs_source_t *source,
|
|||
} else {
|
||||
if (!close_float(vol, 1.0f, EPSILON)) {
|
||||
process_volume(monitor, vol, resample_data,
|
||||
resample_frames);
|
||||
resample_frames);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -262,19 +271,19 @@ static void pulseaudio_underflow(pa_stream *p, void *userdata)
|
|||
}
|
||||
|
||||
static void pulseaudio_server_info(pa_context *c, const pa_server_info *i,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
UNUSED_PARAMETER(userdata);
|
||||
|
||||
blog(LOG_INFO, "Server name: '%s %s'", i->server_name,
|
||||
i->server_version);
|
||||
i->server_version);
|
||||
|
||||
pulseaudio_signal(0);
|
||||
}
|
||||
|
||||
static void pulseaudio_source_info(pa_context *c, const pa_source_info *i,
|
||||
int eol, void *userdata)
|
||||
int eol, void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
PULSE_DATA(userdata);
|
||||
|
|
@ -287,29 +296,29 @@ static void pulseaudio_source_info(pa_context *c, const pa_source_info *i,
|
|||
if (eol > 0)
|
||||
goto skip;
|
||||
|
||||
blog(LOG_INFO, "Audio format: %s, %"PRIu32" Hz, %"PRIu8" channels",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
i->sample_spec.rate, i->sample_spec.channels);
|
||||
blog(LOG_INFO, "Audio format: %s, %" PRIu32 " Hz, %" PRIu8 " channels",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
i->sample_spec.rate, i->sample_spec.channels);
|
||||
|
||||
pa_sample_format_t format = i->sample_spec.format;
|
||||
if (pulseaudio_to_obs_audio_format(format) == AUDIO_FORMAT_UNKNOWN) {
|
||||
format = PA_SAMPLE_FLOAT32LE;
|
||||
|
||||
blog(LOG_INFO, "Sample format %s not supported by OBS,"
|
||||
"using %s instead for recording",
|
||||
pa_sample_format_to_string(
|
||||
i->sample_spec.format),
|
||||
pa_sample_format_to_string(format));
|
||||
blog(LOG_INFO,
|
||||
"Sample format %s not supported by OBS,"
|
||||
"using %s instead for recording",
|
||||
pa_sample_format_to_string(i->sample_spec.format),
|
||||
pa_sample_format_to_string(format));
|
||||
}
|
||||
|
||||
uint8_t channels = i->sample_spec.channels;
|
||||
if (pulseaudio_channels_to_obs_speakers(channels) == SPEAKERS_UNKNOWN) {
|
||||
channels = 2;
|
||||
|
||||
blog(LOG_INFO, "%c channels not supported by OBS,"
|
||||
"using %c instead for recording",
|
||||
i->sample_spec.channels,
|
||||
channels);
|
||||
blog(LOG_INFO,
|
||||
"%c channels not supported by OBS,"
|
||||
"using %c instead for recording",
|
||||
i->sample_spec.channels, channels);
|
||||
}
|
||||
|
||||
data->format = format;
|
||||
|
|
@ -328,15 +337,16 @@ static void pulseaudio_stop_playback(struct audio_monitor *monitor)
|
|||
}
|
||||
|
||||
blog(LOG_INFO, "Stopped Monitoring in '%s'", monitor->device);
|
||||
blog(LOG_INFO, "Got %"PRIuFAST32" packets with %"PRIuFAST64" frames",
|
||||
monitor->packets, monitor->frames);
|
||||
blog(LOG_INFO,
|
||||
"Got %" PRIuFAST32 " packets with %" PRIuFAST64 " frames",
|
||||
monitor->packets, monitor->frames);
|
||||
|
||||
monitor->packets = 0;
|
||||
monitor->frames = 0;
|
||||
}
|
||||
|
||||
static bool audio_monitor_init(struct audio_monitor *monitor,
|
||||
obs_source_t *source)
|
||||
obs_source_t *source)
|
||||
{
|
||||
pthread_mutex_init_value(&monitor->playback_mutex);
|
||||
|
||||
|
|
@ -355,7 +365,7 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
if (match) {
|
||||
monitor->ignore = true;
|
||||
blog(LOG_INFO, "Prevented feedback-loop in '%s'",
|
||||
s_dev_id);
|
||||
s_dev_id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -371,25 +381,25 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
|
||||
if (pulseaudio_get_server_info(pulseaudio_server_info,
|
||||
(void *) monitor) < 0) {
|
||||
(void *)monitor) < 0) {
|
||||
blog(LOG_ERROR, "Unable to get server info !");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pulseaudio_get_source_info(pulseaudio_source_info, monitor->device,
|
||||
(void *) monitor) < 0) {
|
||||
(void *)monitor) < 0) {
|
||||
blog(LOG_ERROR, "Unable to get source info !");
|
||||
return false;
|
||||
}
|
||||
if (monitor->format == PA_SAMPLE_INVALID) {
|
||||
blog(LOG_ERROR,
|
||||
"An error occurred while getting the source info!");
|
||||
"An error occurred while getting the source info!");
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_sample_spec spec;
|
||||
spec.format = monitor->format;
|
||||
spec.rate = (uint32_t) monitor->samples_per_sec;
|
||||
spec.rate = (uint32_t)monitor->samples_per_sec;
|
||||
spec.channels = monitor->channels;
|
||||
|
||||
if (!pa_sample_spec_valid(&spec)) {
|
||||
|
|
@ -397,31 +407,27 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
}
|
||||
|
||||
const struct audio_output_info *info = audio_output_get_info(
|
||||
obs->audio.audio);
|
||||
const struct audio_output_info *info =
|
||||
audio_output_get_info(obs->audio.audio);
|
||||
|
||||
struct resample_info from = {
|
||||
.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR
|
||||
};
|
||||
struct resample_info from = {.samples_per_sec = info->samples_per_sec,
|
||||
.speakers = info->speakers,
|
||||
.format = AUDIO_FORMAT_FLOAT_PLANAR};
|
||||
struct resample_info to = {
|
||||
.samples_per_sec = (uint32_t) monitor->samples_per_sec,
|
||||
.speakers = pulseaudio_channels_to_obs_speakers(
|
||||
monitor->channels),
|
||||
.format = pulseaudio_to_obs_audio_format
|
||||
(monitor->format)
|
||||
};
|
||||
.samples_per_sec = (uint32_t)monitor->samples_per_sec,
|
||||
.speakers =
|
||||
pulseaudio_channels_to_obs_speakers(monitor->channels),
|
||||
.format = pulseaudio_to_obs_audio_format(monitor->format)};
|
||||
|
||||
monitor->resampler = audio_resampler_create(&to, &from);
|
||||
if (!monitor->resampler) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to create resampler");
|
||||
"Failed to create resampler");
|
||||
return false;
|
||||
}
|
||||
|
||||
monitor->bytes_per_channel = get_audio_bytes_per_channel(
|
||||
pulseaudio_to_obs_audio_format(monitor->format));
|
||||
pulseaudio_to_obs_audio_format(monitor->format));
|
||||
monitor->speakers = pulseaudio_channels_to_obs_speakers(spec.channels);
|
||||
monitor->bytes_per_frame = pa_frame_size(&spec);
|
||||
|
||||
|
|
@ -434,26 +440,26 @@ static bool audio_monitor_init(struct audio_monitor *monitor,
|
|||
return false;
|
||||
}
|
||||
|
||||
monitor->attr.fragsize = (uint32_t) -1;
|
||||
monitor->attr.maxlength = (uint32_t) -1;
|
||||
monitor->attr.minreq = (uint32_t) -1;
|
||||
monitor->attr.prebuf = (uint32_t) -1;
|
||||
monitor->attr.fragsize = (uint32_t)-1;
|
||||
monitor->attr.maxlength = (uint32_t)-1;
|
||||
monitor->attr.minreq = (uint32_t)-1;
|
||||
monitor->attr.prebuf = (uint32_t)-1;
|
||||
monitor->attr.tlength = pa_usec_to_bytes(25000, &spec);
|
||||
|
||||
monitor->buffer_size = monitor->bytes_per_frame *
|
||||
pa_usec_to_bytes(5000, &spec);
|
||||
monitor->buffer_size =
|
||||
monitor->bytes_per_frame * pa_usec_to_bytes(5000, &spec);
|
||||
|
||||
pa_stream_flags_t flags = PA_STREAM_INTERPOLATE_TIMING |
|
||||
PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
|
||||
if (pthread_mutex_init(&monitor->playback_mutex, NULL) != 0) {
|
||||
blog(LOG_WARNING, "%s: %s", __FUNCTION__,
|
||||
"Failed to init mutex");
|
||||
"Failed to init mutex");
|
||||
return false;
|
||||
}
|
||||
|
||||
int_fast32_t ret = pulseaudio_connect_playback(monitor->stream,
|
||||
monitor->device, &monitor->attr, flags);
|
||||
int_fast32_t ret = pulseaudio_connect_playback(
|
||||
monitor->stream, monitor->device, &monitor->attr, flags);
|
||||
if (ret < 0) {
|
||||
pulseaudio_stop_playback(monitor);
|
||||
blog(LOG_ERROR, "Unable to connect to stream");
|
||||
|
|
@ -470,13 +476,13 @@ static void audio_monitor_init_final(struct audio_monitor *monitor)
|
|||
return;
|
||||
|
||||
obs_source_add_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
on_audio_playback, monitor);
|
||||
|
||||
pulseaudio_write_callback(monitor->stream, pulseaudio_stream_write,
|
||||
(void *) monitor);
|
||||
(void *)monitor);
|
||||
|
||||
pulseaudio_set_underflow_callback(monitor->stream, pulseaudio_underflow,
|
||||
(void *) monitor);
|
||||
(void *)monitor);
|
||||
}
|
||||
|
||||
static inline void audio_monitor_free(struct audio_monitor *monitor)
|
||||
|
|
@ -485,8 +491,8 @@ static inline void audio_monitor_free(struct audio_monitor *monitor)
|
|||
return;
|
||||
|
||||
if (monitor->source)
|
||||
obs_source_remove_audio_capture_callback(monitor->source,
|
||||
on_audio_playback, monitor);
|
||||
obs_source_remove_audio_capture_callback(
|
||||
monitor->source, on_audio_playback, monitor);
|
||||
|
||||
audio_resampler_destroy(monitor->resampler);
|
||||
circlebuf_free(&monitor->new_data);
|
||||
|
|
|
|||
|
|
@ -32,11 +32,11 @@ static pa_threaded_mainloop *pulseaudio_mainloop = NULL;
|
|||
static pa_context *pulseaudio_context = NULL;
|
||||
|
||||
static void pulseaudio_default_devices(pa_context *c, const pa_server_info *i,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
UNUSED_PARAMETER(c);
|
||||
struct pulseaudio_default_output *d =
|
||||
(struct pulseaudio_default_output *) userdata;
|
||||
(struct pulseaudio_default_output *)userdata;
|
||||
d->default_sink_name = bstrdup(i->default_sink_name);
|
||||
pulseaudio_signal(0);
|
||||
}
|
||||
|
|
@ -44,11 +44,10 @@ static void pulseaudio_default_devices(pa_context *c, const pa_server_info *i,
|
|||
void get_default_id(char **id)
|
||||
{
|
||||
pulseaudio_init();
|
||||
struct pulseaudio_default_output *pdo = bzalloc(
|
||||
sizeof(struct pulseaudio_default_output));
|
||||
struct pulseaudio_default_output *pdo =
|
||||
bzalloc(sizeof(struct pulseaudio_default_output));
|
||||
pulseaudio_get_server_info(
|
||||
(pa_server_info_cb_t) pulseaudio_default_devices,
|
||||
(void *) pdo);
|
||||
(pa_server_info_cb_t)pulseaudio_default_devices, (void *)pdo);
|
||||
*id = bzalloc(strlen(pdo->default_sink_name) + 9);
|
||||
strcat(*id, pdo->default_sink_name);
|
||||
strcat(*id, ".monitor");
|
||||
|
|
@ -118,14 +117,14 @@ static void pulseaudio_init_context()
|
|||
|
||||
pa_proplist *p = pulseaudio_properties();
|
||||
pulseaudio_context = pa_context_new_with_proplist(
|
||||
pa_threaded_mainloop_get_api(pulseaudio_mainloop),
|
||||
"OBS-Monitor", p);
|
||||
pa_threaded_mainloop_get_api(pulseaudio_mainloop),
|
||||
"OBS-Monitor", p);
|
||||
|
||||
pa_context_set_state_callback(pulseaudio_context,
|
||||
pulseaudio_context_state_changed, NULL);
|
||||
pulseaudio_context_state_changed, NULL);
|
||||
|
||||
pa_context_connect(pulseaudio_context, NULL, PA_CONTEXT_NOAUTOSPAWN,
|
||||
NULL);
|
||||
NULL);
|
||||
pa_proplist_free(p);
|
||||
|
||||
pulseaudio_unlock();
|
||||
|
|
@ -217,15 +216,15 @@ void pulseaudio_accept()
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
||||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_source_info_list(
|
||||
pulseaudio_context, cb, userdata);
|
||||
pa_operation *op = pa_context_get_source_info_list(pulseaudio_context,
|
||||
cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -240,7 +239,7 @@ int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
||||
const char *name, void *userdata)
|
||||
const char *name, void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
|
@ -248,7 +247,7 @@ int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
|||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_source_info_by_name(
|
||||
pulseaudio_context, name, cb, userdata);
|
||||
pulseaudio_context, name, cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -269,8 +268,8 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata)
|
|||
|
||||
pulseaudio_lock();
|
||||
|
||||
pa_operation *op = pa_context_get_server_info(
|
||||
pulseaudio_context, cb, userdata);
|
||||
pa_operation *op =
|
||||
pa_context_get_server_info(pulseaudio_context, cb, userdata);
|
||||
if (!op) {
|
||||
pulseaudio_unlock();
|
||||
return -1;
|
||||
|
|
@ -284,7 +283,7 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata)
|
|||
}
|
||||
|
||||
pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
||||
const pa_channel_map *map)
|
||||
const pa_channel_map *map)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return NULL;
|
||||
|
|
@ -292,8 +291,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
pulseaudio_lock();
|
||||
|
||||
pa_proplist *p = pulseaudio_properties();
|
||||
pa_stream *s = pa_stream_new_with_proplist(
|
||||
pulseaudio_context, name, ss, map, p);
|
||||
pa_stream *s = pa_stream_new_with_proplist(pulseaudio_context, name, ss,
|
||||
map, p);
|
||||
pa_proplist_free(p);
|
||||
|
||||
pulseaudio_unlock();
|
||||
|
|
@ -301,7 +300,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
}
|
||||
|
||||
int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
||||
const pa_buffer_attr *attr, pa_stream_flags_t flags)
|
||||
const pa_buffer_attr *attr,
|
||||
pa_stream_flags_t flags)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return -1;
|
||||
|
|
@ -311,8 +311,8 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
memcpy(device, name, dev_len);
|
||||
|
||||
pulseaudio_lock();
|
||||
int_fast32_t ret = pa_stream_connect_playback(s, device, attr, flags,
|
||||
NULL, NULL);
|
||||
int_fast32_t ret =
|
||||
pa_stream_connect_playback(s, device, attr, flags, NULL, NULL);
|
||||
pulseaudio_unlock();
|
||||
|
||||
bfree(device);
|
||||
|
|
@ -320,7 +320,7 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
}
|
||||
|
||||
void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return;
|
||||
|
|
@ -331,7 +331,7 @@ void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
|||
}
|
||||
|
||||
void pulseaudio_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb,
|
||||
void *userdata)
|
||||
void *userdata)
|
||||
{
|
||||
if (pulseaudio_context_ready() < 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ void pulseaudio_accept();
|
|||
* @warning call without active locks
|
||||
*/
|
||||
int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Request source information from a specific source
|
||||
|
|
@ -126,7 +126,7 @@ int_fast32_t pulseaudio_get_source_info_list(pa_source_info_cb_t cb,
|
|||
* @warning call without active locks
|
||||
*/
|
||||
int_fast32_t pulseaudio_get_source_info(pa_source_info_cb_t cb,
|
||||
const char *name, void *userdata);
|
||||
const char *name, void *userdata);
|
||||
|
||||
/**
|
||||
* Request server information
|
||||
|
|
@ -150,7 +150,7 @@ int_fast32_t pulseaudio_get_server_info(pa_server_info_cb_t cb, void *userdata);
|
|||
* @warning call without active locks
|
||||
*/
|
||||
pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
||||
const pa_channel_map *map);
|
||||
const pa_channel_map *map);
|
||||
|
||||
/**
|
||||
* Connect to a pulseaudio playback stream
|
||||
|
|
@ -162,7 +162,8 @@ pa_stream *pulseaudio_stream_new(const char *name, const pa_sample_spec *ss,
|
|||
* @return negative on error
|
||||
*/
|
||||
int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
||||
const pa_buffer_attr *attr, pa_stream_flags_t flags);
|
||||
const pa_buffer_attr *attr,
|
||||
pa_stream_flags_t flags);
|
||||
|
||||
/**
|
||||
* Sets a callback function for when data can be written to the stream
|
||||
|
|
@ -172,7 +173,7 @@ int_fast32_t pulseaudio_connect_playback(pa_stream *s, const char *name,
|
|||
* @param userdata pointer to userdata the callback will be called with
|
||||
*/
|
||||
void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
||||
/**
|
||||
* Sets a callback function for when an underflow happen
|
||||
|
|
@ -182,4 +183,4 @@ void pulseaudio_write_callback(pa_stream *p, pa_stream_request_cb_t cb,
|
|||
* @param userdata pointer to userdata the callback will be called with
|
||||
*/
|
||||
void pulseaudio_set_underflow_callback(pa_stream *p, pa_stream_notify_cb_t cb,
|
||||
void *userdata);
|
||||
void *userdata);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue