mossball765
Posts: 6
Joined: Fri Mar 21, 2014 5:51 pm

Need Help With Apache and Audio Codecs

Fri Apr 04, 2014 12:24 am

Hi everyone,

I'm looking for some direction on how to give my apache server access to my usb audio codec. Right now, I'm running an site that switches the GPIO pins by calling python scripts. It appears that when these run, they run within the server and nothing is displayed on the screen.

I've written a similar python script that launches an executable with elevated permissions (this program launches darkice with a config file that points to the usb audio codec as its source). When I run this program in X, it runs fine and launches darkice. When I run it from the website on the apache server, it launches, but darkice fails because it can't access the USB codec.

My error log contains this information:
malformed header from script. Bad header=Copyright (c) 2008-2010, Akos : input.py, referer: http://wholehomeaudio/
ALSA lib pcm_hw.c:1401:(_snd_pcm_hw_open) , referer: http://wholehomeaudio/
Invalid value for card, referer: http://wholehomeaudio/
' referer: http://wholehomeaudio

Is there any way to open the USB codec to apache, or maybe use apache to launch the darkice executable in X?

I'm a bit of a noob at this stuff, and so far this is the only way I've been able to set things up. Any help you could offer would be great!

Thanks,
Stephen

mossball765
Posts: 6
Joined: Fri Mar 21, 2014 5:51 pm

Re: Need Help With Apache and Audio Codecs

Sat Apr 05, 2014 1:18 pm

I managed to solve this.

I'm using relays (controlled by gpio) to switch power to each port on a usb hub to electrically disconnect the unused audio codecs (there's 3 connected to the hub). When the python script I wrote to switch the ports is activated, it would switch on one codec, and disconnect the other 2, and then try to start darkice. The problem was, when the script ran, it switched the codec in, and then immediately tried to start darkice. When the input is switched on, it takes the pi a couple of seconds to register the device, and the python script was trying to start darkice before the codec was actually registered. I added a 5 second delay between when the input is switched on and when darkice tries to start, and the problem was resolved.

Stephen

Return to “Networking and servers”