From 57defbf95cc4b6e88b07b906f49ab9b9ae23ea1c Mon Sep 17 00:00:00 2001 From: Jannik Vogel Date: Tue, 9 Jun 2020 04:19:36 +0200 Subject: [PATCH] audio: Avoid recalculation of descriptor parameters --- lib/hal/audio.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/hal/audio.c b/lib/hal/audio.c index c21297c29..21d0550c3 100644 --- a/lib/hal/audio.c +++ b/lib/hal/audio.c @@ -245,16 +245,17 @@ void XAudioProvideSamples(unsigned char *buffer, unsigned short bufferLength, in if (isFinal) bufferControl |= 0x4000; - unsigned int address = (unsigned int)buffer; + unsigned int address = MmGetPhysicalAddress((PVOID)buffer); + unsigned int wordCount = bufferLength / 2; - pac97device->pcmOutDescriptor[pac97device->nextDescriptorMod31].bufferStartAddress = MmGetPhysicalAddress((PVOID)address); - pac97device->pcmOutDescriptor[pac97device->nextDescriptorMod31].bufferLengthInSamples = bufferLength / (pac97device->sampleSizeInBits / 8); + pac97device->pcmOutDescriptor[pac97device->nextDescriptorMod31].bufferStartAddress = address; + pac97device->pcmOutDescriptor[pac97device->nextDescriptorMod31].bufferLengthInSamples = wordCount; pac97device->pcmOutDescriptor[pac97device->nextDescriptorMod31].bufferControl = bufferControl; pb[0x115] = (unsigned char)pac97device->nextDescriptorMod31; // set last active descriptor analogBufferCount++; - pac97device->pcmSpdifDescriptor[pac97device->nextDescriptorMod31].bufferStartAddress = MmGetPhysicalAddress((PVOID)address); - pac97device->pcmSpdifDescriptor[pac97device->nextDescriptorMod31].bufferLengthInSamples = bufferLength / (pac97device->sampleSizeInBits / 8); + pac97device->pcmSpdifDescriptor[pac97device->nextDescriptorMod31].bufferStartAddress = address; + pac97device->pcmSpdifDescriptor[pac97device->nextDescriptorMod31].bufferLengthInSamples = wordCount; pac97device->pcmSpdifDescriptor[pac97device->nextDescriptorMod31].bufferControl = bufferControl; pb[0x175] = (unsigned char)pac97device->nextDescriptorMod31; // set last active descriptor digitalBufferCount++;