TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: R.WIESER
from: FOLDEROL
date: 2020-01-03 15:27:00
subject: Re: ALSA sound cut short

On Fri, 3 Jan 2020 15:38:15 +0100
"R.Wieser"  wrote:

>Folderol,
>
>> ALSA is quite complicated at first. It's some time since I've worked
>> on it, but this is what I found out.
>>
>> It is a series of negotiations.
>[snip]
>
>Setting up the whole thing doesn't seem to be creating any kind of problems.
>
>And even though the code in the link I provided doesn't do a lot of error
>checking it does use the values returned by ALSA to both determine the size
>of the programs buffer as well as how many times it should send it.

Does it return the same number of channels as you want to send? If not you need
to work out *when* to actually send them!

>Its just that I have zero idea why the sound gets cut short, even though
>inserting a seconds long usleep( ) just before the snd_pcm_drain( ) call
>shows that the whole length of sound is there.
>
>Regards,
>Rudy Wieser

Alternatively, suggests a periods V buffersize issue to me.
I can't remember for sure, but I think ALSA runs 2 periods per buffer, so one
half of the buffer is played while you send to the other half, so if your
sample is longer than 1/2 buffer you'll lose the rest.

--
W J G

--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)

SOURCE: echomail via QWK@docsplace.org

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.