跳轉到內容

Linux/ALSA 音效卡配置與故障排除

來自 Wikibooks,開放書籍,開放世界

錯誤和解決方案

[編輯 | 編輯原始碼]

核心缺少必要的模組

[編輯 | 編輯原始碼]

表現為

  • 虛擬目錄/proc/asound不存在
  • 命令aplay -l返回沒有找到音效卡
  • 音效卡在一些硬體檢測機制下出現,例如 lspci

有時,這是由於在 dist-upgrade 中選擇性地刪除核心等模組,而沒有刪除相應的核心模組導致的。

解決方法

[編輯 | 編輯原始碼]

將必要的模組新增到你的核心中。在 Ubuntu 中,你可以透過以下命令升級到最新的核心和模組

 $ sudo apt-get install linux-generic

指定的音效卡無效

[編輯 | 編輯原始碼]

如果你遇到以下錯誤,則意味著你正在嘗試使用一個不存在或錯誤的裝置

$ cat /dev/urandom | aplay
ALSA lib pcm_hw.c:1207:(_snd_pcm_hw_open) Invalid value for card
aplay: main:546: audio open error: No such file or directory

解決方法

[編輯 | 編輯原始碼]

這可以透過明確指定裝置來解決。

 cat /dev/urandom | aplay -D hw:0,3

樣本錯誤

[編輯 | 編輯原始碼]

這是一個比較複雜的問題。本質上,硬體期望音訊樣本採用特定的資料型別,而你提供的型別錯誤。

 aplay: set_params:901: Sample format non available

解決方法

[編輯 | 編輯原始碼]

指定樣本格式,或修改 ALSA 配置檔案中的速率。

 cat /dev/urandom | aplay -f S16_LE ## Where S16_LE is your desired rate

無聲道道數

[編輯 | 編輯原始碼]

如果你沒有向 ALSA 提供你想要輸出的聲道數,你將會收到以下錯誤

 aplay: set_params:901: Channels count non available

解決方法

[編輯 | 編輯原始碼]

指定你想要輸出的聲道數。建議使用兩個聲道進行故障排除。

 cat /dev/urandom | aplay -c 2 ## Two channels is stereo sound
華夏公益教科書