I am running raspbian Jessie on my raspi 2. I have an external usb soundcard for my pi. I set it as the default card simply by going to Menu->preferences->Audio Device Settings. This works as expected.

I am writing some code that takes in a file and plays it among other things. The problem is that it must be run with sudo, which then ignores my soundcard and uses the internal card. Is there a way to apply the default soundcard setting to root? I have tried adding root to the audio group, but that didn't help.


  • What program are you using for playing? Do both users need to share the sound card?
    – CL.
    Apr 19, 2016 at 6:35
  • I don't know raspbian, but on Ubuntu (also a Debian derivative) I would use the menu editor to find what is launched when Audio Device Settings is run, then run it under sudo. If this doesn't work I would log into the root account and set the audio from there.
    – AFH
    Apr 19, 2016 at 11:14
  • @CL. I am using gstreamermm c++ wrappings for gstreamer. Yes, both my user (pi) and root need to use the soundcard. I don't need them to both be using the soundcard at the same time, I just need root to use it instead of the internal one.
    – Cole
    Apr 19, 2016 at 17:10
  • You'll have to find out how gstreamer is configured (PulseAudio? ALSA?).
    – CL.
    Apr 19, 2016 at 17:12
  • @CL. There is an element called autoaudiosink that scans all possible sinks and chooses what it thinks is best. I should probably go ahead and switch that to pulseaudiosink since that was my plan all along. Does pulseaudio use completely separate configurations from alsa?
    – Cole
    Apr 19, 2016 at 17:18


You must log in to answer this question.

Browse other questions tagged .