No audio unless media player is run as root
-
I'm running UBports 20.04 on a PinePhone.
An issue I've run into is no applications are able to produce sound when run as the regular user, phablet. This means the settings panel, web browser, and terminal applications such as mplayer cannot produce sound. Even when the volume controls are at max, no sound comes out, either through the phone's speak or through headphones when they are plugged in.
However, audio does work when applications are run as the root user. If I run "sudo mplayer audio-file.mp3" I get sound, but just "mplayer audio-file.mp3" produces no sound.
I've checked and the phablet user is part of the audio group. And the /dev/dsp and /dev/dsp1 devices are present and grant write access to the audio group.
Anyone else running into this? Anyone have a suggested fix? I'm a bit puzzled why phablet can't produce audio but root can.
Update: I have found that copying data directly to /dev/dsp can cause noise to be produced. For example, running "cat sound.wav >> /dev/dsp" causes noise to be produced by the phone's speaker. So I can confirm my user has write access to the audio device. It just seems media apps and web browsers run as my user (phablet) are not able to properly get audio to output while root can.
-
Update: I found the solution. At least when using command line programs like mplayer.
UBports on the PonePhone seems to default to trying to use PulseAudio, which doesn't work. It needs to be using ALSA, but the regular user account selects the wrong ALSA device by default. For some reason the root user gets the right device.
I used the "aplay -l" command to get a list of local audio devices:
$ aplay -l
card 0: PinePhone
card 1: sun9ihdmiIt seems the regular user is selecting card 1 when it needs to be selecting card 0.
So to play audio with mplayer (or other audio players) I need to manually specify card 0. With mplayer that looks like this:
mplayer -ao alsa:device=hw=0 audio-file.mp3
I'm currently looking for a way to make this selection permanent and consistent for all audio players, but for now I can at least funnel audio through mplayer on my PinePhone.
-