[alsa-devel] [PATCH] improved snd-aloop quality when using certain samplerates and kernel HZ
after using a HZ:=300 kernel for some time now and needing snd-aloop again i found out, that i either had to correct the hardcoded number, or fix the problem permanently, which couses stuttering and other problems.
i also removed the SYNC on start code, not just because its more or less useless and brings problems, but ive got a nice idea how to fix this overrun/underrun problem in a much nicer way.
so stay tuned for the next patch, until its implemented.
this patch here is more or less experimental, id like to hear some feedback.
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.15...
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
please also include my email address when responding - i have no intention to enable recieving emails from the list.
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
sorry, forget about the patch before. this one here is a lot better to read and fixes one silly mistake.
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.15...
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
please also include my email address when responding - i have no intention to enable recieving emails from the list.
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Tue, 19 Feb 2008 13:50:46 +0100, Ahmet İnan wrote:
sorry, forget about the patch before. this one here is a lot better to read and fixes one silly mistake.
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.15...
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
Looks like a good clean up.
Applied to HG tree now. Thanks!
Takashi
more cleanups.
removed some unneeded stuff. patch is relative to current hg-tree.
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo...
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
btw, my "nice" idea turned out to be a bitch, again. its really funny how worse almoust always is better. :(
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Wed, 20 Feb 2008 15:19:06 +0100, Ahmet İnan wrote:
more cleanups.
removed some unneeded stuff. patch is relative to current hg-tree.
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo...
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
Thanks, applied now to HG tree.
Takashi
removed my old debugging macros. renamed variables to make it more clear.
[snd-aloop - even more cleanups] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
i promised to improve and clean up snd-dummy too, so here it is: reused the same method to improve timing, renamed the variables, added snd_pcm_format_set_silence on prepare.
[snd-dummy - improved timing, silence on prepare] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-kernel-hg-dum... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
patches are relative to current hg-tree.
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Thu, 21 Feb 2008 01:06:01 +0100, Ahmet İnan wrote: At Thu, 21 Feb 2008 01:06:01 +0100, Ahmet İnan wrote:
[snd-aloop - even more cleanups] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
i promised to improve and clean up snd-dummy too, so here it is: reused the same method to improve timing, renamed the variables, added snd_pcm_format_set_silence on prepare.
[snd-dummy - improved timing, silence on prepare] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-kernel-hg-dum... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
patches are relative to current hg-tree.
Thanks, applied both to HG tree now.
Takashi
when the time interval for a period is smaller than kernel HZ, then snd-aloop and snd-dummy cannot call snd_pcm_period_elapsed as fast enough annymore. this happens for example with games. but the app still needs to see, that the buffer actually did go further, which is provided by these patches.
[snd-aloop - better realtime app support] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
[snd-dummy - better realtime app support] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-kernel-hg-dum... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
patches are relative to current hg-tree.
finally even realtime apps like games work smooth. only one thing left for perfection :)
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Fri, 22 Feb 2008 19:05:28 +0100, Ahmet İnan wrote:
when the time interval for a period is smaller than kernel HZ, then snd-aloop and snd-dummy cannot call snd_pcm_period_elapsed as fast enough annymore. this happens for example with games. but the app still needs to see, that the buffer actually did go further, which is provided by these patches.
Applied to HG tree now. Thanks.
Takashi
see, that the buffer actually did go further, which is provided by these patches.
Applied to HG tree now. Thanks.
could it be, that you still forgot to apply this patch, but did the other?
[snd-aloop - better realtime app support] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
or you havent synced home alsa-driver with main repository yet, then never mind :)
thanks
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Sat, 1 Mar 2008 12:55:06 +0100, Ahmet İnan wrote:
see, that the buffer actually did go further, which is provided by these patches.
Applied to HG tree now. Thanks.
could it be, that you still forgot to apply this patch, but did the other?
It was already applied but a different subject. Please follow the standard patch style at the next time.
Takashi
moved module parameter pcm_substreams range check code around, to prevent catastrophe. removed bogus module parameter pcm_devs code - aloop creates only one pair of devices. allowed float_le, too. removed obsolete code.
[snd-aloop - more cleanups] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
patch is relative to my previous patch.
will fix bogus wiki entries, about the module parameters, too.
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
At Sun, 2 Mar 2008 00:35:03 +0100, Ahmet İnan wrote:
moved module parameter pcm_substreams range check code around, to prevent catastrophe. removed bogus module parameter pcm_devs code - aloop creates only one pair of devices. allowed float_le, too. removed obsolete code.
[snd-aloop - more cleanups] http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-hg-alo... [Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>]
patch is relative to my previous patch.
Please post the patch instead of URL.
Also, it'd be appreciated if you follow the standard rule for submitting patches. We follow the linux kernel rule for alsa-driver tree, too. See $LINUX/Documentation/SubmittingPatches.
thanks,
Takashi
Also, it'd be appreciated if you follow the standard rule for
thank you for pointing this out. will try my best. patch is relative to current hg-tree.
ahmet
snd-aloop - more cleanups
moved module parameter pcm_substreams range check code around, to prevent catastrophe. removed bogus module parameter pcm_devs code - aloop creates only one pair of devices. allowed float_le, too. removed obsolete code.
Signed-off-by: Ahmet İnan <ainan <at> mathematik.uni-freiburg.de>
ive just read about aloop problems by chance, so excuse the late answer, for ive disabled recieving mails from this list. so also cc me when replying :)
repeating stuttering
try tickless kernel, as it improves the quality of timer interrupts dramatically. dont forget to enable high resolution timer support, hpet and so on.
synchronization issue at the beginning
this is still not resolved and its a pain in the ass to get this done right. ive implemented 4 different ways to solve it and im still not happy with what ive got.
kernel crash when closing
do you really have to put at this manny places this del_timer? try to find the right place and resubmit. :)
ahmet
-- admin der abteilung für angewandte mathematik, tel. 0761-203-5626
Hi Ahmet,
ive just read about aloop problems by chance, so excuse the late answer,
for ive disabled recieving mails from this list. so also cc me when replying :)
No problem, I'm delighted somebody is answering my e-mails at all :)
repeating stuttering try tickless kernel, as it improves the quality of timer interrupts dramatically. dont forget to enable high resolution timer support, hpet and so on.
OK, excellent tip. Thanks! High resolution timer support is already enabled and I've got the kernel configured for "realtime" performance (CONFIG_HZ or whatever it was called set to 1000 etc.). I'll try to see if the tickless kernel makes any difference.
synchronization issue at the beginning
this is still not resolved and its a pain in the ass to get this done right. ive implemented 4 different ways to solve it and im still not happy with what ive got.
The funny thing is, after I reverted to the 10.0.16 release tarball these stuttering problems went away. So the fixes that were committed in february/march under the 'fixes realtime behaviour' label actually made things much worse..
kernel crash when closing
do you really have to put at this manny places this del_timer? try to find the right place and resubmit. :)
I already presumed it was a bit much, I'll be the last one to deny that! ;-)
But then again, I'm not too familiar with ALSA kernel stuff anyway and the existing documentation seems a bit sparse. Also, this patch was made as part of a time-limited project at my company so I sadly couldn't spend more time on it after I (crudely) fixed the bug. However, I'd love to refine my patch (in my own spare time). Can you give me any pointers perhaps? They would be greatly appreciated.
Thanks for taking the time to reply!
Kind regards, Benjamin
synchronization issue at the beginning
this is still not resolved and its a pain in the ass to get this done
The funny thing is, after I reverted to the 10.0.16 release tarball these stuttering problems went away. So the fixes that were committed in february/march under the 'fixes realtime behaviour' label actually made things much worse..
without SND_CARD_LOOPBACK_START_SYNC, its still the same. you should really get a tickless kernel first. otherwise its just pure luck and frustration.
try to find the right place and resubmit. :)
(in my own spare time). Can you give me any pointers perhaps? They would be
usually snd_card_loopback_playback_trigger gets called with SNDRV_PCM_TRIGGER_STOP whenever the device is about to be closed. so the next function would be snd_card_loopback_close. try snd_card_loopback_timer_stop there and report :D
ahmet
participants (3)
-
Ahmet İnan
-
Benjamin van den Hout
-
Takashi Iwai