* difference between OSS mmap and alsa mmap? [alsa-oss] @ 2004-07-05 12:42 Florian Schmidt 2004-07-05 13:13 ` Paul Davis 0 siblings, 1 reply; 8+ messages in thread From: Florian Schmidt @ 2004-07-05 12:42 UTC (permalink / raw) To: alsa-devel Hi, the last thing i can see not working correctly in alsa-oss is the mmap emulation [may closed source apps use OSS with mmap emu]. jcdutton told me on irc that this is due to the differences in OSS mmaping and ALSA mmaping and it might not be possible to resolve these issues.. Well, since i don't know anything about mmap'ing device files, i would be glad if somebody could point me to sources of information about mmap'ing device files and especially the differences in handling of ALSA and OSS.. P.S.: the test case here is running Enemy Territory with aoss. Try it and you will see how alsa-oss' mmap emu fails badly [only some craacks and little chunks of audio audible].. -- Palimm Palimm! http://affenbande.org/~tapas/wiki ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-07-05 12:42 difference between OSS mmap and alsa mmap? [alsa-oss] Florian Schmidt @ 2004-07-05 13:13 ` Paul Davis 2004-07-05 13:19 ` Takashi Iwai 0 siblings, 1 reply; 8+ messages in thread From: Paul Davis @ 2004-07-05 13:13 UTC (permalink / raw) To: Florian Schmidt; +Cc: alsa-devel >the last thing i can see not working correctly in alsa-oss is the mmap emulati >on [may closed source apps use OSS with mmap emu]. jcdutton told me on irc tha >t this is due to the differences in OSS mmaping and ALSA mmaping and it might >not be possible to resolve these issues.. i don't think its possible. the OSS mmap API provides raw ptr access to the DMA area of the h/w. you cannot intercede when an app just uses pointer indirection and advance to read/write data. ALSA's API does the same, of course, but access is bounded by two calls that allow correct handling for devices where the DMA area is a bit more complex than the OSS model allows for (e.g. 2 devices, or a device that can't support mmap in hardware, or a dmix device, or ...) --p ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-07-05 13:13 ` Paul Davis @ 2004-07-05 13:19 ` Takashi Iwai 2004-08-24 11:57 ` Florian Schmidt 0 siblings, 1 reply; 8+ messages in thread From: Takashi Iwai @ 2004-07-05 13:19 UTC (permalink / raw) To: Paul Davis; +Cc: Florian Schmidt, alsa-devel At Mon, 05 Jul 2004 09:13:46 -0400, Paul Davis wrote: > > >the last thing i can see not working correctly in alsa-oss is the mmap emulati > >on [may closed source apps use OSS with mmap emu]. jcdutton told me on irc tha > >t this is due to the differences in OSS mmaping and ALSA mmaping and it might > >not be possible to resolve these issues.. > > i don't think its possible. the OSS mmap API provides raw ptr access > to the DMA area of the h/w. you cannot intercede when an app just uses > pointer indirection and advance to read/write data. ALSA's API does > the same, of course, but access is bounded by two calls that allow > correct handling for devices where the DMA area is a bit more complex > than the OSS model allows for (e.g. 2 devices, or a device that can't > support mmap in hardware, or a dmix device, or ...) A hack would be to call mmap_avail() in oss's GETSPACE (or similar) ioctls. But, right, I don't think that the "perfect" emulation is possible on all hardwares as it is now, too. Takashi ------------------------------------------------------- This SF.Net email sponsored by Black Hat Briefings & Training. Attend Black Hat Briefings & Training, Las Vegas July 24-29 - digital self defense, top technical experts, no vendor pitches, unmatched networking opportunities. Visit www.blackhat.com ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-07-05 13:19 ` Takashi Iwai @ 2004-08-24 11:57 ` Florian Schmidt 2004-08-24 12:20 ` Florian Schmidt 2004-08-24 13:41 ` Jaroslav Kysela 0 siblings, 2 replies; 8+ messages in thread From: Florian Schmidt @ 2004-08-24 11:57 UTC (permalink / raw) To: Takashi Iwai; +Cc: Paul Davis, alsa-devel On Mon, 05 Jul 2004 15:19:57 +0200 Takashi Iwai <tiwai@suse.de> wrote: > At Mon, 05 Jul 2004 09:13:46 -0400, > Paul Davis wrote: > > > > >the last thing i can see not working correctly in alsa-oss is the > > >mmap emulati on [may closed source apps use OSS with mmap emu]. > > >jcdutton told me on irc tha t this is due to the differences in OSS > > >mmaping and ALSA mmaping and it might not be possible to resolve > > >these issues.. > > > > i don't think its possible. the OSS mmap API provides raw ptr access > > to the DMA area of the h/w. you cannot intercede when an app just > > uses pointer indirection and advance to read/write data. ALSA's API > > does the same, of course, but access is bounded by two calls that > > allow correct handling for devices where the DMA area is a bit more > > complex than the OSS model allows for (e.g. 2 devices, or a device > > that can't support mmap in hardware, or a dmix device, or ...) > > A hack would be to call mmap_avail() in oss's GETSPACE (or similar) > ioctls. But, right, I don't think that the "perfect" emulation is > possible on all hardwares as it is now, too. btw: i might prove my ignorance with this question, but i have to ask: what makes the kernel oss emu handle mmap so good? it's an emulation, too, i suppose.. so what is the big difference in these two emulations, that in one case it works well [kernel oss emu] and in the other it seems almost impossible [libaoss.so].. flo ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-08-24 11:57 ` Florian Schmidt @ 2004-08-24 12:20 ` Florian Schmidt 2004-08-24 13:41 ` Jaroslav Kysela 1 sibling, 0 replies; 8+ messages in thread From: Florian Schmidt @ 2004-08-24 12:20 UTC (permalink / raw) To: Florian Schmidt; +Cc: Takashi Iwai, Paul Davis, alsa-devel On Tue, 24 Aug 2004 13:57:10 +0200 Florian Schmidt <mista.tapas@gmx.net> wrote: > btw: i might prove my ignorance with this question, but i have to ask: > > what makes the kernel oss emu handle mmap so good? it's an emulation, > too, i suppose.. so what is the big difference in these two > emulations, that in one case it works well [kernel oss emu] and in the > other it seems almost impossible [libaoss.so].. > besies the, of course, obvious fact that one lives in kernel space and the other in user space.. flo ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-08-24 11:57 ` Florian Schmidt 2004-08-24 12:20 ` Florian Schmidt @ 2004-08-24 13:41 ` Jaroslav Kysela 2004-08-24 14:30 ` James Courtier-Dutton 1 sibling, 1 reply; 8+ messages in thread From: Jaroslav Kysela @ 2004-08-24 13:41 UTC (permalink / raw) To: Florian Schmidt; +Cc: Takashi Iwai, Paul Davis, alsa-devel On Tue, 24 Aug 2004, Florian Schmidt wrote: > btw: i might prove my ignorance with this question, but i have to ask: > > what makes the kernel oss emu handle mmap so good? it's an emulation, Nothing. It allows direct uncontrollable access to the ring buffer. Only some hardware is supported. > too, i suppose.. so what is the big difference in these two emulations, > that in one case it works well [kernel oss emu] and in the other it > seems almost impossible [libaoss.so].. The libaoss should work at least for direct buffers in very similar way. Unfortunately, there is one problem for dmix and other plugins (rate, conversions) which RELY on the mmap_begin/mmap_commit sequence. The mmap_commit initiates the real mixing. Unfortunately, if you have the uncontrollable mmap access (OSS), you don't know exactly which data were changed. Thus we may only guess which sample regions needs to be flushed using the mmap_commit method. So resume: If you have access to direct DMA buffer (hw:X,Y devices), the behavior should be same. Unfortunately, all next processing like mixing, conversions needs more work. OSS API has no control for transferred samples for mmap mode. Applications can do anything they want with the ring buffer. OSS API is evil in this area. But they must solve same problem for their virtual mixing devices. Again, I think that they must introduce some extra latency to solve the mmap problems. I can imagine that they might have two serialized (FIFO) ring buffers. One for application and the second one for the real hardware. The real output delay won't be one ring buffer, but two ring buffers in this case. Perhaps, we might try this way. Jaroslav ----- Jaroslav Kysela <perex@suse.cz> Linux Kernel Sound Maintainer ALSA Project, SUSE Labs ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-08-24 13:41 ` Jaroslav Kysela @ 2004-08-24 14:30 ` James Courtier-Dutton 2004-08-24 15:47 ` Paul Davis 0 siblings, 1 reply; 8+ messages in thread From: James Courtier-Dutton @ 2004-08-24 14:30 UTC (permalink / raw) To: Jaroslav Kysela; +Cc: Florian Schmidt, Takashi Iwai, Paul Davis, alsa-devel Jaroslav Kysela wrote: > On Tue, 24 Aug 2004, Florian Schmidt wrote: > > >>btw: i might prove my ignorance with this question, but i have to ask: >> >>what makes the kernel oss emu handle mmap so good? it's an emulation, > > > Nothing. It allows direct uncontrollable access to the ring buffer. > Only some hardware is supported. > > >>too, i suppose.. so what is the big difference in these two emulations, >>that in one case it works well [kernel oss emu] and in the other it >>seems almost impossible [libaoss.so].. > > > The libaoss should work at least for direct buffers in very similar way. > Unfortunately, there is one problem for dmix and other plugins (rate, > conversions) which RELY on the mmap_begin/mmap_commit sequence. The > mmap_commit initiates the real mixing. Unfortunately, if you have the > uncontrollable mmap access (OSS), you don't know exactly which data were > changed. Thus we may only guess which sample regions needs to be flushed > using the mmap_commit method. > > So resume: If you have access to direct DMA buffer (hw:X,Y devices), the > behavior should be same. Unfortunately, all next processing like mixing, > conversions needs more work. OSS API has no control for transferred > samples for mmap mode. Applications can do anything they want with the > ring buffer. > > OSS API is evil in this area. But they must solve same problem for their > virtual mixing devices. Again, I think that they must introduce some extra > latency to solve the mmap problems. I can imagine that they might have two > serialized (FIFO) ring buffers. One for application and the second one > for the real hardware. The real output delay won't be one ring buffer, but > two ring buffers in this case. Perhaps, we might try this way. > > Jaroslav > One runs into the same issues with writing an ALSA driver for wine. Windows ASIO just lets the application write directly to the hardware ring buffer, much the same way that OSS does. I also think that the best way to handle this is to use double buffering. So the user app writes to a ring buffer, and alsa just copies one period at a time to the hardware buffer each time periods_elapsed is called. This will introduce latency, but the latency will be small, and acceptable in my view, until applications switch to using alsa direct. If an interrupt is missed, samples will just get lost. Recently, some latency profiling code is being developed for the linux kernel, so soon we will be able to track and fix all those places in the kernel that hold onto the CPU for >1ms. Once all the critical sections in the kernel are fixed, low latency will be reliable for everyone. James ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: difference between OSS mmap and alsa mmap? [alsa-oss] 2004-08-24 14:30 ` James Courtier-Dutton @ 2004-08-24 15:47 ` Paul Davis 0 siblings, 0 replies; 8+ messages in thread From: Paul Davis @ 2004-08-24 15:47 UTC (permalink / raw) To: James Courtier-Dutton Cc: Jaroslav Kysela, Florian Schmidt, Takashi Iwai, alsa-devel >I also think that the best way to handle this is to use double buffering. >So the user app writes to a ring buffer, and alsa just copies one period >at a time to the hardware buffer each time periods_elapsed is called. this doesn't work. the whole point of the OSS mmap model is that the app always has access to the entire hardware buffer, not just the current period. this is why its so hard to make it work correctly in emulation mode. --p ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-08-24 15:47 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-07-05 12:42 difference between OSS mmap and alsa mmap? [alsa-oss] Florian Schmidt 2004-07-05 13:13 ` Paul Davis 2004-07-05 13:19 ` Takashi Iwai 2004-08-24 11:57 ` Florian Schmidt 2004-08-24 12:20 ` Florian Schmidt 2004-08-24 13:41 ` Jaroslav Kysela 2004-08-24 14:30 ` James Courtier-Dutton 2004-08-24 15:47 ` Paul Davis
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.