pulseaudio daemon.conf 配置翻譯 卡頓問題


由於公司藍牙音箱的項目用到pulseaudio

出現了卡頓,google了很多資料覺得配置文件真的得好好看看

pulseaudio 官方的配置說明
arch linux 關於pulseaudio 的問題說明
其中最重要的配置是關於聲音算法的配置
resample-method= The resampling algorithm to use. Use one of src-sinc-best-quality, src-sinc-medium-quality, src-sinc-fastest, src-zero-order-hold, src-linear, trivial, speex-float-N, speex-fixed-N, ffmpeg. See the documentation of libsamplerate for an explanation for the different src- methods. The method trivial is the most basic algorithm implemented. If you're tight on CPU consider using this. On the other hand it has the worst quality of them all. The Speex resamplers take an integer quality setting in the range 0..9 (bad...good). They exist in two flavours: fixed and float. The former uses fixed point numbers, the latter relies on floating point numbers. On most desktop CPUs the float point resmampler is a lot faster, and it also offers slightly better quality. See the output of dump-resample-methods for a complete list of all available resamplers. Defaults to speex-float-3. The --resample-method command line option takes precedence. Note that some modules overwrite or allow overwriting of the resampler to use.

二次采樣的算法=src-sinc-best-quality 最好的聲音品質,
src-sinc-medium-quality 一般pc采用的品質
當你采用嵌入式開發藍牙音箱,那么選擇 trivial 比較好,因為對CPU的壓力最小.
pulseaudio 是很強大的工具.如果的CPU足夠強大,很多算法可以采用.有低音炮的優化......

聲音片段的設置
//=======================================================================================================================

查找您的音頻設備參數(1/4)
要了解您的聲卡緩沖設置是什么,請使用以下命令並滾動輸出,直到找到正確的接收器條目。

$ pactl list sinks
Sink#1
狀態:RUNNING
名稱:alsa_output.pci-0000_00_1b.0.analog立體聲
說明:內置音頻模擬立體聲
驅動程序:module-alsa-card.c
示例規格:s16le 2ch 44100Hz
頻道映射:前左,前- 右
所有者模塊:7
靜音:否
音量:左前:42600/65%/ -11.22 dB,右前:42600/65%/ -11.22 dB
平衡0.00
基本音量:65536/100%/ 0.00 dB
監聽源:alsa_output.pci-0000_00_1b.0.analog-stereo.monitor
延遲:70662 usec,配置85000 usec
標志:HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
屬性:
alsa.resolution_bits =“16”
device.api =“alsa”
device.class =“sound”
alsa.class =“generic”
alsa.subclass =“generic-mix”
alsa.name =“ALC283 Analog”
alsa.id =“ALC283 Analog”
alsa.subdevice = “0”
alsa.subdevice_name = “ subdevice#0”
alsa.device =“0”
alsa.card =“1”
alsa.card_name =“HDA Intel PCH”
alsa.long_card_name =“HDA Intel PCH at 0xe111c000 irq 43”
alsa。 driver_name =“snd_hda_intel”
device.bus_path =“pci-0000:00:1b.0”
sysfs.path =“/devices/pci0000 :00/0000:00:1b.0/ sound/card1”
device.bus =“pci “
device.vendor.id =“8086”
device.vendor.name =“Intel Corporation”
device.product.id =“9ca0”
device.product.name =“Wildcat Point-LP High Definition Audio Controller”
device.form_factor =“internal”
device.string =“front:1”
device.buffering.buffer_size =“352800”
device.buffering.fragment_size =“176400”
device.access_mode =“mmap + timer”
device.profile.name =“analog-stereo”
device.profile.description =“Analog Stereo”
device.description =“Built-in Audio Analog Stereo “
alsa.mixer_name =”Realtek ALC283“
alsa.components =”HDA:10ec0283,10ec0283,00100003“
module-udev-detect.discovered =”1“
設備。icon_name =“audio-card-pci”
端口:
模擬輸出揚聲器:揚聲器(優先:10000,不可用)
模擬輸出耳機:耳機(優先:9000,可用)
有效端口:模擬輸出耳機
格式:
pcm
...
記下相關聲卡的值buffer_size和fragment_size值。

以毫秒為單位計算碎片大小(2/4)
PulseAudio的默認采樣率和位深度設置為44100Hz@ 16 bits。

使用這種配置,我們需要的比特率是44100* 16= 705600每秒的位數。那就是1411200 bps立體聲。

我們來看看我們在上一步中找到的參數:

device.buffering.buffer_size =“352800”=> 352800/1411200 = 0.25 s = 250 ms
device.buffering.fragment_size =“176400”=> 176400/1411200 = 0.125 s = 125 ms
修改PulseAudio的配置文件(3/4)
/etc/pulse/daemon.conf
; default-fragments = X
; default-fragment-size-msec = Y
在上一步中,我們計算了片段大小參數。片段數是簡單的buffer_size / fragment_size,在這種情況下(250/125)是2:

/etc/pulse/daemon.conf
; default-fragments = 2
; default-fragment-size-msec = 125
重新啟動PulseAudio守護進程(4/4)
$ pulseaudio -k
$ pulseaudio - 啟動
//=============================================================================

經過測試 是這個參數導致的卡頓
default-fragment-size-msec
The duration of a single fragment. Defaults to 25ms (i.e. the total buffer is thus 100ms long).
私人翻譯如下.
單個片段的持續時間.默認是25ms,因為前面的片段設置是 4個片段,那么這個例子中的片段就是100ms.

個人認為這個就是音頻流的緩沖buffer.
不知道為什么這個參數會卡.按照上面的計算方法.設置為2ms(原本是1.25ms)似乎不能設置為小數... ...
但是這樣CPU的占用率提高了很多從20%一下子沖到40%.
但是不卡了... ...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM