问题
I have written an application using ALSA (snd_pcm_open, snd_pcm_readi, etc). The application works perfect locally on my machine. However, when I SSH to another machine and run it through the SSH connection, all calls to snd_pcm_open fails with a message "Device does not exist" or similar. The remote machine has a soundcard just as my local machine has.
What could be the problem here?
Thanks!
EDIT: If I run the application using the console on the remote computer (walk to the computer, login, run the application), the application runs fine.
回答1:
The problem might be with /dev/snd/*
access rights.
Be sure the user is in the audio group.
In my case, I had to do adduser $USER audio
, disconnect and then reconnect.
回答2:
Just to check for the obvious: Are the drivers for the sound card on the remote machine loaded and working correctly? Check /proc/asound/cards
and see so that the card is listed.
回答3:
Just to confirm...you have the application installed on the remote machine and the remote machine has otherwise working aplay etc? The remote machine must be set up so that if you were to login from the console and run the application, it would work
If this is the case then check your environment variables as sometimes they can be subtly different.
回答4:
Found the reason. Turns out /dev/audio
and the devices below /dev/snd/
where all owned by the user logged in on the remote computer, and readable/writable by no one else. For testing I applied chmod 777 /dev/audio /dev/snd/*
and it started working.
Anyone know how I can apply a bit more generous permissions to the audio devices for the remote computer (which will last after a reboot)?
来源:https://stackoverflow.com/questions/9190525/alsa-snd-pcm-open-over-ssh