Fixed! Thanks again Sean. Apologies for not copying to the list previously. G
---- Sean Greenslade wrote ---- >(Re-added the list again. Please make sure to Reply-List or Reply-All >when responding to mailing list messages.) > >On Tue, Feb 15, 2022 at 10:56:55AM +0000, Geoff Browne wrote: >> Great! You cracked it Sean. >> >> > What user is the C code running as? >> >> Thank you Sean, I should have realised - it felt like something silly >> all along. The current C code has to be run with root privileges at >> the moment due to the need to access various low-level control >> registers. I'd assumed that with root privileges it would just work >> for any user, not realising that pulseaudio uses daemon sockets on a >> per-user basis. >> >> All I really want to do is to play short sine wave bleeps of varying >> frequency to the bluetooth speaker that i've paired with the Pi, maybe >> I'm making a mountain out of a molehill? > >There is a way to get root to use your user's pulseaudio session. You >just need to point it to pulse's socket and connection cookie. This can >be done via environment variables. For example, I ran the following on >my machine: > ># PULSE_SERVER=/run/user/1000/pulse/native >PULSE_COOKIE=/home/sean/.config/pulse/cookie pactl list > >Of course, you will need to substitute your user's correct UID and home >directory path. You should be able to set environment variables with the >setenv() C function in stdlib.h. > >--Sean >