From 0c1c3d2b996cff8b96b3f9b53e7780c88e1b4d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20J=C3=A4ger?= Date: Sun, 6 Aug 2017 20:19:32 -0700 Subject: [PATCH] qemu: fix HDA recording latency MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Very long latency occurs for audio inputs when simulating an Intel HDA device. Patch courtesy of Volker RĂ¼meling. https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg03336.html --- .../virtualization/qemu/default.nix | 3 +- .../qemu/fix-hda-recording.patch | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 pkgs/applications/virtualization/qemu/fix-hda-recording.patch diff --git a/pkgs/applications/virtualization/qemu/default.nix b/pkgs/applications/virtualization/qemu/default.nix index 8277261a1500..5da9db918557 100644 --- a/pkgs/applications/virtualization/qemu/default.nix +++ b/pkgs/applications/virtualization/qemu/default.nix @@ -55,7 +55,8 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; patches = [ ./no-etc-install.patch ] - ++ optional nixosTestRunner ./force-uid0-on-9p.patch; + ++ optional nixosTestRunner ./force-uid0-on-9p.patch + ++ optional pulseSupport ./fix-hda-recording.patch; hardeningDisable = [ "stackprotector" ]; diff --git a/pkgs/applications/virtualization/qemu/fix-hda-recording.patch b/pkgs/applications/virtualization/qemu/fix-hda-recording.patch new file mode 100644 index 000000000000..b4e21f4f3477 --- /dev/null +++ b/pkgs/applications/virtualization/qemu/fix-hda-recording.patch @@ -0,0 +1,34 @@ +diff --git a/audio/paaudio.c b/audio/paaudio.c +index fea6071..c1169d4 100644 +--- a/audio/paaudio.c ++++ b/audio/paaudio.c +@@ -608,6 +608,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; +@@ -616,6 +617,12 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) + ss.channels = as->nchannels; + ss.rate = as->freq; + ++ ba.fragsize = pa_frame_size (&ss) * g->conf.samples; ++ ba.maxlength = 5 * ba.fragsize; ++ ba.tlength = -1; ++ ba.prebuf = -1; ++ ba.minreq = -1; ++ + obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); + + pa->stream = qpa_simple_new ( +@@ -625,7 +632,7 @@ static int qpa_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque) + g->conf.source, + &ss, + NULL, /* channel map */ +- NULL, /* buffering attributes */ ++ &ba, /* buffering attributes */ + &error + ); + if (!pa->stream) {