[pulseaudio-discuss] Audible plop at beginning when using pcat-simple
Sean Greenslade
sean at seangreenslade.com
Sat Sep 4 06:13:32 UTC 2021
On Fri, Sep 03, 2021 at 11:54:04AM +0200, mindfsck wrote:
> > Apologies for leading you down a dead-end. I've taken a closer look
> > at the code and found what the problem is. The pacat-simple.c example is
> > expecting raw PCM sample data in the file. Since you're giving it a .WAV
> > file, there is a metadata header at the beginning that it is trying to
> > interpret as audio.
> >
> > Try inserting this line just above the /* Read some data ... */ line:
> >
> > read(STDIN_FILENO, buf, 44); // Discard the .WAV header
>
> Thank you Sean, that did indeed the trick and my files play nicely now!
> Do you expect to add this WAV header detection (and skipping) in a future
> release or do you restrict it to PCM (and user code must skip)?
To be clear, I'm not a pulseaudio dev, just a [power] user. But it seems
to me that it's not within the purview of pulseaudio to do file parsing
/ interpretation. Especially in what purports to be a "simple" API.
Also, the code I showed above was just a quick and dirty hack to prove
what the issue was. If you're making an actual program, you would want
to do at least some basic parsing of the WAV header to select the
correct bitrate / channel / sample size values to fill out the
pa_sample_spec struct. As it sits now, those values are hard-coded, and
you would get glitchy / incorrect audio if you fed it a WAV file with
different parameters.
--Sean
More information about the pulseaudio-discuss
mailing list