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

Sound sharing support #4

Open
ShutdownRepo opened this issue Feb 14, 2023 · 4 comments · May be fixed by ThePorgs/Exegol#141
Open

Sound sharing support #4

ShutdownRepo opened this issue Feb 14, 2023 · 4 comments · May be fixed by ThePorgs/Exegol#141
Assignees
Labels
wrapper Wrapper

Comments

@ShutdownRepo
Copy link
Member

No description provided.

@TahiTi
Copy link

TahiTi commented Feb 22, 2023

Two different choices :

  1. ALSA : Native audio driver, can only support one audio source simultaneously.
  2. PulseAudio :
    PulseAudio works as a server/client solution. There are multiple possibilities to make it work:
  • Using host system's PulseAudio server socket:
    The container mounts the host's PulseAudio socket and specifies the default-server parameter in the client.conf file within the container.
  • Using host system's PulseAudio server port:
    PulseAudio server creates a tcp socket on 127.0.0.1:4713 by default.
    Configure the default-server parameter in the client.conf file within the container pointing to the server's tcp socket.

I tried both approaches without success. Will look into it a bit more this week

@Dramelac
Copy link
Member

I had already poc this subject a long time ago, it is possible to share the socket pulse of the host and also the simplest it allows to delegate the configuration to the host and bonus it will be also supported on windows with WSLg.

@ShutdownRepo ShutdownRepo linked a pull request Feb 23, 2023 that will close this issue
@ShutdownRepo
Copy link
Member Author

I tried to get some inspiration from the following sources to make it work through a mac, to no avail...

It basically comes back to running this:

# from the host
brew install pulseaudio
sed -i '' 's/#load-module module-esound-protocol-tcp/load-module module-esound-protocol-tcp/' /opt/homebrew/Cellar/pulseaudio/14.2_1/etc/pulse/default.pa
sed -i '' 's/#load-module module-native-protocol-tcp/load-module module-native-protocol-tcp/' /opt/homebrew/Cellar/pulseaudio/14.2_1/etc/pulse/default.pa
pulseaudio --load=module-native-protocol-tcp --exit-idle-time=-1 --daemon --verbose
exegol start soundtest nightly --env "PULSE_SERVER=host.docker.internal" --volume "~/.config/pulse:/root/.config/pulse"

# from the container
apt-get update && apt-get install -y alsa-utils libasound2 libasound2-plugins pulseaudio pulseaudio-utils --no-install-recommends
usermod -aG audio,pulse,pulse-access root
wget https://raw.githubusercontent.com/jessfraz/dockerfiles/master/pulseaudio/client.conf -O /etc/pulse/client.conf
wget https://raw.githubusercontent.com/jessfraz/dockerfiles/master/pulseaudio/daemon.conf -O /etc/pulse/daemon.conf
wget https://raw.githubusercontent.com/jessfraz/dockerfiles/master/pulseaudio/default.pa -O /etc/pulse/default.pa
## add the host.docker.internal address subnet to /etc/pulse/default.pa auth-ip-acl
wget https://www.cjoint.com/doc/21_07/KGzngdVKbrk_Rick-Astley---Never-Gonna-Give-You-Up.wav -O rick.wav
paplay /workspace/rick.wav --verbose

But sadly I got no sound output on my mac. Here are a few things I checked

  • host.docker.internal points to my host, which can be pinged from the container
  • ✅ the pulseaudio port (default: 4713) is open and listening from the mac (lsof -Pi TCP -s TCP:LISTEN | grep 4713)
  • ✅ container can reach the PULSE_SERVER addr and port (host.docker.internal:4713)
  • ✅ can't see any error, either from the host or the container when running the commands above. PulseAudio server is running on the host and the client runs paplay smoothly
  • ❌ tried to run paplay rick.wav directly from the mac but got no sound output.
  • ❌ tried different sound output sources (earphones & speakers)

I've probably missed something more or less obvious 🤷

If we manage to make what I've described above work, I think it could apply to Linux and Windows as well

More generally we would need to have:

  • the user's host install and run a PulseAudio server
  • the wrapper to set the right environment variable (PULSE_SERVER, probably need to adapt value to network mode?), share the PulseAudio cookie file at ~/.config/pulse/cookie, probably edit the container's /etc/pulse/default.pa (to add the right subnet in the auth-ip-acl)
  • the images to have pulseaudio (and requirements) installed

Sound support is important as it would allow to

  • install and run SDR tools
  • improve overall experience, especially for CTFers (vlc, pulseaudio, sonic visualizer, ...)
  • improve the desktop feature

@ShutdownRepo ShutdownRepo transferred this issue from ThePorgs/Exegol Oct 19, 2023
@ShutdownRepo ShutdownRepo added the wrapper Wrapper label Oct 19, 2023
@Dramelac
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wrapper Wrapper
Projects
Status: Working on it
Development

Successfully merging a pull request may close this issue.

3 participants