[pulseaudio-discuss] Seeking advice on use of padsp

Sean Greenslade sean at seangreenslade.com
Tue Feb 15 07:28:14 UTC 2022


(Re-added the mailing list)

On Fri, Feb 11, 2022 at 02:05:34PM +0000, Geoff Browne wrote:
> On 11/02/2022 07:49, Sean Greenslade wrote:
> > On Mon, Feb 07, 2022 at 01:21:34PM +0000, Geoff Browne wrote:
> > > If I type the following at the terminal I get the expected tone..
> > > 
> > > 
> > > ...but if I try this from within some C code on a R-Pi Zero...
> > > 
> > > system("/usr/bin/padsp  /usr/bin/tones sine 100 900");
> > > 
> > > I get...
> > > [tones] Connection refused : /dev/dsp
> > Are these commands both being run on the same device, same user, etc.?
> > What distro of linux are you running on the RPi?
> > 
> > > and with -d on...
> > > 
> > > utils/padsp.c: dsp_open()
> > > utils/padsp.c: fd_info_new()
> > > utils/padsp.c: pa_context_connect() failed: Connection refused
> > > utils/padsp.c: freeing fd info (fd=4)
> > > utils/padsp.c: Draining.
> > > utils/padsp.c: dsp_open()
> > > utils/padsp.c: fd_info_new()
> > > utils/padsp.c: pa_context_connect() failed: Connection refused
> > > utils/padsp.c: freeing fd info (fd=4)
> > > utils/padsp.c: Draining.
> > > [tones] Connection refused : /dev/dsp
> > > 
> > > Can anyone please put me right ?
> > "pa_context_connect() failed: Connection refused" typically means that
> > pulseaudio is not running. You can confirm this by running a pactl
> > command, for example:
> > 
> > $ pactl list sinks
> > 
> > Would output the following if pulse is not running:
> > 
> > Connection failure: Connection refused
> > pa_context_connect() failed: Connection refused
> > 
> Hi Sean,
> 
> Thank you, I really appreciate your coming back to me.
> 
> Yes, all on the same R-Pi ZeroW (PRETTY_NAME="Raspbian GNU/Linux 10 (buster)).
> '$ pactl list sinks' returns the details of my bluetooth speaker.
> 
> To clarify the issue, If I ssh into the pi and enter...
> "/usr/bin/tones sine 100 900", I get "[tones] No such file or directory : /dev/dsp".
> 
> This is because a wrapper 'padsp' is required, so if I then enter...
> "/usr/bin/padsp  /usr/bin/tones sine 100 900", a sound is played as expected.
> 
> However, if I make the same call from some C running on same Pi:
> "system("/usr/bin/padsp  /usr/bin/tones sine 100 900");" I get error: "[tones] Connection refused : /dev/dsp".
> If I add the -d switch to padsp, I get the
> 
> utils/padsp.c: pa_context_connect() failed: Connection refused
> 
>  Interesting that the two errors are not quite the same ?  Something to do with how padsp works ?

What user is the C code running as? And what is executing it? If you,
for example, were running the program through a systemd service unit,
that would by default run as root and would not see your local user's
pulseaudio daemon socket.

I don't think there's anything specific to padsp in this regard. You
would probably see the same issue running any pulse utility, e.g. "pactl
list".

--Sean
 


More information about the pulseaudio-discuss mailing list