[maemo-developers] DSP audio question

From: Andrew Zabolotny zap at homelink.ru
Date: Wed Oct 15 01:01:48 EEST 2008
Hello!

I've been looking lately into the sound subsystem of the NIT. I want to
try to make the audio subsystem more responsive and more compatible
with usual Linux software. I have a number of questions related to the
closed component of the audio subsystem - the /lib/dsp/modules/pcm2.o
module, and I'll be glad if somebody may answer them.

The first task may be achieved by modifying the alsa plugin (and maybe
later - the esd plugin) in order to write data to the DSP in small
portions, and a better implementation of the ALSA buffer/period
paradigm, so that software who cares about exact timing may get it.

About compatibility with existing Linux software: one of the
big problems is that the ALSA/DSP plugin does not support mmap access
method. Without this, many libraries (for example, the PortAudio
library, SDL alsa driver and others) will refuse to work with such a
device.

This seems relatively easy to implement, by either providing the client
program direct access to mmap'd area, or emulating this using an
intermediate buffer.

So, here are my first questions:

1. Is the mmap'd buffer directly shared with the DSP, and are the
samples played read all the time from the mmap'd buffer, or the DSP
task will copy the whole buffer at the time of the DSP_CMD_DATA_WRITE
command, and then play it from the internal buffer? In other words: can
I modify the buffer while it's playing, or it should stay intact until
it's finished playing?

2. Is it possible to know the exact position played in the data buffer
(or the number of samples left, or something like this)? I tried to use
the DSP_CMD_STATE command (samples_played_high and samples_played_low
members of the audio_status_info_t structure), and it behaves veeeery
strangely: first half of minute or so, while sound is playing, these
fields are always reported as 0 (???). After some time they suddenly
starts increasing, but contain a very strange value: after playing
12288 samples the samples_played_low field will increase by 1672 (???).

3. Are these DSP_CMD_XXX commands applicable to all DSP nodes, or just
to pcm_rec and pcm[0-3]? This is more of curiosity :)

These questions wouldn't arise if the source of pcm2.o would be
accessible, but unfortunately...

-- 
Andrew

P.S. And, by the way, I found a buglet in dsp-protocol.c:
it mmap's just half of the DSP mmap buffer, e.g. it maps
mmap_buffer_size BYTES while it's meant to be mmap_buffer_size WORDS).
This leads to crashes if you're trying to push into the DSP
mmap_buffer_size words...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.maemo.org/pipermail/maemo-developers/attachments/20081015/aeafb1e6/attachment.pgp 
More information about the maemo-developers mailing list