top-bettercode / docker-wechat

微信 docker 镜像
https://hub.docker.com/r/bestwu/wechat/
486 stars 69 forks source link

微信声音异常 #41

Closed braddw1 closed 2 years ago

braddw1 commented 3 years ago

ubuntu20.4,有时候,微信收到消息或者播放语音消息的时候,其他应用的声音就没有了,好像ubuntu报了pulseaudio clashed,然后我切换系统声音为显示器声音,其他应用可以用显示器自带的音箱发声,微信用音箱发声。 有时候就是,微信直接什么声音没有了,其他应用正常。

iaso2h commented 3 years ago

不看issues都不知道还有提醒声音,笑哭,一直以为就是静音的。KUbuntu 20.4

zhuhu00 commented 2 years ago

+1,之前一直沒有聲音,還以爲是沒有聲音的...

lishengfeng commented 2 years ago

希望对别人有帮助, 在20.04, 22.04下测试后都有声音

初次启用使用脚本:

rm -rf /tmp/pulseaudio.socket
rm -rf /tmp/pulseaudio.client.conf
pactl load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket
cat <<EOT >> /tmp/pulseaudio.client.conf
default-server = unix:/tmp/pulseaudio.socket
# Prevent a server running in the container
autospawn = no
daemon-binary = /bin/true
# Prevent the use of shared memory
enable-shm = false
EOT
xhost +
docker run -d --device /dev/snd --ipc=host \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v $HOME/WeChatFiles:/WeChatFiles \
    -v /tmp/pulseaudio.socket:/tmp/pulseaudio.socket \
    -v /tmp/pulseaudio.client.conf:/etc/pulse/client.conf \
    -e DISPLAY=unix$DISPLAY \
    -e XMODIFIERS=@im=fcitx \
    -e QT_IM_MODULE=fcitx \
    -e GTK_IM_MODULE=fcitx \
    -e PULSE_SERVER=unix:/tmp/pulseaudio.socket \
    -e PULSE_COOKIE=/tmp/pulseaudio.cookie \
    -e AUDIO_GID=`getent group audio | cut -d: -f3` \
    -e GID=`id -g` \
    -e UID=`id -u` \
    --name wechat \
    bestwu/wechat
xhost -

在container 创建之后不需要每次使用run,因为run = create + start. 如果使用run 每次都会创建一个新的container. 改使用脚本

rm -rf /tmp/pulseaudio.socket
rm -rf /tmp/pulseaudio.client.conf
pactl load-module module-native-protocol-unix socket=/tmp/pulseaudio.socket
cat <<EOT >> /tmp/pulseaudio.client.conf
default-server = unix:/tmp/pulseaudio.socket
# Prevent a server running in the container
autospawn = no
daemon-binary = /bin/true
# Prevent the use of shared memory
enable-shm = false
EOT
xhost +
docker stop wechat
docker start wechat
xhost -

资源: https://github.com/mviereck/x11docker/wiki/Container-sound:-ALSA-or-Pulseaudio