Linux 没有pulseaudio的A2DP接收器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12338621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
A2DP sink without pulseaudio
提问by lode
So I'm trying to make my linux server play music sent from my Android phone using bluetooth (the linux machine is the A2DP sink and the phone is the source). What I have done so far is to:
所以我试图让我的 linux 服务器使用蓝牙播放从我的 Android 手机发送的音乐(linux 机器是 A2DP 接收器,手机是源)。到目前为止,我所做的是:
- install bluez and enable audiosource/audiosink
- pair phone and server
- connect to server from phone (phone says it's streaming audio over bluetooth)
- 安装 bluez 并启用 audiosource/audiosink
- 配对电话和服务器
- 从手机连接到服务器(手机说它正在通过蓝牙流式传输音频)
But I can't hear anything. Also, most guides on the internet assumes Pulseaudio and I would prefer to use ALSA.
但我什么也听不见。此外,互联网上的大多数指南都假设 Pulseaudio,我更愿意使用 ALSA。
I currently have the following in /etc/asound.conf:
我目前在 /etc/asound.conf 中有以下内容:
pcm.!default{
type bluetooth
profile "auto"
}
I'm running Bluez v4.99 and Alsa v1.0.25. Any ideas?
我正在运行 Bluez v4.99 和 Alsa v1.0.25。有任何想法吗?
回答by TJD
My guess is that your audio path isn't routing the bluetooth to your speakers. I have seen similar issue, which was fixed by manually doing step 5 "Connect PulseAudio bluetooth source to PulseAudio ALSA sink" from this link: http://jprvita.wordpress.com/2009/12/15/1-2-3-4-a2dp-stream/
我的猜测是您的音频路径没有将蓝牙路由到您的扬声器。我已经看到了类似的问题,这是通过从以下链接手动执行第 5 步“将 PulseAudio 蓝牙源连接到 PulseAudio ALSA 接收器”来解决的:http: //jprvita.wordpress.com/2009/12/15/1-2-3- 4-a2dp-流/
回答by Eugene Marcotte
I just tried to do the same thing, I'm using Fedora 19, so your mileage my vary. These are the steps I took.
我只是尝试做同样的事情,我使用的是 Fedora 19,所以你的里程数会有所不同。这些是我采取的步骤。
- Made computer discoverable
- Pair phone to computer (it had a headphone logo next to it)
- On my HTC phone I clicked "connect" on the pairing
- Go into gnome3's sound settings
- Go to the input tab
- Select the bluetooth item for your phone
- Maybe adjust volume...
- 使计算机可发现
- 将手机与电脑配对(旁边有耳机标志)
- 在我的 HTC 手机上,我点击了配对上的“连接”
- 进入 gnome3 的声音设置
- 转到输入选项卡
- 为您的手机选择蓝牙项目
- 可能要调音量...
回答by MrUser
I know this is an old post, but hopefully the answer is useful to people currently working on this.
我知道这是一篇旧帖子,但希望答案对目前从事此工作的人有用。
You can use /etc/bluetooth/audio.conf, which is the system-wide file, or ~/.asoundrc, which is your local file. Both are read by BlueZ/ALSA. However, I think you need to include the MAC address in your config file, z.B.:
您可以使用 /etc/bluetooth/audio.conf,它是系统范围的文件,或 ~/.asoundrc,它是您的本地文件。两者都由 BlueZ/ALSA 读取。但是,我认为您需要在配置文件 zB 中包含 MAC 地址:
pcm.btheadset {
type bluetooth
device "XX:XX:XX:XX:XX:XX" #MAC address
profile "auto"
}
The best resources I've found for this are:
我为此找到的最佳资源是:
1) James B's blog post: Bluez must be one of the best kept secrets in Linux
He explains the structure and interface between BlueZ and ALSA, which I found nowhere else on the internet.
1) James B 的博文:Bluez 一定是 Linux 中保存得最好的秘密之一
他解释了 BlueZ 和 ALSA 之间的结构和接口,我在互联网上找不到其他地方。
2) His second post with code: Bluez A2DP AudioSink for ALSA
2)他的第二篇带有代码的帖子:Bluez A2DP AudioSink for ALSA
3) The ALSA site, which introduces the structure of pcm plugins, but doesn't really explain them very well.
3) ALSA 站点,它介绍了 pcm 插件的结构,但并没有很好地解释它们。
4) Some ALSA plugin tutorials: The ALSA wiki
4) 一些 ALSA 插件教程:ALSA wiki
Some useful commands:
一些有用的命令:
$sudo service bluetooth restart
$sudo alsa force-reload
Run these after you change the asoundrc or audio.conf files.
在更改 asoundrc 或 audio.conf 文件后运行这些文件。
回答by chalee
Here you find a manual to configure bluetooth with ALSA or Pulseaudio:
在这里您可以找到使用 ALSA 或 Pulseaudio 配置蓝牙的手册:
-tested on Linux Mint 17.3 Mate, 64bit / Ubuntu 14.04 Mate, 64bit-
-在 Linux Mint 17.3 Mate,64 位/Ubuntu 14.04 Mate,64 位上测试-
HOW TO MAKE ALSA AND BLUETOOTH WORK TOGETHER WITHOUT PA
如何在没有 PA 的情况下使 ALSA 和蓝牙协同工作
This part is for pure ALSA-based systems without Pulseaudio like KXStudio, QStudio64,Tango studio..!
这部分适用于没有 Pulseaudio 的纯基于 ALSA 的系统,如 KXStudio、QStudio64、Tango studio..!
Be sure that Pulseaudio is deinstalled and your soundcards configured right in ALSA!
确保 Pulseaudio 已卸载,并且您的声卡已在 ALSA 中正确配置!
delete pulse-audio cookies and files in /home/USERNAME/.config/pulse
- Modify your bluetooth-audio.conf: type:
gksudo pluma /etc/bluetooth/audio.conf
Set
# This section contains options which are not specific to any # particular interface
[General] Enable=Socket
删除 /home/USERNAME/.config/pulse 中的脉冲音频 cookie 和文件
- 修改您的bluetooth-audio.conf:输入:
gksudo puma /etc/bluetooth/audio.conf
放
# This section contains options which are not specific to any # particular interface
[通用] Enable=Socket
Save the file.
保存文件。
- setup ~/.asoundrcfile type:
- 设置~/.asoundrc文件类型:
sudo hcitool scan
须藤 hcitool 扫描
Scanning ... XX:XX:XX:XX:XX:XX Stereo Headset
正在扫描 ... XX:XX:XX:XX:XX:XX 立体声耳机
Create a hidden-file named .asoundrc in your home-folder!and write:
在您的主文件夹中创建一个名为 .asoundrc 的隐藏文件!并写入:
pcm.!default {
type plug
slave.pcm {
type bluetooth
device "XX:XX:XX:XX:XX:XX"
profile "auto"
}
}
Replace “XX:XX..” with the adress of your device.
将“XX:XX..”替换为您设备的地址。
Save the file!
保存文件!
Run these after you change the asoundrc or audio.conf files:
在更改 asoundrc 或 audio.conf 文件后运行这些:
sudo service bluetooth restart
sudo alsa force-reload
or reboot your computer! ———————————————————————————————————–—-
或者重启你的电脑!————————————————————————————————————————————
Go to your blueman-appletat your taskbar, search & setup your new device! Note: Some bluetooth-devices need a passphrase (eg. 0000) by default
转到任务栏上的blueman-applet,搜索并设置您的新设备!注意:某些蓝牙设备默认需要密码(例如 0000)
- while some others takes shuffle-pairing. Keep your found and paired device to “trust”!
- 而其他一些则需要随机配对。让您找到并配对的设备“信任”!
Connect your device as AUDIO via A2DP!
通过A2DP将您的设备作为 AUDIO 连接!
————————————————————————————————————
———————————————————————————————————————
If your device is connected with your system you can play sound with totem (gui), vlc (gui+terminal), mplayer (terminal), qmmp (gui), banshee and browsers over bluetooth while setting the output in players to “default”!
如果您的设备与您的系统连接,您可以通过蓝牙使用图腾 (gui)、vlc (gui+终端)、mplayer (终端)、qmmp (gui)、banshee 和浏览器播放声音,同时将播放器中的输出设置为“默认” !
—————————————————————————————————–———
——————————————————————————————————————————
RENAME THE .ASOUNDRC IN HOME-FOLDER TO “.ASOUNDRC_OFF” TO GET YOUR OLD SYSTEM-SETTINGS WITHOUT BLUETOOTH BACK!
将 HOME-FOLDER 中的 .ASOUNDRC 重命名为“.ASOUNDRC_OFF”,以在不恢复蓝牙的情况下获取旧系统设置!
type: mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF
->to disable the bluetooth-specific asoundrc
键入:mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF
-> 禁用特定于蓝牙的 asoundrc
type: mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc
-> to enable it!
输入:mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc
-> 启用它!
Alternative:
替代方案:
Make two “scripts” to activate/deactivate bluetooth with .asoundrc in your home-folder:
在您的主文件夹中使用 .asoundrc 制作两个“脚本”来激活/停用蓝牙:
Create one empty file and write/paste:
创建一个空文件并写入/粘贴:
#!/bin/bash
mv /home/USERNAME/.asoundrc /home/USERNAME/.asoundrcOFF
or:
#!/bin/bash
cd /home/USERNAME/
mv .asoundrc .asoundrcOFF
To activate your .asoundrc for bluetooth again, create another file with following entry:
要再次为蓝牙激活 .asoundrc,请使用以下条目创建另一个文件:
#!/bin/bash
mv /home/USERNAME/.asoundrcOFF /home/USERNAME/.asoundrc
or:
或者:
#!/bin/bash
cd /home/USERNAME/
mv .asoundrcOFF .asoundrc
Make the files executable and run them with “open with terminal”! Now you have two “buttons” to switch bluetooth-sound On or Off.
使文件可执行并使用“用终端打开”运行它们!现在您有两个“按钮”可以打开或关闭蓝牙声音。
Give them individual-icons: ;-)
给他们单独的图标:;-)
————————————————————————————————————-
——————————————————————————————————————————
PLAYERS
球员
————–
——————
It's recommend to use totem, Qmmp or Banshee-player - because there is nothing more to do than play and listen! Also totem-player shows videos too.
建议使用图腾、Qmmp 或 Banshee-player - 因为除了玩和听之外别无他法!图腾播放器也显示视频。
VLC-player needs the “default” sounddriver for bluetooth to working right!
VLC 播放器需要蓝牙的“默认”声音驱动程序才能正常工作!
Check in: /home/USERNAME/.config/vlc/vlcrc
签入:/home/USERNAME/.config/vlc/vlcrc
that alsa-audio-device in >>line1666<< is:
>>line1666<< 中的 alsa-audio-device 是:
# ALSA Device Name (string)
alsa-audio-device=default
Use this commands to use players with terminal: To play music, type:
使用此命令通过终端使用播放器:要播放音乐,请键入:
MPlayer
播放器
———––
——————
mplayer /home/USERNAME/Musik/1.mp3
If you hear no sound or get errors try:
如果您听不到声音或出现错误,请尝试:
mplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3
VLC-Player
VLC播放器
—————-
——————
cvlc /home/USERNAME/Musik/1.mp3
vlc /home/USERNAME/Musik/1.mp3
rvlc /home/USERNAME/Musik/1.mp3
To add whole directories type:
rvlc add /home/USERNAME/Musik/
type: start/stop/next... to navigate!
类型:开始/停止/下一步...导航!
or use the vlc-gui.
或使用 vlc-gui。
—————————————————————————————————–——-
—————————————————————————————————————————————
To use mplayerwith graphical-interface you have to install the gui-package: type:
要使用带有图形界面的mplayer,您必须安装 gui-package:键入:
sudo apt-get install mplayer-gui
Open a terminal via Ctrl-Alt-T and use the commands below.Use the lines and type/copy one by one to avoid confusion(!):
通过 Ctrl-Alt-T 打开终端并使用下面的命令。使用这些行并一一键入/复制以避免混淆(!):
cd /usr/share/mplayer/skins/default
for FILE in *.png; do sudo convert “$FILE” -define png:format=png24 “$FILE”; done
cd /usr/share/mplayer/skins; sudo rm default; sudo ln -s Blue default
———————————————————————————————————–
—————————————————————————————————————————
Now you can start the mplayer-gui without errors!
现在您可以毫无错误地启动 mplayer-gui!
If you prefer the terminal type:
如果您更喜欢终端类型:
gmplayer /home/USERNAME/Musik/1.mp3
or
或者
gmplayer -ao alsa:device=default /home/USERNAME/Musik/1.mp3
if you have problems!
terminal command without gui:
没有gui的终端命令:
mplayer /DIRECTION/TO/FILE
Available Output-Modules and Drivers:
可用的输出模块和驱动器:
mplayer -vo help
———————————————————————-
——————————————————————————
BLUETOOTH WITH PULSEAUDIO
带脉冲音频的蓝牙
————————————————–--------
——————————————————————————
For Linux systems that comes with pulseaudio:
对于带有pulseaudio的Linux系统:
(1.) Edit /etc/bluetooth/audio.conf and uncomment the following line:
(1.) 编辑 /etc/bluetooth/audio.conf 并取消注释以下行:
AutoConnect=true
Run the following command to install latest packages for blueman and related modules:
sudo add-apt-repository ppa:blueman/ppa
sudo apt-get update
sudo apt-get upgrade blueman enter code here
运行以下命令为 blueman 和相关模块安装最新的软件包:
须藤添加-apt-repository ppa:blueman/ppa
sudo apt-get 更新
sudo apt-get upgrade blueman 在此处输入代码
(3.) Check if the following lines are added in /etc/pulse/default.pa:
(3.) 检查是否在 /etc/pulse/default.pa 中添加了以下几行:
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif
If not, add the lines.
如果没有,请添加行。
REBOOT!
重启!
- Run the new blueman-applet.
- 运行新的blueman-applet。
Right click on the panel applet and turn bluetooth on. The old profie of you bluetooth device would still be there, remove it. Right click on the blueman-panel applet and select Setup New Device. Complete the wizard for your device.(If you have problems with “pairing” restart your system and skip this step!)
右键单击面板小程序并打开蓝牙。您的蓝牙设备的旧配置仍然存在,请将其删除。右键单击 blueman-panel 小程序并选择设置新设备。为您的设备完成向导。(如果“配对”有问题,请重新启动系统并跳过此步骤!)
Now you get a connected bluetooth device!
现在你得到了一个连接的蓝牙设备!
To send/hear audio over it just follow these 2 steps:
要通过它发送/收听音频,只需按照以下 2 个步骤操作:
Open Mate-volume control-settings (or pavucontrol)with rightclick in taskbar, browse to “HARDWARE” - and use the dropdown to turn the Built-in audio profiles of all other soundcards “off”
so that the bluetooth-device gets active!
- use the other dropdown to set the bluetooth device to use A2DP
在任务栏中右键单击打开Mate-volume control-settings(或 pavucontrol),浏览到“HARDWARE” - 并使用下拉菜单将所有其他声卡的内置音频配置文件“关闭”
以便蓝牙设备激活!
- 使用其他下拉菜单将蓝牙设备设置为使用A2DP
Now start the totem-player or vlc (with pulseaudio-output) to send audio to bluetooth!
现在启动totem-player或vlc(带有pulseaudio-output)将音频发送到蓝牙!
Enjoy your sound! ;-)
享受你的声音!;-)
WLAN-ISSUES:
WLAN-问题:
——————–— In case you see a WiFi connection drop after connecting to the bluetooth device run the following command:
————————— 如果您在连接到蓝牙设备后看到 WiFi 连接断开,请运行以下命令:
$ echo “options iwlwifi 11n_disable=1 bt_coex_active=0 power_save=0 auto_agg=0 swcrypto=1” |
sudo tee -a /etc/modprobe.d/iwlwifi.conf > /dev/null
tested 2017 for LM 17.3 (Rosa) MATE and Ubuntu 14.04 by chalee:
chalee 在 2017 年针对 LM 17.3 (Rosa) MATE 和 Ubuntu 14.04 进行了测试: