TIP: Click on subject to list as thread! ANSI
echo: rberrypi
to: R.WIESER
from: ELI THE BEARDED
date: 2020-01-03 22:11:00
subject: Re: ALSA sound cut short

In comp.sys.raspberry-pi, R.Wieser  wrote:
> I'm trying to generate a simple beep, and am heavily basing it on an example
> found here:
>
> http://www.linuxjournal.com/article/6735?page=0,0   Listing 3. Simple Sound
> Playback

All four listings on that page work for me.

> I've removed the reading from stdin and replaced it with filling the buffer
> with a simpel square wave.

So I have to wonder if you've introduced a bug in your code changes
which you have described but not shared.

> Question: How do I make the program wait until the full length of the
> written sound has been played - without resorting to throwing some
> best-guess "usleep( )" hacks into into it I mean.   In other words: what is
> missing from the example program I've been using ?

You might have more luck in a more general Linux group
(comp.os.linux.misc gets a fair amount of traffic) or a programming
group (comp.lang.c is active). But include your actual code.

I used a wrapper around "aplay" for ALSA sound playback when I made an
alarm clock. I fork a program that loops aplay for however long it takes
to play the sound file for one minute, while the parent program checks
the state of a GPIO input to detect silence button pushed. On push, it
then kills the child process.

Elijah
------
requires GPIO in both states at least once to handle either NO or NC switches

--- 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™.