The volume of sound cannot be reduced in root mode

Based on ubuntu20.04/JP5.02, we found the volume of sound cannot be adjusted in root mode.
Here is the step to duplicate this issue:

  1. Plug in earphone
  2. Play video in root mode.
  3. Adjust the volume through the sound icon at top-right screen

if in user mode:
$ aplay /usr/lib/libreoffice/share/gallery/sounds/gong.wav
the volume can be adjusted by system top-right volume setting menu.
However, if in root mode,
$ sudo aplay /usr/lib/libreoffice/share/gallery/sounds/gong.wav
the volume cannot be change.
Could you please help to check such issue? Thanks.

Hi,
This looks expected since root user is not in audio group. A normal user is in the groups:

$ groups
nvidia adm cdrom sudo audio dip video plugdev render i2c lpadmin gdm sambashare weston-launch gpio

Hi Dane,

I thought so at first, while, i did the same test on JP4.5.1, the volume can be adjusted.
Here is groups display on JP4.5.1/ubuntu 18.04 OS.
$ groups
test adm cdrom sudo audio dip video plugdev i2c lpadmin gdm lightdm sambashare weston-launch gpio

I’m not really an audio person, but generally speaking, are you using a GUI app to reduce volume? Or command line? What is your exact method, and if you watch “dmesg --follow” while changing volume, is there any message? If command line, does it show any error logged? I would expect that if it is a permissions problem there might be a different log message or error compared to something else.

Hi LiuxDev

Thanks for your prompt response! both GUI (system menu/volume control) or command I have tried. for command line as follows:

$ pactl set-sink-volume alsa_output.platform-sound.analog-stereo 20%
$ aplay /usr/lib/libreoffice/share/gallery/sounds/gong.wav
$ pactl set-sink-volume alsa_output.platform-sound.analog-stereo 80%
$ aplay /usr/lib/libreoffice/share/gallery/sounds/gong.wav

the system volume can be changed. However, when play wav in root mode,

$ sudo aplay /usr/lib/libreoffice/share/gallery/sounds/gong.wav

command ‘pactl’ can’t change the volume.
Playing wav in urser mode or root mode, there’s no difference or permission message show when watching kernel log by command “dmesg --follow”.
What I found is ‘pulseaudio’ component can’t be run as root.

sudo pulseaudio
W: [pulseaudio] main.c: This program is not intended to be run as root (unless --system is specified).

However, JP4.5.1/ubuntu 18.04 has no issue.

On JP5.02, aplay command with verbose as follows:

$ aplay -v /usr/lib/libreoffice/share/gallery/sounds/gong.wav
Playing WAVE ‘/usr/lib/libreoffice/share/gallery/sounds/gong.wav’ : Signed 16 bit Little Endian, Rate 11025 Hz, Mono
ALSA <-> PulseAudio PCM I/O Plugin
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 11025
exact rate : 11025 (11025/1)
msbits : 16
buffer_size : 5513
period_size : 1378
period_time : 125000
tstamp_mode : NONE
tstamp_type : GETTIMEOFDAY
period_step : 1
avail_min : 1378
period_event : 0
start_threshold : 5513
stop_threshold : 5513
silence_threshold: 0
silence_size : 0
boundary : 6207086186423386112

sudo root mode:

sudo aplay -v /usr/lib/libreoffice/share/gallery/sounds/gong.wav
Playing WAVE ‘/usr/lib/libreoffice/share/gallery/sounds/gong.wav’ : Signed 16 bit Little Endian, Rate 11025 Hz, Mono
Plug PCM: Rate conversion PCM (48000, sformat=S16_LE)
Converter: libspeex (builtin)
Protocol version: 10002
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 11025
exact rate : 11025 (11025/1)
msbits : 16
buffer_size : 1881
period_size : 470
period_time : 42666
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 470
period_event : 0
start_threshold : 1881
stop_threshold : 1881
silence_threshold: 0
silence_size : 0
boundary : 1058908862385487872
Slave: Route conversion PCM (sformat=S16_LE)
Transformation table:
0 ← 0
1 ← 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 8192
period_size : 2048
period_time : 42666
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 8192
stop_threshold : 8192
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
Slave: Hardware PCM card 1 ‘NVIDIA Jetson Xavier NX APE’ device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 8192
period_size : 2048
period_time : 42666
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 8192
stop_threshold : 8192
silence_threshold: 0
silence_size : 0
boundary : 4611686018427387904
appl_ptr : 0
hw_ptr : 0

Is the problem solved then by not running as root/sudo? If you must run as root, then consider root can use sudo to become a regular user without any password. That user could be a “dummy” account used only for audio playback.

It’s not really reqirement in root mode. Just found such issue, we want to clarify it’s OS pulseaudio in ubuntu 20.04 worked as design or not. As you know, JP4.5.1 or JP4.6.2/ubuntu 18.04 has not such issue. Thanks.

Hi Weileng,
As you mentioned running PulseAudio in system mode likely is not the right choice.

Below is some more info related :
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/

Please let me if above info helps you.

Good to know this, thank you DRAMESH.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.