You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
No sound can be played when AIR application run under sudo with Linux.
Sometimes multimedia applications should be run with root privileges (for example when autostart enabled). That's why it crucial.
Seems there is multiple similar issues with Video with audio playback too, with NetStream::appendBytes(), with M4A audio playback via NetStream and SoundSampleDataEvent.SAMPLE_DATA.
Tested with multiple AIR versions, even with latest AIR 51.1.1.3 with multiple different Linux x86_64 devices (VM and real), different OS versions and different applications.
Same issue almost in all cases using Ubuntu 22/24.
There is no such issue without sudo.
There is almost no such issues using ffplay.
There is no such issue with other platforms.
package {
import flash.display.Sprite;
import flash.media.Sound;
import flash.net.URLRequest;
public class LinuxSoundRootBug extends Sprite {
public function LinuxSoundRootBug() {
var sound:Sound = new Sound(new URLRequest('audio.mp3'));
sound.play();
}
}
}
Actual Result:
No audio played. No exceptions or errors in Scout.
In terminal you will see:
Gtk-Message: 16:39:25.252: Failed to load module "canberra-gtk-module"
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
MESA: error: ZINK: failed to choose pdev
glx: failed to create drisw screen
Expected Result:
Audio will be played.
Known Workarounds
Launch application with sudo -E: sudo -E ./linux_sound_root_bug
Launch application with XDG_RUNTIME_DIR environmental variable: sudo XDG_RUNTIME_DIR=/run/user/1000 ./linux_sound_root_bug
Write native extension to set up XDG_RUNTIME_DIR environmental variable just after AIR application start under sudo.
For simple cases you can use:
if (!getuid()){//If run under root (sudo)
const char* sudoUID = std::getenv("SUDO_UID");
//Set up XDG_RUNTIME_DIR value
std::string xdgRuntimeDirValue = "/run/user/" + std::string(sudoUID);
setenv("XDG_RUNTIME_DIR", xdgRuntimeDirValue.c_str(), 1)
}
But for proper solution (if your application launches via systemd for example) you should properly get UID via loginctl or by another methods.
The text was updated successfully, but these errors were encountered:
Problem Description
No sound can be played when AIR application run under sudo with Linux.
Sometimes multimedia applications should be run with root privileges (for example when autostart enabled). That's why it crucial.
Seems there is multiple similar issues with
Video
with audio playback too, withNetStream::appendBytes()
, with M4A audio playback viaNetStream
andSound
SampleDataEvent.SAMPLE_DATA
.Tested with multiple AIR versions, even with latest AIR 51.1.1.3 with multiple different Linux x86_64 devices (VM and real), different OS versions and different applications.
Same issue almost in all cases using Ubuntu 22/24.
There is no such issue without sudo.
There is almost no such issues using ffplay.
There is no such issue with other platforms.
Related issues:
#1984
#1041 (comment)
#365
#224
#15
Steps to Reproduce
Launch application with code below with any Linux under sudo:
sudo ./linux_sound_root_bug
It should play audio via
Sound
.Application example with sources and audio sample attached.
linux_sound_root_bug.zip
Actual Result:
No audio played. No exceptions or errors in Scout.
In terminal you will see:
Expected Result:
Audio will be played.
Known Workarounds
sudo -E
:sudo -E ./linux_sound_root_bug
XDG_RUNTIME_DIR
environmental variable:sudo XDG_RUNTIME_DIR=/run/user/1000 ./linux_sound_root_bug
XDG_RUNTIME_DIR
environmental variable just after AIR application start under sudo.For simple cases you can use:
But for proper solution (if your application launches via systemd for example) you should properly get UID via
loginctl
or by another methods.The text was updated successfully, but these errors were encountered: