]> Git Repo - qemu.git/commitdiff
audio/paaudio: fix microphone input being unusable
authorMartin Schrodt <[email protected]>
Fri, 15 Mar 2019 08:46:53 +0000 (09:46 +0100)
committerGerd Hoffmann <[email protected]>
Mon, 18 Mar 2019 11:21:15 +0000 (12:21 +0100)
The current code does not specify the metrics of the buffers for the
input device. This makes PulseAudio choose very bad defaults, which
causes input to be unusable: Audio put in gets out 30 seconds later.
This patch fixes that and makes the latency configurable as well.

Signed-off-by: Martin Schrodt <[email protected]>
Message-id: 20190315084653[email protected]
Signed-off-by: Gerd Hoffmann <[email protected]>
audio/paaudio.c

index be27c73f094ae241824be75b73fe7401701594a5..45295b4e5ecb832cd44572f646a45f23f834be65 100644 (file)
@@ -605,6 +605,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
 {
     int error;
     pa_sample_spec ss;
+    pa_buffer_attr ba;
     struct audsettings obt_as = *as;
     PAVoiceIn *pa = (PAVoiceIn *) hw;
     paaudio *g = pa->g = drv_opaque;
@@ -615,6 +616,11 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
     ss.channels = as->nchannels;
     ss.rate = as->freq;
 
+    ba.fragsize = pa_usec_to_bytes(ppdo->latency, &ss);
+    ba.maxlength = -1;
+    ba.minreq = -1;
+    ba.prebuf = -1;
+
     obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness);
 
     pa->stream = qpa_simple_new (
@@ -624,7 +630,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
         ppdo->has_name ? ppdo->name : NULL,
         &ss,
         NULL,                   /* channel map */
-        NULL,                   /* buffering attributes */
+        &ba,                    /* buffering attributes */
         &error
         );
     if (!pa->stream) {
This page took 0.029318 seconds and 4 git commands to generate.