搞不清楚之ubuntu pulseaudio
先說了,我搞不清楚ubuntu的pulseaudio。
備忘一:如何暫時關掉pulseaudio?
A: 網上有人問了也有人答了,見how-to-temporarily-disable-pulseaudio
個人偏好第二個答案,就是去/etc/pulse/client.conf設定檔,將autospawn=yes改成no,記得前面;是備註的意思,要把它去掉。這樣當我們下指令:
$ pulseaudio --kill
把pulseaudio關掉後,pulseaudio就不會再自己自動重新開啟了。
那如果我們想要打開pulseaudio,就下指令:
$ pulseaudio --start
狀況一:
使用MAC機器架VirtualBox,裝ubuntu 10.04,暫時關掉pulseaudio,發現aplay還可以正常運作:
$ aplay ~/音樂/01\ 慢火車.wav
正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲
$ aplay -Dhw:0,0 ~/音樂/01\ 慢火車.wav
正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=I82801AAICH
Intel 82801AA-ICH, Intel 82801AA-ICH
Default Audio Device
front:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
Front speakers
surround40:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
4.0 Surround output to Front and Rear speakers
surround41:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
iec958:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
IEC958 (S/PDIF) Digital Audio Output
就連aplay -L指令都可以正常的運作。
狀況二:
實體機器裝ubuntu 12.10,暫時關掉pulseaudio,發現aplay無法正常運作,播音樂聽不到聲音,aplay -L也無法正常列出應有的資訊。這個情況和網上朋友why-does-aplay-work-when-pulseaudio-is-running-and-else-not所說相符。
$ aplay -L
default
Playback/recording through the PulseAudio sound server
sysdefault:CARD=PCH
HDA Intel PCH, ALC892 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Front speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Digital
IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=PCH,DEV=0
HDA Intel PCH, HDMI 0
HDMI Audio Output
dmix:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct sample mixing device
dmix:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct sample mixing device
dmix:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct sample snooping device
dsnoop:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct sample snooping device
hw:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Hardware device with all software conversions
後來安裝了Qmmp軟體,在其設定中找到Output聲訊可以選擇:Alsa, Oss, PulseAudio等,我將其改為ALSA,如上圖。然後再將Pulseaudio暫時關掉,此時由Qmmp播放音樂,結果是可以聽到音樂的。這表示在關掉pulseaudio時,應該可以直接透過ALSA播放音樂。利用之前ALSA PCM的http://www.alsa-project.org/alsa-doc/alsa-lib/examples.html示範程式, 將device由原本的default之類,改成sysdefault:CARD=PCH,結果是可以聽到聲音的(在pulseaudio暫時關掉的情況下)。
但因為我在用ALSA PCM寫的程式播音樂時,把Qmmp關掉,此時自己寫的程式跳了一下,之後就無法再由自己寫的程式在pulseaudio關掉時播出聲音了!而且另一套軟體VLC,也有同様的問題,原本也是可以在設定的地方改成使用ALSA播出聲音,運作也沒問題;但是之後也無法正常運作了。可是有趣的是,Qmmp卻還能在關閉pulseaudio時運作正常。
狀況三:
實體機器裝ubuntu 13.04,行為和ubuntu 10.04很像,暫時關掉pulseaudio,發現aplay還可以正常運作。
備忘一:如何暫時關掉pulseaudio?
A: 網上有人問了也有人答了,見how-to-temporarily-disable-pulseaudio
個人偏好第二個答案,就是去/etc/pulse/client.conf設定檔,將autospawn=yes改成no,記得前面;是備註的意思,要把它去掉。這樣當我們下指令:
$ pulseaudio --kill
把pulseaudio關掉後,pulseaudio就不會再自己自動重新開啟了。
那如果我們想要打開pulseaudio,就下指令:
$ pulseaudio --start
狀況一:
使用MAC機器架VirtualBox,裝ubuntu 10.04,暫時關掉pulseaudio,發現aplay還可以正常運作:
$ aplay ~/音樂/01\ 慢火車.wav
正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲
$ aplay -Dhw:0,0 ~/音樂/01\ 慢火車.wav
正在播放 WAVE '/home/ops/音樂/01 慢火車.wav' : Signed 16 bit Little Endian, 速率 44100 Hz, 立體聲
$ aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=I82801AAICH
Intel 82801AA-ICH, Intel 82801AA-ICH
Default Audio Device
front:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
Front speakers
surround40:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
4.0 Surround output to Front and Rear speakers
surround41:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
iec958:CARD=I82801AAICH,DEV=0
Intel 82801AA-ICH, Intel 82801AA-ICH
IEC958 (S/PDIF) Digital Audio Output
就連aplay -L指令都可以正常的運作。
狀況二:
實體機器裝ubuntu 12.10,暫時關掉pulseaudio,發現aplay無法正常運作,播音樂聽不到聲音,aplay -L也無法正常列出應有的資訊。這個情況和網上朋友why-does-aplay-work-when-pulseaudio-is-running-and-else-not所說相符。
$ aplay -L
default
Playback/recording through the PulseAudio sound server
sysdefault:CARD=PCH
HDA Intel PCH, ALC892 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Front speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Digital
IEC958 (S/PDIF) Digital Audio Output
hdmi:CARD=PCH,DEV=0
HDA Intel PCH, HDMI 0
HDMI Audio Output
dmix:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct sample mixing device
dmix:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct sample mixing device
dmix:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct sample snooping device
dsnoop:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct sample snooping device
hw:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Direct hardware device without any conversions
hw:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
HDA Intel PCH, ALC892 Analog
Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
HDA Intel PCH, ALC892 Digital
Hardware device with all software conversions
plughw:CARD=PCH,DEV=3
HDA Intel PCH, HDMI 0
Hardware device with all software conversions
後來安裝了Qmmp軟體,在其設定中找到Output聲訊可以選擇:Alsa, Oss, PulseAudio等,我將其改為ALSA,如上圖。然後再將Pulseaudio暫時關掉,此時由Qmmp播放音樂,結果是可以聽到音樂的。這表示在關掉pulseaudio時,應該可以直接透過ALSA播放音樂。利用之前ALSA PCM的http://www.alsa-project.org/alsa-doc/alsa-lib/examples.html示範程式, 將device由原本的default之類,改成sysdefault:CARD=PCH,結果是可以聽到聲音的(在pulseaudio暫時關掉的情況下)。
但因為我在用ALSA PCM寫的程式播音樂時,把Qmmp關掉,此時自己寫的程式跳了一下,之後就無法再由自己寫的程式在pulseaudio關掉時播出聲音了!而且另一套軟體VLC,也有同様的問題,原本也是可以在設定的地方改成使用ALSA播出聲音,運作也沒問題;但是之後也無法正常運作了。可是有趣的是,Qmmp卻還能在關閉pulseaudio時運作正常。
後記:後來重新裝了一台ubuntu 12.10的機器並且做了更新,再測試暫時關閉pulseaudio,結果可以使用aplay -L指令,也可以用aplay播音樂,而且不用特別使用-D參數來使用特定的裝置。那是我原來那台機器壞了!那為什麼網路上也有人有相同的問題呢?
狀況三:
實體機器裝ubuntu 13.04,行為和ubuntu 10.04很像,暫時關掉pulseaudio,發現aplay還可以正常運作。
留言