简体   繁体   English

ALSA:无法打开音频设备:没有这样的文件或目录

[英]ALSA: Couldn't open audio device: No such file or directory

If I start my python program as root (I have to start it as root cause the keyboard-module) this problem accrued:如果我以 root 身份启动我的 python 程序(我必须以 root 身份启动它,因为键盘模块)这个问题产生了:

ALSA lib pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave
Stopping program
Stopping program
Traceback (most recent call last):
  File "[...]/run.py", line 26, in <module>
    main()
  File "[...]/run.py", line 11, in main
    GameStateManager.change_gamestate(SetupState())
  File "[...]/src/game_state.py", line 103, in __init__
    self.setup_sound_manager()
  File "[...]/src/game_state.py", line 110, in setup_sound_manager
    GameState.sound_manager = SoundManager()
  File "[...]/src/utils.py", line 253, in __init__
    mixer.init()
pygame.error: ALSA: Couldn't open audio device: No such file or directory

If I run aa sound manually with sudo aplay test.wav than this error comes up:如果我使用sudo aplay test.wav手动运行 aa 声音,则会出现此错误:

ALSA lib pcm_dmix.c:1032:(snd_pcm_dmix_open) unable to open slave

System系统

                    /-                      
                   ooo:                     ----------------------------
                  yoooo/                    OS: ArcoLinux
                 yooooooo                   Kernel: 5.17.4-arch1-1
                yooooooooo                  Uptime: 3 days, 23 hours, 2 mins
               yooooooooooo                 Packages: 1373 (pacman)
             .yooooooooooooo                Shell: zsh 5.8.1
            .oooooooooooooooo               Resolution: 1920x1080
           .oooooooarcoooooooo              WM: i3
          .ooooooooo-oooooooooo             Theme: Arc-Dark [GTK2/3]
         .ooooooooo-  oooooooooo            Icons: Sardi-Arc [GTK2/3]
        :ooooooooo.    :ooooooooo           Terminal: alacritty
       :ooooooooo.      :ooooooooo          CPU: AMD Ryzen 5 2500U with Radeon Vega Mobile Gfx (8) @ 2.000GHz
      :oooarcooo         .oooarcooo         GPU: AMD ATI Radeon Vega Series / Radeon Vega Mobile Series
     :ooooooooy           .ooooooooo        Memory: 2015MiB / 6904MiB (29%)
    :ooooooooo   /ooooooooooooooooooo
   :ooooooooo      .-ooooooooooooooooo.
  ooooooooo-             -ooooooooooooo.
 ooooooooo-                 .-oooooooooo.
ooooooooo.                     -ooooooooo

Try to give full path of your sound file.尝试提供声音文件的完整路径。 Such as:如:

your/full/path/to/file/test.wav

If this didn't work, Your SDL default sound driver is alsa .如果这不起作用,您的 SDL 默认声音驱动程序是alsa You can change your sound driver using this command:您可以使用以下命令更改声音驱动程序:

import os
os.environ['SDL_AUDIODRIVER'] = 'dsp'
# Your code

Put these two lines very top of your code.将这两行放在代码的最顶部。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 主管服务无权访问音频设备(“设置 open_pcm 时出错:没有这样的文件或目录”) - Supervisor service doesn't have access to audio device (“Error while setting open_pcm: No such file or directory”) 使用ALSA通过回调打开音频 - Open audio with callback using ALSA 尝试打开图像时,T​​kinter“无法打开“pyimage1”:没有这样的文件或目录”错误 - Tkinter "couldn't open "pyimage1": no such file or directory" error when trying to open an image 无法打开目录中的音频文件 - Cannot open audio file in the directory I/O 错误:无法打开文件“发票/a.pdf”:没有这样的文件或目录 - I/O Error: Couldn't open file 'Invoice/a.pdf': No such file or directory 如何修复“_tkinter.TclError:无法打开”Island1.png“:没有这样的文件或目录”错误? - How to fix “_tkinter.TclError: couldn't open ”Island1.png“: no such file or directory” error? 我该如何解决错误_tkinter.TclError: couldn't open "sample.png": no such file or directory - How should I solve the error _tkinter.TclError: couldn't open "sample.png": no such file or directory _tkinter.TclError:无法打开“download.gif”:没有这样的文件或目录 - _tkinter.TclError: couldn't open "download.gif": no such file or directory 无法执行“ python”:没有这样的文件或目录 - couldn't execute “python”: no such file or directory 无法使用声音文件将音频存储为 MP3 文件 - Couldn't store audio as MP3 file using soundfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM