Multiple simultaneous sound channels (sources) with X.org and Envy24 (M-Audio Audiophile 2496)

Konstantin Dimitrov kosio.dimitrov at gmail.com
Fri Dec 19 01:07:37 PST 2008


hi guys,

sorry that i'm not around here lately, but i'm busy with other things.

On Thu, Dec 18, 2008 at 10:58 PM, Scott Spare <scuppers at gmail.com> wrote:
> Stefan,
> Thank you for your detailed message. I am more than willing to test any new
> driver code for Envy24 that supports multiplexing if anyone creates it.  I
> looked at the code for the driver yesterday, but realized after about half
> an hour of reading code that driver debugging is way beyond my C ability.
>
> I was unable to figure out what that high-quality hardware mixing is called
> in the driver, or whether it's just automatically enabled, and so would be
> something that would have to be disabled explicitly by sending a signal to
> the chip to tell it not to use it.

it's easy to disable the hardware mixing, you can look at
snd_envy24ht(4) code in which hardware mixing is disabled, because
Envy24 from 172x family don't have hardware mixing like 1712 ones.
basically, you need to remove:

envy24_route(sc, ENVY24_ROUTE_DAC_1, ENVY24_ROUTE_CLASS_MIX, 0, 0);
envy24_route(sc, ENVY24_ROUTE_DAC_SPDIF, ENVY24_ROUTE_CLASS_DMA, 0, 0);

and pcm_register one instead of 5 channels.

> I would be very glad to use the hardware
> mixer if it was working.  Also I'm not really clear on what portion of all
> this is handled by the driver itself, and what's handled by the kernel
> modules.
>
> I looked around for datasheets for the VIA Envy24 chip itself, and couldn't
> find those.  I personally thank Konstantin and whoever else authored these
> drivers in the first place. How they did so without datasheets, I will never
> know.
>

all datasheets and a lot of documents written by me that describes
hardware design of particular card are here:

http://envy24.svobodno.com/

i created this site, so to be easy for future developers and
contributors to the driver.

Katsurajima Naoto wrote the snd_envy24(4) for M-Audio Delta DiO 2496
card only back in the 2001. since then he is out of reach and i truly
hope he is well and want to thank him once again for his tremendous
work on snd_envy24(4)!

few years ago, i just patched snd_envy24(4) to work on newer versions
of FreeBSD and add support for more cards. the latest code is in the
FreeBSD P4 repository:

http://perforce.freebsd.org/chv.cgi?CH=152970

i then re-used "Interleaved DMA Playback" code from snd_envy24(4) as a
base for snd_envy24ht(4) and wrote all the necessary hardware routines
for 172x family of Envy24 and support for a lot of different 172x
cards. (during the upcoming holidays i'm planning to move
snd_envy24ht(4) to P4 repository and make some updates to the code)

the "Interleaved DMA Playback" code can be used for both hardware
mixing and multichannel playback. it's very universal and probably can
be used with almost every multichannel card, not only Envy24-based
ones. maybe, someday someone will look at that code and move it from
snd_envy24(4) and snd_envy24ht(4) to the newpcm subsystem. that will
make drivers for multichannel audio controllers much simpler and will
allow newpcm to support multichannel.

konstantin

> FWIW, there's a web page on the chip itself at
> http://www.via.com.tw/en/products/audio/controllers/envy24/.
> The digital mixer is shown on that page in a block diagram, but the quality
> of the diagram is not so good.  There's a zip file for an "image kit" on
> that page, but that's just logos.
>
> Next steps: I think I'm going to try OSS again and see if I can get that
> virtual channel mixing thing working.  I might also look at the source of
> their envy24 support to see if that answers anything.  I kind of doubt it,
> but it's worth a shot.  I'd really prefer to use some kind of low-level
> solution like the hardware mixing or FreeBSDs vchans.  I think the driver
> may be disabling the vchans, but not sure.
>
> The driver itself has been working great with libao besides the multiplexing
> issue.  I use it every day to play music on Amarok.  What a great card.
> Thanks once again.
>
> Scott
>
> On Tue, Dec 16, 2008 at 6:46 PM, Stefan Ehmann <shoesoft at gmx.net> wrote:
>>
>> On Tuesday 16 December 2008 22:43:47 Scott Spare wrote:
>> > Multimedia gurus,
>> >
>> > I am looking for advice about the best way to handle the following
>> > situation:
>> > Playing sound with any two apps at the same time causes errors, sound
>> > stuttering and / or hangups.
>> >
>> > So far, I've tested and confirmed this problem under the following
>> > conditions:
>> > -Amarok is playing music and Pidgin tries to make noise to tell me
>> > someone's online.
>> > -XMMS is playing music and Pidgin tries to make noise.
>> > -XMMS and Amarok are both playing music at the same time.
>> > -Shell-FM is playing music and Pidgin tries to make noise.
>> >
>> > Expected behavior:
>> > Simultaneous sounds play simultaneously.
>> >
>> > Errors received:
>> > pcm0: play: dsp0.p0 play interrupt timeout, channel dead
>> > pcm0: play: dsp0.p1 play interrupt timeout, channel dead
>> >
>> > What I have tried so far:
>> > -I've enabled autovchans in sysctls: hw.snd.maxautovchans: 4.  This did
>> > not
>> > help.
>> > -Reading more, I became a bit confused about a message regarding the
>> > driver
>> > (or at least the hardware) supporting multiplexing natively
>>
>> It doesn't happen with all applications. Playing two files with mplayer
>> simultaneously works for instance. Don't think it has anything to do with
>> xorg
>> but haven't found out under what exact circumstances it fails.
>>
>> The hardware mixing seems to be buggy in some cases. But it seems to be
>> used
>> even if vchans is enabled. So there's no easy way to workaround that.
>>
>> Maybe someone could come up with a simple patch to disable the hardware
>> mixing
>> feature. I've tried some time ago but failed.
>>
>> > -So I installed OSS, thinking that maybe it could solve my multiple
>> > audio
>> > source problems, but got the same problem - stuttering sound when
>> > playing
>> > multiple sources, followed by instability.  I later learned that OSS
>> > hadn't
>> > loaded correctly, and didn't support multiple sound channels on FreeBSD
>> > anyway, and I am trying to avoid running a heavy sound server if
>> > possible...  so without any luck with OSS, I've now uninstalled it.  I'm
>> > open to suggestions.  Does anyone know how PC-BSD handles sound?  Maybe
>> > they've got it right for the desktop?  There's ALSA, ESD, ARTS, OSS
>> > FreeBSD
>> > version via ports, OSS 4Front version, vchans, hardware multiplexing and
>> > more.  Pretty confusing.
>>
>> It's been some time since I used the 4Front driver. There's something
>> called
>> virtual channel mixer or something similar. IIRC it provides several dsp
>> devices; but you need to explicitly specify which device to use. So it's
>> not
>> as comfortable as the shipped driver.
>>
>> Also some applications have troubles with the driver, e.g. you need to
>> patch
>> libao. But maybe that's already been fixed.
>>
>> --
>> Stefan
>
>


More information about the freebsd-multimedia mailing list