(Fwd) ALSA related comments - please correct [wulfram-26284]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 6 lines · Peter Hunnisett
Quoted 5 lines
What's looping sound? You can initiate endless ring buffer looping when you set
stop_thresholdto boundary (sw_params). I think that this major drawback does not exist.
Quoted 8 lines
Thanks for pointing out that sound looping is possible in a reasonable and straightforward way. We had actually realized that we could have worked around this even if ALSA didn't provide support using a PCM callback and some double buffering but it wasn't obvious which is why the link you quoted above indicates the lack of looping support. The online documentation that we looked at certainly wasn't clear or particularly informative in showing this reasonably common usage so may I suggest improving it.
OK, I've added a few words to snd_pcm_sw_params_set_stop_threshold() and snd_pcm_sw_params_get_stop_threshold() functions.
Quoted 9 lines
We have been unable to find a way to tell ALSA, through
snd_pcm_mmap_begin(), where we want to write data when using the mmap api. OSS doesn't have this restriction and this is the only documented way we can see to support sound engines which mix in new sounds using looping buffers and "randomly" writing ahead of the playing position. We have seen that there are undocumented ways to support this functionality and we are leery of using undocumented functionality since it could disappear or change. Can you suggest a documented way to achieve the desired effect or would you be in favour of modifications to the API?
Use snd_pcm_forward() and snd_pcm_rewind() functions to move the application pointer in the ring buffer before snd_pcm_mmap_begin().
Note: The pointer for these functions is the stream pointer [0 ... (boundary - 1)]. The offset to the ring buffer is:
stream_pointer % ring_buffer_size
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Quoted 9 lines
Quoted 9 lines
We have been unable to find a way to tell ALSA, through
snd_pcm_mmap_begin(), where we want to write data when using the mmap api. OSS doesn't have this restriction and this is the only documented way we can see to support sound engines which mix in new sounds using looping buffers and "randomly" writing ahead of the playing position. We have seen that there are undocumented ways to support this functionality and we are leery of using undocumented functionality since it could disappear or change. Can you suggest a documented way to achieve the desired effect or would you be in favour of modifications to the API?
although i agree that from a pragmatic perspective, it would be good to understand how to use ALSA to do this.
however, this model of audio programming is not portable, and has gotten people into trouble before, not just under Linux.
making the assumption that direct access at all times to the full hardware buffer is not a valid assumption to make. there is a very popular audio interface API (ASIO) that explicitly denies this possibility, and there are audio interfaces out there that are not designed in a way that makes it possible to do what you are trying to do (i know that game programmers generally don't use ASIO).
its just my personal opinion of course, but i think it very unfortunate that game programmers have fallen into this model. by all means setup your *own* buffer and write anywhere into it. then transfer the relevant parts of your buffer to the device at interrupt time (i.e. when poll returns or when write is possible). but assuming that you can access the h/w buffer directly and more - that you can access all of it at any time, i don't believe that this is a good model.
i can understand that you don't like having to sync to the audio device interrupt. but not doing so leads to other problems as well.
just my $0.02, or perhaps less.
--p
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
Quoted 8 lines
although i agree that from a pragmatic perspective, it would be good to understand how to use ALSA to do this.
however, this model of audio programming is not portable, and has gotten people into trouble before, not just under Linux.
making the assumption that direct access at all times to the full hardware buffer is not a valid assumption to make. there is a very
sorry, terrible english. i hope you know what i meant :)
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials. Become an expert in LINUX or just sharpen your skills. Sign up for IBM's Free Linux Tutorials. Learn everything from the bash shell to sys admin. Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click