ive got 2 working implementations of the loopback snd-aloop device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



about:userspace->kernel->userspacewithout wasting too much in kernel. no dmixin, no mixin at all and noformat changing is done in kernel. its only a loopback device.for this to work, it forces the other side to use the same rate, formatand number of channels.
reason:aoss doesnt always work for me. and imho is not the right way.LD_PRELOAD'ing is just plain braindamaged, it couses more trouble than itsolves. telling vendors to use alsa also doesnt help.me wants mixing very bad. me wants network transparency for all apps.
ive just hacked this two implementations, just to find out, if these twomethods would work:
1. ringbuffer-copy:the first method was very easy to implement and works perfectly, withoutfracking too much with alsa internals. it allows different buffer andperiod sizes on both sides. but it consumes more cpu cycles for thememcpy. the capture timer checks if playback is valid and running, thencopies from the playbacks current position to its own buffers currentposition.
2. overwriting dma_area with other sides dma_area:the second method is a little harder to implement and it is still notfinnished, but also works perfectly. not finnished because after "stealing"the others dma area, it cant simply free both dma buffers:after letting alsa do all the hard work of allocating and setting up dma,it simply overwrites the dma_area with the dma_area of the other side.for this to work, it also forces the other side to use the same bufferand period sizes. it is very efficient, couse it doesnt need to copybuffers. on each SNDRV_PCM_TRIGGER_START it synchronizes the bufferposition, to reduce latency.
features:currently it can have up to 8 simultaneous playback and capture streams(i hope this is enough to tell you what i mean, also see my asoundrc):
ecasound -B:nonrt -f:16,2,48000 -i:alsahw,0,1,0 &ecasound -B:nonrt -f:16,2,48000 -i:alsahw,0,1,1 &ecasound -B:nonrt -f:16,2,48000 -i:alsahw,0,1,2 &...
or, if ecasound is not to your avail but want to test it:arecord -D hw:0,1 -t raw -c 2 -r 48000 -f S16_LE | aplay -t raw -c 2 -r 48000 -f S16_LE -
now open up to 8 oss applications _without_ aoss, sit back and relax.
todo:the second method needs a better way of doing the job. it needs to allocatedma and do the voodoo stuff and then set both sides to it. this way, afterclosing both sides, it can free up again, thus eliminating the memory leak.
its currently only a half duplex loopback but fullduplex device, cousethe missing part is dummy code. it would be no trouble at all to implementthis.
after sorting out problems im going to write an userspace app that willdo what ecasound above does, but transparent to the user. maybe someonewants to help.
cleaning up.
problems:i have HZ=1000:2*2*44100/1000 = 176.4, not 17648000 works perfect tho. HZ=100 wont show these problems (different storywhen using 11025, for example). i tried bresenham to change pcm_jiffiesconstantly, but it actually gave me more problems than it solved.maybe using rtc/hpet with fallback to jiffie would be a better idea.
files:http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/aloop-kernel-ringbuffer-copy.chttp://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/aloop-kernel-efficient_but_complex.chttp://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.13-aloop-ainan-ringbuffer-copy.diffhttp://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.13-aloop-ainan-efficient_but_complex.diff
last but not least:hooray!
ahmet
--admin der abteilung für angewandte mathematik, tel. 0761-203-5626
-------------------------------------------------------------------------Take Surveys. Earn Cash. Influence the Future of ITJoin SourceForge.net's Techsay panel and you'll get the chance to share youropinions on IT & business topics through brief surveys - and earn cashhttp://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV_______________________________________________Alsa-devel mailing listAlsa-devel@xxxxxxxxxxxxxxxxxxxxxxxxxx://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux