mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 23:25:34 +00:00
PulseAudio: pass the latency test
This commit is contained in:
parent
8e30053962
commit
2633b1bd60
|
@ -699,9 +699,8 @@ static int outstream_open_pa(SoundIoPrivate *si, SoundIoOutStreamPrivate *os) {
|
||||||
ospa->buffer_attr.tlength = buffer_length;
|
ospa->buffer_attr.tlength = buffer_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_START_CORKED|PA_STREAM_AUTO_TIMING_UPDATE);
|
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_START_CORKED | PA_STREAM_AUTO_TIMING_UPDATE |
|
||||||
if (outstream->software_latency > 0.0)
|
PA_STREAM_INTERPOLATE_TIMING);
|
||||||
flags = (pa_stream_flags_t) (flags | PA_STREAM_ADJUST_LATENCY);
|
|
||||||
|
|
||||||
int err = pa_stream_connect_playback(ospa->stream,
|
int err = pa_stream_connect_playback(ospa->stream,
|
||||||
outstream->device->id, &ospa->buffer_attr,
|
outstream->device->id, &ospa->buffer_attr,
|
||||||
|
@ -938,9 +937,7 @@ static int instream_start_pa(SoundIoPrivate *si, SoundIoInStreamPrivate *is) {
|
||||||
SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
|
SoundIoPulseAudio *sipa = &si->backend_data.pulseaudio;
|
||||||
pa_threaded_mainloop_lock(sipa->main_loop);
|
pa_threaded_mainloop_lock(sipa->main_loop);
|
||||||
|
|
||||||
pa_stream_flags_t flags = PA_STREAM_AUTO_TIMING_UPDATE;
|
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_INTERPOLATE_TIMING);
|
||||||
if (instream->software_latency > 0.0)
|
|
||||||
flags = (pa_stream_flags_t) (flags|PA_STREAM_ADJUST_LATENCY);
|
|
||||||
|
|
||||||
int err = pa_stream_connect_record(ispa->stream,
|
int err = pa_stream_connect_record(ispa->stream,
|
||||||
instream->device->id,
|
instream->device->id,
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
static int usage(char *exe) {
|
static int usage(char *exe) {
|
||||||
fprintf(stderr, "Usage: %s [--backend dummy|alsa|pulseaudio|jack|coreaudio|wasapi]\n", exe);
|
fprintf(stderr, "Usage: %s [--backend dummy|alsa|pulseaudio|jack|coreaudio|wasapi] [--latency seconds]\n", exe);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,7 @@ static void underflow_callback(struct SoundIoOutStream *outstream) {
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
char *exe = argv[0];
|
char *exe = argv[0];
|
||||||
enum SoundIoBackend backend = SoundIoBackendNone;
|
enum SoundIoBackend backend = SoundIoBackendNone;
|
||||||
|
double software_latency = 0.0;
|
||||||
for (int i = 1; i < argc; i += 1) {
|
for (int i = 1; i < argc; i += 1) {
|
||||||
char *arg = argv[i];
|
char *arg = argv[i];
|
||||||
if (arg[0] == '-' && arg[1] == '-') {
|
if (arg[0] == '-' && arg[1] == '-') {
|
||||||
|
@ -152,6 +153,8 @@ int main(int argc, char **argv) {
|
||||||
fprintf(stderr, "Invalid backend: %s\n", argv[i]);
|
fprintf(stderr, "Invalid backend: %s\n", argv[i]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(arg, "--latency") == 0) {
|
||||||
|
software_latency = atof(argv[i]);
|
||||||
} else {
|
} else {
|
||||||
return usage(exe);
|
return usage(exe);
|
||||||
}
|
}
|
||||||
|
@ -186,6 +189,7 @@ int main(int argc, char **argv) {
|
||||||
outstream->format = SoundIoFormatFloat32NE;
|
outstream->format = SoundIoFormatFloat32NE;
|
||||||
outstream->write_callback = write_callback;
|
outstream->write_callback = write_callback;
|
||||||
outstream->underflow_callback = underflow_callback;
|
outstream->underflow_callback = underflow_callback;
|
||||||
|
outstream->software_latency = software_latency;
|
||||||
|
|
||||||
if (soundio_device_supports_format(device, SoundIoFormatFloat32NE)) {
|
if (soundio_device_supports_format(device, SoundIoFormatFloat32NE)) {
|
||||||
outstream->format = SoundIoFormatFloat32NE;
|
outstream->format = SoundIoFormatFloat32NE;
|
||||||
|
|
Loading…
Reference in a new issue