Page 1 of 1

Audio click/pop sound due to scheduling

Posted: Sat Jul 16, 2022 7:41 am
by Kamal123
Hi,
I have been working on audio in my os.. currently I am using Intel HD audio...it plays sound without any problem before scheduler runs.. but after the scheduler is initialised and task switching is going on, it produces pop/click sound when cyclic buffer reach its beginning..

is there any special scheduling algorithm for sound? What can be the problem?

My rep :https://github.com/manaskamal/aurora-xeneva

Thanks in advance...

Re: Audio click/pop sound due to scheduling

Posted: Sat Jul 16, 2022 2:50 pm
by Octocontrabass
Did you get interrupts working?

Are you waiting until the buffer is completely empty before you refill it, or are you refilling it before it reaches that point?

Is the buffer big enough to absorb your latency? The buffer needs to be big enough that you can respond to the IRQ and refill it before it completely empties. (But a bigger buffer also increases the audio delay, so you have to find a good balance.)

Re: Audio click/pop sound due to scheduling

Posted: Sun Jul 17, 2022 3:15 am
by xeyes
If HDA only pops rather than plays a small piece of audio repeatedly, it may not be an under-run due to the userspace app not being able to keep up, but rather that the buffer updating process isn't happening correctly for certain cases.



IMO you don't have to have interrupts to get it to work well.

You can choose to dedicate a core for HDA and let the driver spin on it polling the card and software queues.

Other core(s) can build "software defined descriptor packets" and send them over to the driver core for service.

This should give you very low latency between the card and the driver, at the cost of CPU cycles. It seems quite suitable for the current situation:
Multiprocessor support (multiprocessor scheduler not ready!!)
Later, you'd have to decide whether audio is important enough to always have a dedicated core servicing it though.

Re: Audio click/pop sound due to scheduling

Posted: Sun Jul 17, 2022 4:45 am
by Kamal123
Hi,
I have interrupts working very well , I use msi for hda.. my hda driver has ioc after completion of every buffer which request sound system for already available audio data.......

also i faced an issue, even if my output converters are not configured... running the output stream gives output...and the pop click sound occurs in left speaker only.. I think I am failing to configure the pins and output converters properly..

Re: Audio click/pop sound due to scheduling

Posted: Mon Jul 18, 2022 2:50 pm
by Kamal123
Hi,

Finally I came to know the problem and I fixed it...it was due bdl_size*buffer_size crossing 4k page..it should be bdl_size*buffer_size = 4096..

Also I fixed all output path configuration bugs.. Now pins, mixer & DACs are initialised properly..

https://github.com/manaskamal/aurora-xeneva

Thank you everyone for your replies,
Manas Kamal..