DIGIT-ARC read-only archive · snapshot: July 23, 2026

Handling /dev/dsp in C

2 posts · originally from https://geek.digit.in/community/threads/handling-dev-dsp-in-c.45646/

desertwind
desertwind Original post #1
Jan 4, 2007 at 4:59 PM
Hi gurus,

For one of my project text2speech project, I want to access the sound device to play a sound file. Code is written in C like this

fd = open("/dev/dsp", O_RDWR);

if (fd < 0) {

perror("open of /dev/dsp failed");

exit(1);

}



The problem I am experiencing here is, if artsd (or any sound system) is holding this device I cannot use /dev/dsp. And I cannot guess the sound system running on the machine this program is going to run. If I kill artsd using kill -9 command, this will work. Can you people suggest a method to play PCM encoded sound using C code, irrespective of the sound driver/device in all target machines?
praka123
Jan 4, 2007 at 7:32 PM
perhaps for guessing the streaming device either gstreamer or others u can include lsof
Code:
etch:~# lsof |grep /dev/dsp
esd       4437    prakash    5w      CHR       14,3                5394 /dev/dsp