mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2025-01-05 16:45:38 +00:00
JACK: fix not setting outstream buffer_duration
This commit is contained in:
parent
29a914ceba
commit
a378cac92d
|
@ -397,12 +397,14 @@ struct SoundIoOutStream {
|
||||||
// Buffer duration in seconds.
|
// Buffer duration in seconds.
|
||||||
// After you call `soundio_outstream_open` this value is replaced with the
|
// After you call `soundio_outstream_open` this value is replaced with the
|
||||||
// actual duration, as near to this value as possible.
|
// actual duration, as near to this value as possible.
|
||||||
// Defaults to 1 second (and then clamped into range).
|
// Defaults to a big buffer, potentially upwards of 1 second. If you want
|
||||||
|
// lower latency, set this value to the latency you want.
|
||||||
// If the device has unknown buffer duration min and max values, you may
|
// If the device has unknown buffer duration min and max values, you may
|
||||||
// still set this. If you set this and the backend is PulseAudio, it
|
// still set this, but you might not get the value you requested. If you
|
||||||
// sets `PA_STREAM_ADJUST_LATENCY` and is the value used for `maxlength`
|
// set this and the backend is PulseAudio, it sets
|
||||||
// and `tlength`. With PulseAudio, this value is not replaced with the
|
// `PA_STREAM_ADJUST_LATENCY` and is the value used for `maxlength` and
|
||||||
// actual duration until `soundio_outstream_start`.
|
// `tlength`. With PulseAudio, this value is not replaced with the actual
|
||||||
|
// duration until `soundio_outstream_start`.
|
||||||
double buffer_duration;
|
double buffer_duration;
|
||||||
|
|
||||||
// `period_duration` is the latency; how much time it takes
|
// `period_duration` is the latency; how much time it takes
|
||||||
|
@ -657,11 +659,13 @@ int soundio_output_device_count(struct SoundIo *soundio);
|
||||||
|
|
||||||
// Always returns a device. Call soundio_device_unref when done.
|
// Always returns a device. Call soundio_device_unref when done.
|
||||||
// `index` must be 0 <= index < soundio_input_device_count
|
// `index` must be 0 <= index < soundio_input_device_count
|
||||||
// Returns NULL if you never called `soundio_flush_events`.
|
// Returns NULL if you never called `soundio_flush_events` or if you provide
|
||||||
|
// invalid parameter values.
|
||||||
struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index);
|
struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index);
|
||||||
// Always returns a device. Call soundio_device_unref when done.
|
// Always returns a device. Call soundio_device_unref when done.
|
||||||
// `index` must be 0 <= index < soundio_output_device_count
|
// `index` must be 0 <= index < soundio_output_device_count
|
||||||
// Returns NULL if you never called `soundio_flush_events`.
|
// Returns NULL if you never called `soundio_flush_events` or if you provide
|
||||||
|
// invalid parameter values.
|
||||||
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index);
|
||||||
|
|
||||||
// returns the index of the default input device
|
// returns the index of the default input device
|
||||||
|
|
|
@ -99,7 +99,7 @@ static int refresh_devices_bare(SoundIoPrivate *si) {
|
||||||
return SoundIoErrorNoMem;
|
return SoundIoErrorNoMem;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundIoList<SoundIoJackClient> clients;
|
SoundIoList<SoundIoJackClient> clients = {0};
|
||||||
const char **port_name_ptr = port_names;
|
const char **port_name_ptr = port_names;
|
||||||
while (*port_name_ptr) {
|
while (*port_name_ptr) {
|
||||||
const char *client_and_port_name = *port_name_ptr;
|
const char *client_and_port_name = *port_name_ptr;
|
||||||
|
@ -415,7 +415,7 @@ static int outstream_open_jack(struct SoundIoPrivate *si, struct SoundIoOutStrea
|
||||||
if (sij->is_shutdown)
|
if (sij->is_shutdown)
|
||||||
return SoundIoErrorBackendDisconnected;
|
return SoundIoErrorBackendDisconnected;
|
||||||
|
|
||||||
outstream->buffer_duration = 0.0;
|
outstream->buffer_duration = device->period_duration_current;
|
||||||
outstream->period_duration = device->period_duration_current;
|
outstream->period_duration = device->period_duration_current;
|
||||||
osj->period_size = sij->period_size;
|
osj->period_size = sij->period_size;
|
||||||
|
|
||||||
|
@ -616,7 +616,7 @@ static int instream_open_jack(struct SoundIoPrivate *si, struct SoundIoInStreamP
|
||||||
if (sij->is_shutdown)
|
if (sij->is_shutdown)
|
||||||
return SoundIoErrorBackendDisconnected;
|
return SoundIoErrorBackendDisconnected;
|
||||||
|
|
||||||
instream->buffer_duration = 0.0;
|
instream->buffer_duration = device->period_duration_current;
|
||||||
instream->period_duration = device->period_duration_current;
|
instream->period_duration = device->period_duration_current;
|
||||||
isj->period_size = sij->period_size;
|
isj->period_size = sij->period_size;
|
||||||
|
|
||||||
|
|
|
@ -254,43 +254,75 @@ void soundio_flush_events(struct SoundIo *soundio) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int soundio_input_device_count(struct SoundIo *soundio) {
|
int soundio_input_device_count(struct SoundIo *soundio) {
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
if (!si->safe_devices_info)
|
if (!si->safe_devices_info)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return si->safe_devices_info->input_devices.length;
|
return si->safe_devices_info->input_devices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int soundio_output_device_count(struct SoundIo *soundio) {
|
int soundio_output_device_count(struct SoundIo *soundio) {
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
if (!si->safe_devices_info)
|
if (!si->safe_devices_info)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return si->safe_devices_info->output_devices.length;
|
return si->safe_devices_info->output_devices.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int soundio_default_input_device_index(struct SoundIo *soundio) {
|
int soundio_default_input_device_index(struct SoundIo *soundio) {
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
if (!si->safe_devices_info)
|
if (!si->safe_devices_info)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return si->safe_devices_info->default_input_index;
|
return si->safe_devices_info->default_input_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int soundio_default_output_device_index(struct SoundIo *soundio) {
|
int soundio_default_output_device_index(struct SoundIo *soundio) {
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
if (!si->safe_devices_info)
|
if (!si->safe_devices_info)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return -1;
|
||||||
|
|
||||||
return si->safe_devices_info->default_output_index;
|
return si->safe_devices_info->default_output_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index) {
|
struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int index) {
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
|
if (!si->safe_devices_info)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
assert(index < si->safe_devices_info->input_devices.length);
|
assert(index < si->safe_devices_info->input_devices.length);
|
||||||
if (!si->safe_devices_info)
|
if (index < 0 || index >= si->safe_devices_info->input_devices.length)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SoundIoDevice *device = si->safe_devices_info->input_devices.at(index);
|
SoundIoDevice *device = si->safe_devices_info->input_devices.at(index);
|
||||||
|
@ -300,10 +332,18 @@ struct SoundIoDevice *soundio_get_input_device(struct SoundIo *soundio, int inde
|
||||||
|
|
||||||
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index) {
|
struct SoundIoDevice *soundio_get_output_device(struct SoundIo *soundio, int index) {
|
||||||
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
SoundIoPrivate *si = (SoundIoPrivate *)soundio;
|
||||||
|
|
||||||
assert(soundio->current_backend != SoundIoBackendNone);
|
assert(soundio->current_backend != SoundIoBackendNone);
|
||||||
|
if (soundio->current_backend == SoundIoBackendNone)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
assert(si->safe_devices_info);
|
||||||
|
if (!si->safe_devices_info)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
assert(index >= 0);
|
assert(index >= 0);
|
||||||
assert(index < si->safe_devices_info->output_devices.length);
|
assert(index < si->safe_devices_info->output_devices.length);
|
||||||
if (!si->safe_devices_info)
|
if (index < 0 || index >= si->safe_devices_info->output_devices.length)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
SoundIoDevice *device = si->safe_devices_info->output_devices.at(index);
|
SoundIoDevice *device = si->safe_devices_info->output_devices.at(index);
|
||||||
|
@ -333,6 +373,7 @@ void soundio_device_unref(struct SoundIoDevice *device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void soundio_device_ref(struct SoundIoDevice *device) {
|
void soundio_device_ref(struct SoundIoDevice *device) {
|
||||||
|
assert(device);
|
||||||
device->ref_count += 1;
|
device->ref_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,9 +411,12 @@ static void default_underflow_callback(struct SoundIoOutStream *outstream) { }
|
||||||
|
|
||||||
struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device) {
|
struct SoundIoOutStream *soundio_outstream_create(struct SoundIoDevice *device) {
|
||||||
SoundIoOutStreamPrivate *os = allocate<SoundIoOutStreamPrivate>(1);
|
SoundIoOutStreamPrivate *os = allocate<SoundIoOutStreamPrivate>(1);
|
||||||
|
SoundIoOutStream *outstream = &os->pub;
|
||||||
|
|
||||||
if (!os)
|
if (!os)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
SoundIoOutStream *outstream = &os->pub;
|
if (!device)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
outstream->device = device;
|
outstream->device = device;
|
||||||
soundio_device_ref(device);
|
soundio_device_ref(device);
|
||||||
|
@ -455,9 +499,12 @@ static void default_instream_error_callback(struct SoundIoInStream *is, int err)
|
||||||
|
|
||||||
struct SoundIoInStream *soundio_instream_create(struct SoundIoDevice *device) {
|
struct SoundIoInStream *soundio_instream_create(struct SoundIoDevice *device) {
|
||||||
SoundIoInStreamPrivate *is = allocate<SoundIoInStreamPrivate>(1);
|
SoundIoInStreamPrivate *is = allocate<SoundIoInStreamPrivate>(1);
|
||||||
|
SoundIoInStream *instream = &is->pub;
|
||||||
|
|
||||||
if (!is)
|
if (!is)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
SoundIoInStream *instream = &is->pub;
|
if (!device)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
instream->device = device;
|
instream->device = device;
|
||||||
soundio_device_ref(device);
|
soundio_device_ref(device);
|
||||||
|
|
Loading…
Reference in a new issue