PulseAudio: fix incorrect outstream software_latency

Previously, when using PulseAudio, unintended integer division
caused SoundIoOutStream::software_latency to be incorrect.
This commit is contained in:
Andrew Kelley 2015-11-20 23:51:16 -07:00
parent 180ed94e2f
commit 72fde44073
2 changed files with 8 additions and 7 deletions

View file

@ -200,12 +200,6 @@ int main(int argc, char **argv) {
}
fprintf(stderr, "Output device: %s\n", device->name);
fprintf(stderr,
"'p\\n' - pause\n"
"'u\\n' - unpause\n"
"'P\\n' - pause from within callback\n"
"'c\\n' - clear buffer\n"
"'q\\n' - quit\n");
if (device->probe_error) {
fprintf(stderr, "Cannot probe device: %s\n", soundio_strerror(device->probe_error));
@ -241,6 +235,13 @@ int main(int argc, char **argv) {
return 1;
}
fprintf(stderr, "Software latency: %f\n", outstream->software_latency);
fprintf(stderr,
"'p\\n' - pause\n"
"'u\\n' - unpause\n"
"'P\\n' - pause from within callback\n"
"'c\\n' - clear buffer\n"
"'q\\n' - quit\n");
if (outstream->layout_error)
fprintf(stderr, "unable to set channel layout: %s\n", soundio_strerror(outstream->layout_error));

View file

@ -724,7 +724,7 @@ static int outstream_open_pa(struct SoundIoPrivate *si, struct SoundIoOutStreamP
}
size_t writable_size = pa_stream_writable_size(ospa->stream);
outstream->software_latency = writable_size / bytes_per_second;
outstream->software_latency = ((double)writable_size) / (double)bytes_per_second;
pa_threaded_mainloop_unlock(sipa->main_loop);