Skip to contentSkip to conversation

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

DISCUSSION Ahmet İnan 2 participants 3 messages Dec 17, 2006 – Dec 18, 2006

lore
Share & tools
lore
#0 lore raw

about:
userspace->kernel->userspace
without wasting too much in kernel. no dmixin, no mixin at all and no format changing is done in kernel. its only a loopback device. for this to work, it forces the other side to use the same rate, format and 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 it solves. 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 two methods would work:

1. ringbuffer-copy:
the first method was very easy to implement and works perfectly, without fracking too much with alsa internals. it allows different buffer and period sizes on both sides. but it consumes more cpu cycles for the memcpy. the capture timer checks if playback is valid and running, then copies from the playbacks current position to its own buffers current position.

2. overwriting dma_area with other sides dma_area:
the second method is a little harder to implement and it is still not finnished, 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 buffer and period sizes. it is very efficient, couse it doesnt need to copy buffers. on each SNDRV_PCM_TRIGGER_START it synchronizes the buffer position, 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 allocate dma and do the voodoo stuff and then set both sides to it. this way, after closing both sides, it can free up again, thus eliminating the memory leak.

its currently only a half duplex loopback but fullduplex device, couse the missing part is dummy code. it would be no trouble at all to implement this.

after sorting out problems im going to write an userspace app that will do what ecasound above does, but transparent to the user. maybe someone wants to help.

cleaning up.

problems:
i have HZ=1000:
2*2*44100/1000 = 176.4, not 176
48000 works perfect tho. HZ=100 wont show these problems (different story when using 11025, for example). i tried bresenham to change pcm_jiffies constantly, 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.c
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/aloop-kernel-efficient_but_complex.c
http://www.mathematik.uni-freiburg.de/IAM/homepages/ainan/alsa-driver-1.0.13-aloop-ainan-ringbuffer-copy.diff
http://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 IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

#1 lore raw
Quoted 6 lines · Ahmet İnan

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 it solves. telling vendors to use alsa also doesnt help.
me wants mixing very bad. me wants network transparency for all apps.

This seems like a lot of wasted cycles just to make life easier for lazy application programmers.

Telling vendors to use ALSA does indeed help - the latest releases of Flash and Skype support ALSA natively.

Lee

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

#2 lore raw
Quoted 8 lines · Lee Revell
Quoted 5 lines · Ahmet İnan

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 it solves. telling vendors to use alsa also doesnt help.
me wants mixing very bad. me wants network transparency for all apps.

This seems like a lot of wasted cycles just to make life easier for lazy application programmers.

/* the same goes to aoss, which is also a waste of cycles and nerves. */ well comfort comes always with a higher price to pay. and in this respect i made it easier for my own life. it was the last time this properitary-but-hard-to-beat app annoyed me couse of this one shortcomming. so im happy now. felt like sharing. ^_^

Quoted 2 lines

Telling vendors to use ALSA does indeed help - the latest releases of Flash and Skype support ALSA natively.

yeah, but it takes them YEARS to react, until the app is outdated or of no use / interest annymore. its almoust as futile to tell them to make their apps also work on my favorite os.

so until they do, at least, ppl like me can enjoy things, what manny other ppl who dont know how it works, already do.

but hey, at least alsa starts to have a working loopback device, again, it can be used for a lot of nice things.

ahmet

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel