简体   繁体   English

没有脉冲音频的A2DP接收器

[英]A2DP sink without pulseaudio

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). 因此,我试图使我的linux服务器使用蓝牙播放从我的Android手机发送的音乐(Linux机器是A2DP接收器,而手机是源)。 What I have done so far is to: 到目前为止,我所做的是:

  • install bluez and enable audiosource/audiosink 安装bluez并启用audiosource / audiosink
  • pair phone and server 配对电话和服务器
  • connect to server from phone (phone says it's streaming audio over bluetooth) 通过电话连接到服务器(电话说它正在通过蓝牙传输音频)

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. 我正在运行Bluez v4.99和Alsa v1.0.25。 Any ideas? 有任何想法吗?

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. 您可以使用/etc/bluetooth/audio.conf(这是系统范围的文件)或〜/ .asoundrc(这是您的本地文件)。 Both are read by BlueZ/ALSA. 两者均由BlueZ / ALSA读取。 However, I think you need to include the MAC address in your config file, zB: 但是,我认为您需要在配置文件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 1)James B的博客文章: Bluez必须是Linux中最保密的秘密之一
He explains the structure and interface between BlueZ and ALSA, which I found nowhere else on the internet. 他解释了BlueZ和ALSA之间的结构和接口,我在互联网上找不到其他地方。

2) His second post with code: Bluez A2DP AudioSink for ALSA 2)他的第二篇代码为: ALSA的Bluez A2DP AudioSink

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文件后,请运行它们。

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 删除/home/USERNAME/.config/pulse中的脉冲音频cookie和文件

    1. Modify your bluetooth-audio.conf : type: 修改您的bluetooth-audio.conf :输入:

    gksudo pluma /etc/bluetooth/audio.conf gksudo pluma /etc/bluetooth/audio.conf

    Set

     # This section contains options which are not specific to any # particular interface 

    [General] Enable=Socket [常规]启用=套接字

Save the file. 保存文件。

  1. setup ~/.asoundrc file type: 设置〜/ .asoundrc文件类型:

sudo hcitool scan sudo hcitool扫描

Scanning ... XX:XX:XX:XX:XX:XX Stereo Headset 扫描中... XX: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-applet at your taskbar, search & setup your new device! 转到任务栏上的blueman-applet ,搜索并设置新设备! Note: Some bluetooth-devices need a passphrase (eg. 0000) by default 注意:默认情况下,某些蓝牙设备需要密码(例如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 + terminal),mplayer(终端),qmmp(gui),女妖和浏览器播放声音,同时将播放器中的输出设置为“默认” !

—————————————————————————————————–——— ————————————————————————————————————————

RENAME THE .ASOUNDRC IN HOME-FOLDER TO “.ASOUNDRC_OFF” TO GET YOUR OLD SYSTEM-SETTINGS WITHOUT BLUETOOTH BACK! 将家用文件夹中的.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! 建议使用图腾,Qmmp或Banshee播放器-因为除了玩和听,别无其他! Also totem-player shows videos too. 图腾播放器也显示视频。

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

———–– --——––

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 mplayer with graphical-interface you have to install the gui-package: type: 要将mplayer与图形界面一起使用,必须安装gui软件包:输入:

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 带有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
  1. Run the following command to install latest packages for blueman and related modules: 运行以下命令为blueman和相关模块安装最新软件包:

    sudo add-apt-repository ppa:blueman/ppa sudo add-apt-repository ppa:blueman / ppa

    sudo apt-get update sudo apt-get更新

    sudo apt-get upgrade blueman enter code here 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! 重启!

  1. 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. 右键单击blueman-panel小程序,然后选择“设置新设备”。 Complete the wizard for your device.(If you have problems with “pairing” restart your system and skip this step!) 完成设备的向导。(如果“配对”有问题,请重新启动系统并跳过此步骤!)

Now you get a connected bluetooth device! 现在您将获得一个已连接的蓝牙设备!

To send/hear audio over it just follow these 2 steps: 要发送/收听音频,请按照以下两个步骤操作:

  • 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” 在任务栏中单击鼠标右键以打开Mate-volume控制设置(或pavucontrol) ,浏览到“硬件”-并使用下拉菜单将所有其他声卡的内置音频配置文件“关闭”

  • so that the bluetooth-device gets active! 这样蓝牙设备才能启动!

  • use the other dropdown to set the bluetooth device to use A2DP 使用另一个下拉菜单将蓝牙设备设置为使用A2DP

Now start the totem-player or vlc (with pulseaudio-output) to send audio to bluetooth! 现在启动图腾播放器或vlc(带有pulseaudio输出),将音频发送到蓝牙!

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在LM 17.3(Rosa)MATE和Ubuntu 14.04上测试了2017:

http://mayastudio.tumblr.com/bluetooth http://mayastudio.tumblr.com/bluetooth

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流/

I just tried to do the same thing, I'm using Fedora 19, so your mileage my vary. 我只是尝试做同样的事情,因为我使用的是Fedora 19,所以您的行驶里程会有所不同。 These are the steps I took. 这些是我采取的步骤。

  1. Made computer discoverable 使计算机可发现
  2. Pair phone to computer (it had a headphone logo next to it) 将手机与计算机配对(旁边带有耳机徽标)
  3. On my HTC phone I clicked "connect" on the pairing 在HTC手机上,我点击了配对上的“连接”
  4. Go into gnome3's sound settings 进入gnome3的声音设置
  5. Go to the input tab 转到输入标签
  6. Select the bluetooth item for your phone 选择手机的蓝牙项目
  7. Maybe adjust volume... 也许调整音量...

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM