snd_pcm_avail() & snd_pcm_writei() question using pulse plugin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I seem to be bumping into an issue when trying to play some audio on the
pulse plugin. After opening the pulse device using snd_pcm_open(), I'm
trying to:

    const float * data;
    long          length;

    // ...

    snd_pcm_sframes_t available = snd_pcm_avail(_handle);

    long written = snd_pcm_writei(_handle, inData,
                          length < available ? length : available);


now, what happens is that available returns an huge number, something
like 2097151 initially - which is 47 seconds of audio in 44.1kHz mono.
so I always end up sending the whole available data, which is say 5
seconds worth of audio. snd_pcm_writei() will always return the total
sample size as a return value, but actually nothing is played, just a
small 'blip' is to be heard. (and the same happens both in non-blocking
and blocking mode)

now, if I force the write length to be small, say 4440, then actually
snd_pcm_writei() will play the audio. but this is some arbitrary value...

so my question is: how to determine the most suitable & biggest buffer
length parameter for snd_pcm_writei()?


Akos

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user


[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux