* mm functions vs. normal IO
@ 2008-03-03 22:40 Reiner
2008-03-04 7:58 ` Clemens Ladisch
0 siblings, 1 reply; 4+ messages in thread
From: Reiner @ 2008-03-03 22:40 UTC (permalink / raw)
To: alsa-devel
Hello,
I'am new for using ALSA API.
I was astonished that a simple wav playback example does not exist. But
after reading the pcm examples I have managed to make one (if I will
finish it I can post it so it can be added to the examples)
Now my question:
What should be used:
snd_pcm_mmap_commit
<http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m___direct.html#g3e3d8bb878f70e94a746d17410e93273>
(I think snd_pcm_mmap_writei
<http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m___direct.html#g3a811efcd9d64b60e6a25df6924d26b0>
is the same with an additional copy behind ?)
or
snd_pcm_writei
<http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gf13067c0ebde29118ca05af76e5b17a9>
I think mmap will have better performance, but will it work with all
soundcards? Or should it be in a config what to use?
I'am also looking for a function to get the number of played frames. I
have played around with "snd_pcm_status" but it seems not to have a
counter for this.
By the way is there a detailed tutorial (introduction) for ALSA
available? The online help is a little bit too short for newbies. ;-)
Reiner
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mm functions vs. normal IO
2008-03-03 22:40 mm functions vs. normal IO Reiner
@ 2008-03-04 7:58 ` Clemens Ladisch
2008-03-04 13:55 ` Reiner P
0 siblings, 1 reply; 4+ messages in thread
From: Clemens Ladisch @ 2008-03-04 7:58 UTC (permalink / raw)
To: Reiner; +Cc: alsa-devel
Reiner wrote:
> I was astonished that a simple wav playback example does not exist.
The alsa-lib package has test/pcm_min.c.
> What should be used:
>
> snd_pcm_mmap_commit
> (I think snd_pcm_mmap_writei is the same with an additional copy behind ?)
snd_pcm_mmap_writei is the same as calling snd_pcm_mmap_begin, copying
into the buffer, and calling snd_pcm_mmap_commit.
> or snd_pcm_writei
If you have to ask, use snd_pcm_writei.
> I think mmap will have better performance,
Only if the program generates samples on the fly and can write them
directly to the buffer in a format supported by the hardware.
If you already have the data in some buffer, copying it into the
device's buffer with snd_pcm_writei or snd_pcm_mmap_writei is just as
fast as when you copy it into the device's buffer by yourself.
> but will it work with all soundcards?
Not directly. ALSA has mmap emulation for cards that don't support it.
And there are devices where only support mmap access is
SND_PCM_ACCESS_MMAP_COMPLEX.
> I'am also looking for a function to get the number of played frames.
ALSA doesn't count them. This is nothing that a program couldn't do
trivially by itself.
HTH
Clemens
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mm functions vs. normal IO
2008-03-04 7:58 ` Clemens Ladisch
@ 2008-03-04 13:55 ` Reiner P
2008-03-04 14:04 ` James Courtier-Dutton
0 siblings, 1 reply; 4+ messages in thread
From: Reiner P @ 2008-03-04 13:55 UTC (permalink / raw)
To: alsa-devel
Hello,
ok, at the moment I use a simple read(...) to get the data from file
so mm should be ok.
Playing position:
I can count the frames I have written to the buffer but where is the
actual play position ???
What's the porpose of the triigerTimestamp in the status filed?
Thanks
Reiner
On Tue, Mar 4, 2008 at 8:58 AM, Clemens Ladisch <clemens@ladisch.de> wrote:
>
> Reiner wrote:
> > I was astonished that a simple wav playback example does not exist.
>
> The alsa-lib package has test/pcm_min.c.
>
>
> > What should be used:
> >
> > snd_pcm_mmap_commit
> > (I think snd_pcm_mmap_writei is the same with an additional copy behind ?)
>
> snd_pcm_mmap_writei is the same as calling snd_pcm_mmap_begin, copying
> into the buffer, and calling snd_pcm_mmap_commit.
>
> > or snd_pcm_writei
>
> If you have to ask, use snd_pcm_writei.
>
>
> > I think mmap will have better performance,
>
> Only if the program generates samples on the fly and can write them
> directly to the buffer in a format supported by the hardware.
>
> If you already have the data in some buffer, copying it into the
> device's buffer with snd_pcm_writei or snd_pcm_mmap_writei is just as
> fast as when you copy it into the device's buffer by yourself.
>
>
> > but will it work with all soundcards?
>
> Not directly. ALSA has mmap emulation for cards that don't support it.
> And there are devices where only support mmap access is
> SND_PCM_ACCESS_MMAP_COMPLEX.
>
>
> > I'am also looking for a function to get the number of played frames.
>
> ALSA doesn't count them. This is nothing that a program couldn't do
> trivially by itself.
>
>
> HTH
> Clemens
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mm functions vs. normal IO
2008-03-04 13:55 ` Reiner P
@ 2008-03-04 14:04 ` James Courtier-Dutton
0 siblings, 0 replies; 4+ messages in thread
From: James Courtier-Dutton @ 2008-03-04 14:04 UTC (permalink / raw)
To: Reiner P; +Cc: alsa-devel
Reiner P wrote:
> Hello,
>
> ok, at the moment I use a simple read(...) to get the data from file
> so mm should be ok.
>
> Playing position:
> I can count the frames I have written to the buffer but where is the
> actual play position ???
> What's the porpose of the triigerTimestamp in the status filed?
>
> Thanks
> Reiner
>
>
Use snd_pcm_delay()
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-03-04 14:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-03 22:40 mm functions vs. normal IO Reiner
2008-03-04 7:58 ` Clemens Ladisch
2008-03-04 13:55 ` Reiner P
2008-03-04 14:04 ` James Courtier-Dutton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.