mmap_commit() and hardware buffering
Hi,
I have an intel 8x0 card and Alsa 1.0.9.
Despite snd_pcm_hw_params_is_batch() and is_double() both returning false, the hardware seems to be double buffering the mmap buffer. That is, if I snd_pcm_mmap_commit() the whole buffer, and then immediately modify the buffer, the modification doesn't take effect - the sound hardware just outputs the original contents of the buffer.
Can anyone confirm whether these cards actually do double buffering? Or is there something else going on here?
I am trying to get wine's alsa driver behaving better. It was committing the whole buffer, then progressively committing the buffer again as it became available. The result on my system is that sounds play twice.
The best improvement I've got so far is to commit only a couple of periods worth of data at the beginning, and then commit a single period each time the callback is called (i.e. commit another period as a period is drained). This means the software mixer is able to stay ahead of the commit pointer. However it also means that the potential for buffer underrun is greatly increased, because there are only ever two periods committed.
My thinking is that for double-buffered cards, the driver could demand that the lock/unlock buffer calls be used (i.e. the direct sound layer has to lock part of the buffer before updating it, and unlock it when done), in which case the driver has much better info about how much it can commit (a portion of the buffer can be committed when it is unlocked).
For non-double buffered cards it would be better to use the previous strategy, however, as this allows just-in-time mixing. Unfortunately though is_batch() and is_double() seem to give incorrect information - so I'm not sure how to decide which strategy should be used.
Any ideas?
Also I'd be interested if there is any way to do just-in-time mixing (rendering) for double-buffered hardware?
Thanks,
Davin
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information
To be more specific, the hw is Intel ICH5 "with ALC850".
Davin
Quoted 26 lines · On Tue, 1 Nov 2005 16:56:51 +1100 Davin McCall <[email protected]> wrote:
Hi,
I have an intel 8x0 card and Alsa 1.0.9.
Despite
snd_pcm_hw_params_is_batch()andis_double()both returning false, the hardware seems to be double buffering the mmap buffer. That is, if Isnd_pcm_mmap_commit()the whole buffer, and then immediately modify the buffer, the modification doesn't take effect - the sound hardware just outputs the original contents of the buffer.Can anyone confirm whether these cards actually do double buffering? Or is there something else going on here?
I am trying to get wine's alsa driver behaving better. It was committing the whole buffer, then progressively committing the buffer again as it became available. The result on my system is that sounds play twice.
The best improvement I've got so far is to commit only a couple of periods worth of data at the beginning, and then commit a single period each time the callback is called (i.e. commit another period as a period is drained). This means the software mixer is able to stay ahead of the commit pointer. However it also means that the potential for buffer underrun is greatly increased, because there are only ever two periods committed.
My thinking is that for double-buffered cards, the driver could demand that the lock/unlock buffer calls be used (i.e. the direct sound layer has to lock part of the buffer before updating it, and unlock it when done), in which case the driver has much better info about how much it can commit (a portion of the buffer can be committed when it is unlocked).
For non-double buffered cards it would be better to use the previous strategy, however, as this allows just-in-time mixing. Unfortunately though
is_batch()andis_double()seem to give incorrect information - so I'm not sure how to decide which strategy should be used.Any ideas?
Also I'd be interested if there is any way to do just-in-time mixing (rendering) for double-buffered hardware?
Thanks,
Davin
Quoted 9 lines
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information
At Tue, 1 Nov 2005 16:56:51 +1100,
Quoted 6 lines · Davin McCall
Hi,
I have an intel 8x0 card and Alsa 1.0.9.
Despite
snd_pcm_hw_params_is_batch()andis_double()both returning false, the hardware seems to be double buffering the mmap buffer. That is, if Isnd_pcm_mmap_commit()the whole buffer, and then immediately modify the buffer, the modification doesn't take effect - the sound hardware just outputs the original contents of the buffer.
To be sure, do you call snd_pcm_mmap_begin() at each time?
Quoted 1 line
Can anyone confirm whether these cards actually do double buffering?
No, it's not.
Quoted 1 line
Or is there something else going on here?
Basically no double-buffer should happen with mmap mode. Although the mmap buffer provided though alsa-lib plugin isn't always the real hardware buffer. That is, the data ranged by snd_pcm_mmap_begin() is processed/transferred manually after mmap_commit().
Takashi
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
Quoted 3 lines · On Wed, 02 Nov 2005 11:49:39 +0100 Takashi Iwai <[email protected]> wrote:
Quoted 1 line
Despite
snd_pcm_hw_params_is_batch()andis_double()both returning false, the hardware seems to be double buffering the mmap buffer. That is, if Isnd_pcm_mmap_commit()the whole buffer, and then immediately modify the buffer, the modification doesn't take effect - the sound hardware just outputs the original contents of the buffer.To be sure, do you call
snd_pcm_mmap_begin()at each time?
Yes.
Quoted 4 lines
Quoted 2 lines
Can anyone confirm whether these cards actually do double buffering?
No, it's not.
Ok, thanks. I actually ended up reading the datasheet and came to the same conclusion, but it's good that someone else can verify this.
Quoted 8 lines
Quoted 2 lines
Or is there something else going on here?
Basically no double-buffer should happen with mmap mode. Although the mmap buffer provided though alsa-lib plugin isn't always the real hardware buffer. That is, the data ranged by
snd_pcm_mmap_begin()is processed/transferred manually aftermmap_commit().
Yes, that's the problem - it's using the plughw device instead of the hw device. Thanks again.
Davin
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
tir, 01,.11.2005 kl. 16.56 +1100, skrev Davin McCall:
Quoted 1 line
My thinking is that for double-buffered cards, the driver could demand that the lock/unlock buffer calls be used (i.e. the direct sound layer has to lock part of the buffer before updating it, and unlock it when done), in which case the driver has much better info about how much it can commit (a portion of the buffer can be committed when it is unlocked).
The TransGaming Cedega alsa driver does something like this - always. The overhead is negligible, it works on pretty much everything (barring dmix bugs, which AFAIK still remains a problem), and just-in-time mixing is possible (thanks to suggestions from the alsa developers).
This implementation was once upon a time offered to Wine in a wine-devel posting, but as is normal, there was no reply.
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download it for free - -and be entered to win a 42" plasma tv or your very own Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php