One way to solve the problem would be to have your program run as root, but have it call the sound emitter as a normal user.
From the shell, it should be possible to call the command-line media player
mplayer. This question gives more options on playing sound from the command line.
To make the bridge between programs, you should write a simple shell script that takes the sound file as input:
and call it with:
This question details how to run commands as a different user without the need for a password. Add the following to
your-sound-playing-user ALL=(root) NOPASSWD: /home/your-sound-playing-user/playsound.sh
From your root privileged application, you can then place a system call to:
sudo -u your-sound-playing-user /home/your-sound-playing-user/playsound.sh sound-to-play.mp3