mirror of
https://github.com/Ryujinx/libsoundio.git
synced 2024-12-22 23:45:26 +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;
|
||||
}
|
||||
|
||||
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_START_CORKED|PA_STREAM_AUTO_TIMING_UPDATE);
|
||||
if (outstream->software_latency > 0.0)
|
||||
flags = (pa_stream_flags_t) (flags | PA_STREAM_ADJUST_LATENCY);
|
||||
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_START_CORKED | PA_STREAM_AUTO_TIMING_UPDATE |
|
||||
PA_STREAM_INTERPOLATE_TIMING);
|
||||
|
||||
int err = pa_stream_connect_playback(ospa->stream,
|
||||
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;
|
||||
pa_threaded_mainloop_lock(sipa->main_loop);
|
||||
|
||||
pa_stream_flags_t flags = PA_STREAM_AUTO_TIMING_UPDATE;
|
||||
if (instream->software_latency > 0.0)
|
||||
flags = (pa_stream_flags_t) (flags|PA_STREAM_ADJUST_LATENCY);
|
||||
pa_stream_flags_t flags = (pa_stream_flags_t)(PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_INTERPOLATE_TIMING);
|
||||
|
||||
int err = pa_stream_connect_record(ispa->stream,
|
||||
instream->device->id,
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <math.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ static void underflow_callback(struct SoundIoOutStream *outstream) {
|
|||
int main(int argc, char **argv) {
|
||||
char *exe = argv[0];
|
||||
enum SoundIoBackend backend = SoundIoBackendNone;
|
||||
double software_latency = 0.0;
|
||||
for (int i = 1; i < argc; i += 1) {
|
||||
char *arg = argv[i];
|
||||
if (arg[0] == '-' && arg[1] == '-') {
|
||||
|
@ -152,6 +153,8 @@ int main(int argc, char **argv) {
|
|||
fprintf(stderr, "Invalid backend: %s\n", argv[i]);
|
||||
return 1;
|
||||
}
|
||||
} else if (strcmp(arg, "--latency") == 0) {
|
||||
software_latency = atof(argv[i]);
|
||||
} else {
|
||||
return usage(exe);
|
||||
}
|
||||
|
@ -186,6 +189,7 @@ int main(int argc, char **argv) {
|
|||
outstream->format = SoundIoFormatFloat32NE;
|
||||
outstream->write_callback = write_callback;
|
||||
outstream->underflow_callback = underflow_callback;
|
||||
outstream->software_latency = software_latency;
|
||||
|
||||
if (soundio_device_supports_format(device, SoundIoFormatFloat32NE)) {
|
||||
outstream->format = SoundIoFormatFloat32NE;
|
||||
|
|
Loading…
Reference in a new issue