Date: Sat, 28 Jan 2012 13:36:50 +0200 From: Alexander Motin <mav@FreeBSD.org> To: Ruslan Bukin <br@bsdpad.com> Cc: freebsd-multimedia@FreeBSD.org Subject: Re: multi-mono-channel sound card Message-ID: <4F23DDD2.7000804@FreeBSD.org> In-Reply-To: <20120128102235.GA39995@jail.io> References: <mailpost.1327157687.2711952.14470.mailing.freebsd.multimedia@FreeBSD.cs.nctu.edu.tw> <4F1ADDC8.90104@FreeBSD.org> <20120122163828.GA18783@jail.io> <20120128102235.GA39995@jail.io>
next in thread | previous in thread | raw e-mail | index | archive | help
On 28.01.2012 12:22, Ruslan Bukin wrote: > On Sun, Jan 22, 2012 at 08:38:28PM +0400, Ruslan Bukin wrote: >> On Sat, Jan 21, 2012 at 05:46:16PM +0200, Alexander Motin wrote: >>> On 01/21/12 16:12, Ruslan Bukin wrote: >>>> My multichannel sound card (RME HDSPe AIO) is support >>>> SND_FORMAT(AFMT_S32_LE, 1, 0) only. >>>> >>>> I call pcm_addchan(..), which triggers chan_init(..,*snd_dbuf,..) >>>> Addr of snd_dbuf I write to card in slot N. >>>> In result I have /dev/dsp0.pN devices (one device per each mono channel) >>>> >>>> Works perfectly, sounds great, but in mono mode. >>>> >>>> I'm interested, what is the right way to implement >>>> stereo pair of channels per one device file like in OSS? >>> >>> pcm_addchan() registers set of equal playback/record channels that >>> are supposed to be mixed into the same signal. It is hardware >>> equivalent of vchans. It has nothing common with multiple speakers. >>> >>> Multichannel audio is always multiplexed and AFAIk there is no >>> demultiplexing in sound(4). Sound(4) can upmix/downmix channels, >>> change their order, format, rate, but not demultiplex. >>> >>> I see only two ways: >>> - implement demultiplexing in driver -- that is not easy, but I >>> believe it should be possible; >>> - export each input/output connector as separate PCM device and let >>> some user level software to do demultiplexing -- that is easy and >>> that is what snd_emu10kx does. snd_emu10kx(4) recommends to use >>> pulseaudio for demultiplexing. >> >> Thanks. I have implemented demultiplexing. Works great. >> I will release the driver soon. >> > > Not great, actually. Demultiplexing need some time, > but seems that PCMTRIG_EMLDMAWR event trigger is not the > moment where we have it. > > If I just copy buffer (memcpy) on PCMTRIG_EMLDMAWR no problem at all, > card generates 12k IRQ/s. > > but simple demultiplex (for loop) on each IRQ reduce speed to 6-10k IRQ/s > and causes producing high-pitched sound goes from some chip > on card or may be motherboard (its difficult to identify source) It can be CPU power converter, when power consumption jumps up and down when CPU is woken up by interrupt. > it happens only on small period sizes, like 32 samples > (choices are 32,64,..4096). > > samples - IRQ/s > 32 - 12k > 64 - 6k > 128 - 3k > 256 - 1.5k > 512 - 0.6k > 1024 - 0.3k > 2048 - 0.15k > 4096 - 0.08k > > card bufsize is 64k bytes (16k samples) Interrupt rate depends on what fragment size you are setting on the card. The smaller fragment size is, the lower I/O latency, but higher interrupt rate. sound(4) has mechanism to set fragment size depending on current format to control latency, but you can change it if your card has some limitations. > so we have only 1/12k = 0.0000833s to demultiplex, > but it is not possible, right? Yes, you have 1/12ks to do it in worst case, but you only need to handle data for 1/12k of second from the last tick. So this should be not so difficult. -- Alexander Motin
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F23DDD2.7000804>