Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add audio support in docker container for gazebo simulation #7

Open
jacknlliu opened this issue Mar 18, 2018 · 1 comment
Open

add audio support in docker container for gazebo simulation #7

jacknlliu opened this issue Mar 18, 2018 · 1 comment

Comments

@jacknlliu
Copy link
Owner

jacknlliu commented Mar 18, 2018

audio and contact force are very import signals for physical interaction for human.

Human process the audio signal faster than image.

ALSA lib can't work in container even though PulseAudio(server) has been installed in the host.

AL lib: (WW) alc_initconfig: Failed to initialize backend "pulse"
ALSA lib confmisc.c:768:(parse_card) cannot find card '0'
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1251:(snd_func_refer) error evaluating name
ALSA lib conf.c:4292:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:4771:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directory
[Err] [OpenAL.cc:84] Unable to open audio device[default]
 Audio will be disabled.

Solution:

docker run --device /dev/snd \
	          -e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
	          -v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
	          --group-add $(getent group audio | cut -d: -f3) 

In container, we also need the following command to make sure the access to /dev/snd/*, if your user in container is not created by docker run option --user or USER in Dockerfile

sudo usermod -aG audio <your_user>

# or directly change the permission of /dev/snd/*
# sudo chmod a+rwx /dev/snd/*
# this will take effect directly, without restarting your container.

And then restart your container.

Reference

@jacknlliu jacknlliu changed the title add audio support in docker container for gazebo physics engine add audio support in docker container for gazebo simulation Mar 18, 2018
@jacknlliu
Copy link
Owner Author

jacknlliu commented Mar 18, 2018

Pulseaudio vs. ALSA

Pulseaudio is a sound server which allows multiple sound sources to be fed through to one or more sinks. AFAIK Alsa only works with one source at a time.... Actually I think that is wrong and Alsa does support multiple concurrent sources.

Found this diagram showing what it does:

pulseaudio-alsa

PulseAudio basically sits atop ALSA, and use it internally. ALSA is unable by itself to be used by multiple applications, so PulseAudio provides this functionality among others.

Reference

tfoote added a commit to osrf/rocker that referenced this issue Dec 24, 2018
Found here: jacknlliu/ros-docker-images#7
Also fixed typo in the config.

Tested using chromium in docker watching youtube.

Firefox seems to crash stil though.
tfoote added a commit to osrf/rocker that referenced this issue Dec 24, 2018
Found here: jacknlliu/ros-docker-images#7
Also fixed typo in the config.

Tested using chromium in docker watching youtube.

Firefox seems to crash stil though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant