andrewrk / libsoundio

C library for cross-platform real-time audio input and output
http://libsound.io/
MIT License
1.92k stars 229 forks source link

soundio_outstream_pause() doesn't un-pause immediately on ALSA #196

Open bmewj opened 5 years ago

bmewj commented 5 years ago

I'm using libsoundio to play notification sounds. These notification sounds are played once every 10 minutes, so I keep the stream paused in between notifications. When a notification sound needs to be played, I un-pause the stream, stream the samples, and then pause the stream again.

This works fine with CoreAudio on macOS, but fails with ALSA on Ubuntu: when I un-pause a stream that's been paused for a long time, the first few seconds worth of samples are not streamed to output. So, I tend to miss the entire notification sound.

Anyone know what this is down to? It feels like ALSA is 'detaching' streams that have been inactive for a long time, and then takes a bit of time to reattach them when un-paused. This seems fine to me, as long as I can tell when exactly I can actually start streaming sound. Any suggestions for what to do? Maybe manage it myself by completely opening and closing the stream when it's not in use?

Thanks, Bartholomew