From 8bf0e04c1629dcecf68035bb94a036b29b918005 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Sat, 26 Feb 2022 19:20:07 +0100 Subject: [PATCH] Kernel: Allow setting AC'97 sample rate during playback The Qemu AC'97 device stops its PCM channel's DMA engine when it is running and the sample rate is changed. We now make sure the DMA engine is restarted after changing the sample rate, allowing you to e.g. run `asctl set r 22050` during `aplay` playback. --- Kernel/Devices/Audio/AC97.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/Devices/Audio/AC97.cpp b/Kernel/Devices/Audio/AC97.cpp index 09dca53a56..68f7c51420 100644 --- a/Kernel/Devices/Audio/AC97.cpp +++ b/Kernel/Devices/Audio/AC97.cpp @@ -145,6 +145,10 @@ ErrorOr AC97::set_pcm_output_sample_rate(u32 sample_rate) dbgln("AC97 @ {}: PCM front DAC rate set to {} Hz", pci_address(), m_sample_rate); + // Setting the sample rate stops a running DMA engine, so restart it + if (m_pcm_out_channel.dma_running()) + m_pcm_out_channel.start_dma(); + return {}; }