UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    No audio unless media player is run as root

    Scheduled Pinned Locked Moved Solved Support
    2 Posts 1 Posters 302 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • N Offline
        newguy
        last edited by newguy

        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.

        N 1 Reply Last reply Reply Quote 0
        • N Offline
          newguy @newguy
          last edited by

          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: sun9ihdmi

          It 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.

          1 Reply Last reply Reply Quote 0
          • N newguy has marked this topic as solved on
          • First post
            Last post