Re: Trying to do audio from CGI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27/12/20 7:33 am, Alan Corey wrote:
Directory:/data/mp3/Queen/-- Studio Albums --/(1975) A Night at the Opera/
Playing MPEG stream 1 of 1: 11 Queen - Bohemian Rhapsody.mp3 ...
[src/libout123/modules/portaudio.c:120] error: Failed to open
PortAudio default stream: Device unavailable
main: [src/mpg123.c:323] error: out123 error 7: failed to open device

Why is it now trying PortAudio?  And failing - Audacity works with it.
Could it be something not in www-data's path?

It might be a default for `mpg123` or `libao` (the back-end library used by `mpg123`). I haven't used `mpg123` for a long time now but I think in the man page, there's a documented flag to point it at a different back-end such as ALSA directly. (I switched to Ogg/Vorbis to "clean" out the illegally downloaded files I had in that format, and because MP3's licensing was a pain back in 2004. As a bonus, storage requirements shrunk by 40%.)

If the machine is acting as a music jukebox and nothing else, it probably makes sense to disable PulseAudio in this situation since there's only the one "user" of the sound card, PulseAudio really doesn't offer much other than maybe Bluetooth speaker connectivity (and there are ways to do that without PulseAudio too).

PulseAudio will need the user that runs it, to have "real-time" rights (configured in `/etc/security/limits.conf`). Not sure if `www-data` will have those rights as it's a rare requirement for CGI scripts. Alternatively, I think PulseAudio can be run in a "system" mode, have a read of its documentation, maybe that might work in your situation.

The other option you might want to look into, rather than trying to make PulseAudio or ALSA work as the CGI user, instead look at making a back-end daemon look after whistling up `mpg123` to play music, and have the CGI script talk to it via some IPC mechanism (SysV IPC, Unix domain sockets, private HTTP API, Redis/AMQP/MQTT whatever).

I'd strongly suggest having a look at `mpd`, as while there's probably some educational value to re-inventing the wheel, it looks like someone's done the work for you: `mpd` itself can act as that back-end service, and there are already web-based front-ends to talk to it.
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
  ...it's backed up on a tape somewhere.


_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user



[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux