Skip to contentSkip to conversation

Bug: Alsa-lib 1.05 doesn't work with dmix plugin and noninterleaved mmap'ed access and regions-buffer ?

DISCUSSION Daniel Schnell 2 participants 3 messages Jul 30, 2004 – Aug 2, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I tried the official most recent version of the alsa-lib (V1.05) together with its counterparts alsa-utils and alsa-driver. Apparently this seems to be only an issue with alsa-lib, as a downgrade to V1.03 of the library alone worked again like a charm.

I write an application which uses a user-defined dmix plugin for sound output (and the snd-intel8x0 AC97 low level driver). The output gets Non-Interleaved Samples in seperate buffers per channel, floating-point, mmaped access and I use the zero-copy mechanism provided by regions. In my applications sound loop I use snd_pcm_mmap_begin() / snd_pcm_mmap_commit() to detemine how many samples have to be processed. I initialized the sound layer with a buffer size of 512 and a period size of 256. Sample Rate is 48000Hz.

I use the following device according to the configuration in /etc/asound.conf. Nevertheless the problem also exists with the standard dmix plugin (plug:dmix). This only triggers the effect a bit later.

pcm.dmixer {
    type dmix
    ipc_key 1027
    slave {
        pcm "hw:0,0"
        period_time 0
        period_size 256
        buffer_size 512
        periods 2
    }
    bindings {
        0 0
        1 1
    }
}

Normally, if I print out the values returned by snd_pcm_avail_update() and the chunks processed by snd_pcm_mmap_begin() / snd_pcm_mmap_commit() I get the following output:

256 frames available
256 chunked
256 frames available
108 chunked 148 chunked
256 frames available
...

But after some while I get:

...
257 (!) frames avilable
108 chunked 149 chunked
511(!) frames available
363 chunked 148 chunked

This seems to be where the problem arises, as I use the internal regions buffers, which are certainly allocated only to 256 frames (1024 bytes) and here a buffer overflow occurs. Afterwards the audio output ceases to work. I have not debugged into the alsa-lib, so these are only assumptions. But by thinking about it, it seems reasonable that this should be the problem.

This behaviour does not show for alsa-lib V 1.03.

Best regards,

Daniel.

#1 lore raw
Quoted 5 lines · Daniel Schnell

...
257 (!) frames avilable
108 chunked 149 chunked
511(!) frames available
363 chunked 148 chunked

Sorry, I don't understand this description.
Also, the dump of PCM configuration would be nice for analysis (snd_pcm_dump()).

Quoted 3 lines

This seems to be where the problem arises, as I use the internal regions buffers, which are certainly allocated only to 256 frames (1024 bytes) and here a buffer overflow occurs. Afterwards the audio output ceases to

You may get more frames available - it depends on hardware interrupt acknowledge (in some cases the interrupt is delayed by some reason).

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs

-------------------------------------------------------
This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com

#2 lore raw

The output fom snd_pcm_dump is attached. The output is the same for alsa-lib v1.05 or 1.03.

Even if I get more frames available than configured because of delayed hardware interrupts - how can I accomodate this with the zero copy approach of mmaped operations ? Make another while loop around snd_pcm_avail_update(), snd_pcm_mmap_begin(), snd_pcm_mmap_commit() to match the buffer sizes of the internally allocated region buffers? If this is the way to go: Ok. But it would be a clear inconveniance and furthermore no documentation or sample code shows any hint for that.

If it's not a bug: why has this behavior changed since ALSA Lib v1.03 ? Here I never get a "late interrupt".

Ciao,

Daniel.

----- Original Message -----
From: "Jaroslav Kysela" <[email protected]>
To: "Daniel Schnell" <[email protected]>
Cc: <[email protected]>
Sent: Friday, July 30, 2004 7:37 PM
Subject: Re: [Alsa-devel] Bug: Alsa-lib 1.05 doesn't work with dmix plugin and noninterleaved mmap'ed access and regions-buffer ?

Quoted 26 lines · Daniel Schnell
Quoted 6 lines

...
257 (!) frames avilable
108 chunked 149 chunked
511(!) frames available
363 chunked 148 chunked

Sorry, I don't understand this description.
Also, the dump of PCM configuration would be nice for analysis (snd_pcm_dump()).

Quoted 3 lines

This seems to be where the problem arises, as I use the internal regions buffers, which are certainly allocated only to 256 frames (1024 bytes) and here a buffer overflow occurs. Afterwards the audio output ceases to

You may get more frames available - it depends on hardware interrupt acknowledge (in some cases the interrupt is delayed by some reason).

Jaroslav

-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs