1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:27:46 +00:00

Kernel+AudioServer: Use interrupts for Intel HDA audio buffer completion

We used to not care about stopping an audio output stream for Intel HDA
since AudioServer would continuously send new buffers to play. Since
707f5ac150ef858760eb9faa52b9ba80c50c4262 however, that has changed.

Intel HDA now uses interrupts to detect when each buffer was completed
by the device, and uses a simple heuristic to detect whether a buffer
underrun has occurred so it can stop the output stream.

This was tested on Qemu's Intel HDA (Linux x86_64) and a bare metal MSI
Starship/Matisse HD Audio Controller.
This commit is contained in:
Jelle Raaijmakers 2023-06-27 16:07:05 +02:00
parent 2e474e8c18
commit 5c64686666
5 changed files with 120 additions and 25 deletions

View file

@ -58,10 +58,7 @@ void Mixer::mix()
{
Threading::MutexLocker const locker(m_pending_mutex);
// While we have nothing to mix, wait on the condition.
// HACK: HDA is currently broken when we don't constantly feed it a buffer stream.
// Commenting out this line makes it "just work" for the time being. Please add this line back once the issue is fixed.
// See:
// m_mixing_necessary.wait_while([this, &active_mix_queues]() { return m_pending_mixing.is_empty() && active_mix_queues.is_empty(); });
m_mixing_necessary.wait_while([this, &active_mix_queues]() { return m_pending_mixing.is_empty() && active_mix_queues.is_empty(); });
if (!m_pending_mixing.is_empty()) {
active_mix_queues.extend(move(m_pending_mixing));
m_pending_mixing.clear();