pulseaudio基于a2dp音频架构,其使用流程如下:
首先需要一直bluez5及pulseaudio,此处关于一直pulseaudio详见其他博客。
配置使用流程:
1.开启蓝牙设备
//此处与后续的bluetoothctl命令中的power on相对应,没有开启的话,bluetoothctl会报错.
root@imx6qsabresd:~#rfkill unblock bluetooth
2.启动蓝牙
root@imx6qsabresd:~#hciconfig hci0 up
3.通过bluetoothctl连接蓝牙耳机
//必须先启动bluetoothd,否则bluetoothctl无法工作
root@imx6qsabresd:~#bluetoothd&
root@imx6qsabresd:~#bluetoothctl
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Controller A4:17:31:C7:9B:B6 Discovering: yes
[NEW] Device 74:7D:04:2F:F1:BA 74-7D-04-2F-F1-BA
[NEW] Device 88:0F:10:87:22:CE 88-0F-10-87-22-CE
[CHG] Device 88:0F:10:87:22:CE Name: MI_SCALE
[CHG] Device 88:0F:10:87:22:CE Alias: MI_SCALE
[NEW] Device 35:BD:7B:5D:CC:AE 35-BD-7B-5D-CC-AE
[NEW] Device 38:BC:1A:B2:9B:5D 38-BC-1A-B2-9B-5D
[CHG] Device 35:BD:7B:5D:CC:AE LegacyPairing: no
[CHG] Device 35:BD:7B:5D:CC:AE Name: J2-USB Bluetooth
[CHG] Device 35:BD:7B:5D:CC:AE Alias: J2-USB Bluetooth
[CHG] Device 38:BC:1A:B2:9B:5D Name: MEIZU MX4
[CHG] Device 38:BC:1A:B2:9B:5D Alias: MEIZU MX4
[NEW] Device 00:1A:7D:DA:71:13 00-1A-7D-DA-71-13
[CHG] Device 00:1A:7D:DA:71:13 RSSI: -76
[CHG] Device 00:1A:7D:DA:71:13 Name: JavieWong-PC
[CHG] Device 00:1A:7D:DA:71:13 Alias: JavieWong-PC
[CHG] Device 35:BD:7B:5D:CC:AE LegacyPairing: yes
[CHG] Device 35:BD:7B:5D:CC:AE RSSI: -48
[CHG] Device 38:BC:1A:B2:9B:5D UUIDs:
00001112-0000-1000-8000-00805f9b34fb
00001203-0000-1000-8000-00805f9b34fb
0000111f-0000-1000-8000-00805f9b34fb
00001116-0000-1000-8000-00805f9b34fb
00001115-0000-1000-8000-00805f9b34fb
0000110c-0000-1000-8000-00805f9b34fb
0000110f-0000-1000-8000-00805f9b34fb
0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device 88:0F:10:87:22:CE RSSI: -92
[bluetooth]# pair 35:BD:7B:5D:CC:AE
Attempting to pair with 35:BD:7B:5D:CC:AE
[CHG] Device 35:BD:7B:5D:CC:AE Connected: yes
[CHG] Device 35:BD:7B:5D:CC:AE UUIDs:
0000110b-0000-1000-8000-00805f9b34fb
0000110e-0000-1000-8000-00805f9b34fb
0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device 35:BD:7B:5D:CC:AE Paired: yes
Pairing successful
[bluetooth]# connect 35:BD:7B:5D:CC:AE
Attempting to connect to 35:BD:7B:5D:CC:AE
[CHG] Device 35:BD:7B:5D:CC:AE Connected: yes
[bluetooth]# info 35:BD:7B:5D:CC:AE
Device 35:BD:7B:5D:CC:AE
Name: J2-USB Bluetooth
Alias: J2-USB Bluetooth
Class: 0x240404
Icon: audio-card
Paired: yes
Trusted: no
Blocked: no
Connected: yes
LegacyPairing: yes
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Handsfree (0000111e-0000-1000-8000-00805f9b34fb)
[bluetooth]#
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
4.在另外一个控制终端中启动pulseaudio
//
root@imx6qsabresd:~# pulseaudio --system
W: [pulseaudio] main.c: Running in system mode, but --disallow-exit not set!
W: [pulseaudio] main.c: Running in system mode, but --disallow-module-loading not set!
N: [pulseaudio] main.c: Running in system mode, forcibly disabling SHM mode!
W: [pulseaudio] main.c: OK, so you are running PA in system mode. Please note that you most likely shouldn't be doing that.
W: [pulseaudio] main.c: If you do it nonetheless then it's your own fault if things don't work as expected.
W: [pulseaudio] main.c: Please read http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/WhatIsWrongWithSystemWide/ for an explanation why system mode is usually a bad idea.
E: [pulseaudio] module-alsa-card.c: Failed to find a working profile.
E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="0" name="platform-sound-hdmi.21" card_name="alsa_card.platform-sound-hdmi.21" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes card_properties="module-udev-detect.discovered=1""): initialization failed.
W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.config/pulse/cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.config/pulse/cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to open cookie file '/var/run/pulse/.pulse-cookie': No such file or directory
W: [pulseaudio] authkey.c: Failed to load authentication key '/var/run/pulse/.pulse-cookie': No such file or directory
5、配置默认音频输出设备
root@imx6qsabresd:~#pacmd help
Available commands:
help Show this help
list-modules List loaded modules
list-cards List cards
list-sinks List loaded sinks
list-sources List loaded sources
list-clients List loaded clients
list-sink-inputs List sink inputs
list-source-outputs List source outputs
stat Show memory block statistics
info Show comprehensive status
load-module Load a module (args: name, arguments)
unload-module Unload a module (args: index|name)
describe-module Describe a module (arg: name)
set-sink-volume Set the volume of a sink (args: index|name, volume)
set-source-volume Set the volume of a source (args: index|name, volume)
set-sink-mute Set the mute switch of a sink (args: index|name, bool)
set-source-mute Set the mute switch of a source (args: index|name, bool)
set-sink-input-volume Set the volume of a sink input (args: index, volume)
set-source-output-volume Set the volume of a source output (args: index, volume)
set-sink-input-mute Set the mute switch of a sink input (args: index, bool)
set-source-output-mute Set the mute switch of a source output (args: index, bool)
set-default-sink Set the default sink (args: index|name)
set-default-source Set the default source (args: index|name)
set-card-profile Change the profile of a card (args: index|name, profile-name)
set-sink-port Change the port of a sink (args: index|name, port-name)
set-source-port Change the port of a source (args: index|name, port-name)
set-port-latency-offset Change the latency of a port (args: card-index|card-name, port-name, latency-offset)
suspend-sink Suspend sink (args: index|name, bool)
suspend-source Suspend source (args: index|name, bool)
suspend Suspend all sinks and all sources (args: bool)
move-sink-input Move sink input to another sink (args: index, sink)
move-source-output Move source output to another source (args: index, source)
update-sink-proplist Update the properties of a sink (args: index|name, properties)
update-source-proplist Update the properties of a source (args: index|name, properties)
update-sink-input-proplist Update the properties of a sink input (args: index, properties)
update-source-output-proplist Update the properties of a source output (args: index, properties)
list-samples List all entries in the sample cache
play-sample Play a sample from the sample cache (args: name, sink|index)
remove-sample Remove a sample from the sample cache (args: name)
load-sample Load a sound file into the sample cache (args: name, filename)
load-sample-lazy Lazily load a sound file into the sample cache (args: name, filename)
load-sample-dir-lazy Lazily load all files in a directory into the sample cache (args: pathname)
kill-client Kill a client (args: index)
kill-sink-input Kill a sink input (args: index)
kill-source-output Kill a source output (args: index)
set-log-target Change the log target (args: null|auto|syslog|stderr|file:PATH|newfile:PATH)
set-log-level Change the log level (args: numeric level)
set-log-meta Show source code location in log messages (args: bool)
set-log-time Show timestamps in log messages (args: bool)
set-log-backtrace Show backtrace in log messages (args: frames)
play-file Play a sound file (args: filename, sink|index)
dump Dump daemon configuration
dump-volumes Debug: Show the state of all volumes
shared Debug: Show shared properties
exit Terminate the daemon
root@imx6qsabresd:~#pactl list cards
Card #0
Name: alsa_card.platform-sound.20
Driver: module-alsa-card.c
Owner Module: 7
Properties:
alsa.card = "0"
alsa.card_name = "wm8962-audio"
alsa.long_card_name = "wm8962-audio"
device.bus_path = "platform-sound.20"
sysfs.path = "/devices/soc0/sound.20/sound/card0"
device.string = "0"
device.description = "wm8962-audio"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
Profiles:
input:analog-mono: Analog Mono Input (sinks: 0, sources: 1, priority: 2, available: yes)
input:analog-stereo: Analog Stereo Input (sinks: 0, sources: 1, priority: 60, available: yes)
output:analog-mono: Analog Mono Output (sinks: 1, sources: 0, priority: 200, available: yes)
output:analog-mono+input:analog-mono: Analog Mono Duplex (sinks: 1, sources: 1, priority: 202, available: yes)
output:analog-stereo: Analog Stereo Output (sinks: 1, sources: 0, priority: 6000, available: yes)
output:analog-stereo+input:analog-stereo: Analog Stereo Duplex (sinks: 1, sources: 1, priority: 6060, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: output:analog-stereo+input:analog-stereo
Ports:
analog-input: Analog Input (priority: 10000, latency offset: 0 usec)
Part of profile(s): input:analog-mono, input:analog-stereo, output:analog-mono+input:analog-mono, output:analog-stereo+input:analog-stereo
analog-output-speaker: Speakers (priority: 10000, latency offset: 0 usec, not available)
Properties:
device.icon_name = "audio-speakers"
Part of profile(s): output:analog-mono, output:analog-mono+input:analog-mono, output:analog-stereo, output:analog-stereo+input:analog-stereo
analog-output-headphones: Headphones (priority: 9000, latency offset: 0 usec, available)
Properties:
device.icon_name = "audio-headphones"
Part of profile(s): output:analog-mono, output:analog-mono+input:analog-mono, output:analog-stereo, output:analog-stereo+input:analog-stereo
如果发现板子上有单个声卡设备,则按照步骤5.1配置既可以,如果有多个声卡设备按照5.2步骤配置
5.1 单声音配置
Card #1
Name: bluez_card.35_BD_7B_5D_CC_AE
Driver: module-bluez5-device.c
Owner Module: 24
Properties:
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: no)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
headset-output: Headset (priority: 0, latency offset: 0 usec)
Part of profile(s): a2dp_sink, headset_head_unit
headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
Part of profile(s): headset_head_unit
root@imx6qsabresd:~#pacmd list-sinks
1 sink(s) available.
* index: 1
name:
driver:
flags: HARDWARE DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9030
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max request: 2 KiB
max rewind: 0 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
fixed latency: 39.51 ms
card: 0
module: 24
properties:
bluetooth.protocol = "a2dp_sink"
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
active port:
root@imx6qsabresd:~#pacmd list-cards
1 card(s) available.
index: 0
name:
driver:
owner module: 24
properties:
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: no)
off: Off (priority 0, available: yes)
active profile:
sinks:
bluez_sink.35_BD_7B_5D_CC_AE/#1: J2-USB Bluetooth
sources:
bluez_sink.35_BD_7B_5D_CC_AE.monitor/#1: Monitor of J2-USB Bluetooth
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
headset-input: Headset (priority 0, latency offset 0 usec, available: no)
properties:
root@imx6qsabresd:~#pacmd set-default-sink 1
root@imx6qsabresd:~#pacmd set-card-profile 0 a2dp_sink
root@imx6qsabresd:~#pacmd info
Memory blocks currently allocated: 1, size: 64.0 KiB.
Memory blocks allocated during the whole lifetime: 53616, size: 67.8 MiB.
Memory blocks imported from other processes: 0, size: 0 B.
Memory blocks exported to other processes: 0, size: 0 B.
Total sample cache size: 0 B.
Default sample spec: s16le 2ch 44100Hz
Default channel map: front-left,front-right
Default sink name: bluez_sink.35_BD_7B_5D_CC_AE
Default source name: bluez_sink.35_BD_7B_5D_CC_AE.monitor
Memory blocks of type POOL: 1 allocated/39706 accumulated.
Memory blocks of type POOL_EXTERNAL: 0 allocated/0 accumulated.
Memory blocks of type APPENDED: 0 allocated/0 accumulated.
Memory blocks of type USER: 0 allocated/0 accumulated.
Memory blocks of type FIXED: 0 allocated/0 accumulated.
Memory blocks of type IMPORTED: 0 allocated/13910 accumulated.
24 module(s) loaded.
index: 0
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the volume/mute state of devices"
module.version = "6.0"
index: 1
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the volume/mute/device state of streams"
module.version = "6.0"
index: 2
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore profile of cards"
module.version = "6.0"
index: 3
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Augment the property sets of streams with additional static information"
module.version = "6.0"
index: 4
name:
argument: <>
used: -1
load once: no
properties:
index: 5
name:
argument:
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Detect available audio hardware and load matching drivers"
module.version = "6.0"
index: 7
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Fr茅d茅ric Dalleau"
module.description = "When a bluetooth sink or source is added, load module-loopback"
module.version = "6.0"
index: 8
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Jo茫o Paulo Rechi Vita"
module.description = "Detect available Bluetooth daemon and load the corresponding discovery module"
module.version = "6.0"
index: 9
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Jo茫o Paulo Rechi Vita"
module.description = "Detect available BlueZ 5 Bluetooth audio devices and load BlueZ 5 Bluetooth audio drivers"
module.version = "6.0"
index: 10
name:
argument: <>
used: -1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "Native protocol (UNIX sockets)"
module.version = "6.0"
index: 11
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically restore the default sink and source"
module.version = "6.0"
index: 12
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "When a sink/source is removed, try to move its streams to the default sink/source"
module.version = "6.0"
index: 13
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Always keeps at least one sink loaded even if it's a null one"
module.version = "6.0"
index: 15
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Automatically set device of streams based on intended roles of devices"
module.version = "6.0"
index: 16
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "When a sink/source is idle for too long, suspend it"
module.version = "6.0"
index: 17
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Create a client for each ConsoleKit session of this user"
module.version = "6.0"
index: 18
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Position event sounds between L and R depending on the position on screen of the widget triggering them."
module.version = "6.0"
index: 19
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Lennart Poettering"
module.description = "Mute & cork streams with certain roles while others exist"
module.version = "6.0"
index: 20
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Detect when various filters are desirable"
module.version = "6.0"
index: 21
name:
argument: <>
used: -1
load once: yes
properties:
module.author = "Colin Guthrie"
module.description = "Load filter sinks automatically when needed"
module.version = "6.0"
index: 22
name:
argument:
used: -1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "X11 credential publisher"
module.version = "6.0"
index: 23
name:
argument:
used: -1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "Synthesize X11 media key events when cork/uncork is requested"
module.version = "6.0"
index: 24
name:
argument:
used: 0
load once: no
properties:
module.author = "Jo茫o Paulo Rechi Vita"
module.description = "BlueZ 5 Bluetooth audio sink and source"
module.version = "6.0"
index: 25
name:
argument: <>
used: -1
load once: no
properties:
module.author = "Lennart Poettering"
module.description = "Command line interface protocol (UNIX sockets)"
module.version = "6.0"
1 sink(s) available.
* index: 1
name:
driver:
flags: HARDWARE DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 9030
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max request: 2 KiB
max rewind: 0 KiB
monitor source: 1
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
fixed latency: 39.51 ms
card: 0
module: 24
properties:
bluetooth.protocol = "a2dp_sink"
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
active port:
1 source(s) available.
* index: 1
name:
driver:
flags: DECIBEL_VOLUME LATENCY
state: SUSPENDED
suspend cause: IDLE
priority: 1030
volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
base volume: 65536 / 100% / 0.00 dB
volume steps: 65537
muted: no
current latency: 0.00 ms
max rewind: 0 KiB
sample spec: s16le 2ch 44100Hz
channel map: front-left,front-right
Stereo
used by: 0
linked by: 0
fixed latency: 39.51 ms
monitor_of: 1
card: 0
module: 24
properties:
device.description = "Monitor of J2-USB Bluetooth"
device.class = "monitor"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
1 client(s) logged in.
index: 26
driver:
owner module: 25
properties:
application.name = "UNIX socket client"
1 card(s) available.
index: 0
name:
driver:
owner module: 24
properties:
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: no)
off: Off (priority 0, available: yes)
active profile:
sinks:
bluez_sink.35_BD_7B_5D_CC_AE/#1: J2-USB Bluetooth
sources:
bluez_sink.35_BD_7B_5D_CC_AE.monitor/#1: Monitor of J2-USB Bluetooth
ports:
headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
properties:
headset-input: Headset (priority 0, latency offset 0 usec, available: no)
properties:
0 sink input(s) available.
0 source output(s) available.
0 cache entrie(s) available.
root@imx6qsabresd:~#pacmd stat
Memory blocks currently allocated: 1, size: 64.0 KiB.
Memory blocks allocated during the whole lifetime: 53616, size: 67.8 MiB.
Memory blocks imported from other processes: 0, size: 0 B.
Memory blocks exported to other processes: 0, size: 0 B.
Total sample cache size: 0 B.
Default sample spec: s16le 2ch 44100Hz
Default channel map: front-left,front-right
Default sink name: bluez_sink.35_BD_7B_5D_CC_AE
Default source name: bluez_sink.35_BD_7B_5D_CC_AE.monitor
Memory blocks of type POOL: 1 allocated/39706 accumulated.
Memory blocks of type POOL_EXTERNAL: 0 allocated/0 accumulated.
Memory blocks of type APPENDED: 0 allocated/0 accumulated.
Memory blocks of type USER: 0 allocated/0 accumulated.
Memory blocks of type FIXED: 0 allocated/0 accumulated.
Memory blocks of type IMPORTED: 0 allocated/13910 accumulated.
5.2 多声卡设备配置
root@imx6qsabresd:~# pacmd set-card-profile 1 a2dp_sink
root@imx6qsabresd:~# pactl list sinks
Sink #0
State: SUSPENDED
Name: alsa_output.platform-sound.20.analog-stereo
Description: wm8962-audio Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 7
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: alsa_output.platform-sound.20.analog-stereo.monitor
Latency: 0 usec, configured 0 usec
Flags: HARDWARE DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HiFi wm8962-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "wm8962-audio"
alsa.long_card_name = "wm8962-audio"
device.bus_path = "platform-sound.20"
sysfs.path = "/devices/soc0/sound.20/sound/card0"
device.string = "hw:0"
device.buffering.buffer_size = "17632"
device.buffering.fragment_size = "4408"
device.access_mode = "mmap"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "wm8962-audio Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
Ports:
analog-output-speaker: Speakers (priority: 10000, not available)
analog-output-headphones: Headphones (priority: 9000, available)
Active Port: analog-output-headphones
Formats:
pcm
Sink #1
State: SUSPENDED
Name: bluez_sink.35_BD_7B_5D_CC_AE
Description: J2-USB Bluetooth
Driver: module-bluez5-device.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 24
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: bluez_sink.35_BD_7B_5D_CC_AE.monitor
Latency: 0 usec, configured 0 usec
Flags: HARDWARE DECIBEL_VOLUME LATENCY
Properties:
bluetooth.protocol = "a2dp_sink"
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Ports:
headset-output: Headset (priority: 0)
Active Port: headset-output
Formats:
pcm
root@imx6qsabresd:~# pacmd set-default-sink 1
root@imx6qsabresd:~# pactl list sources
Source #0
State: SUSPENDED
Name: alsa_output.platform-sound.20.analog-stereo.monitor
Description: Monitor of wm8962-audio Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 7
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor of Sink: alsa_output.platform-sound.20.analog-stereo
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY
Properties:
device.description = "Monitor of wm8962-audio Analog Stereo"
device.class = "monitor"
alsa.card = "0"
alsa.card_name = "wm8962-audio"
alsa.long_card_name = "wm8962-audio"
device.bus_path = "platform-sound.20"
sysfs.path = "/devices/soc0/sound.20/sound/card0"
device.string = "0"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
Formats:
pcm
Source #1
State: SUSPENDED
Name: alsa_input.platform-sound.20.analog-stereo
Description: wm8962-audio Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 7
Mute: no
Volume: front-left: 33804 / 52% / -17.25 dB, front-right: 33804 / 52% / -17.25 dB
balance 0.00
Base Volume: 26090 / 40% / -24.00 dB
Monitor of Sink: n/a
Latency: 0 usec, configured 0 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = ""
alsa.id = "HiFi wm8962-0"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "wm8962-audio"
alsa.long_card_name = "wm8962-audio"
device.bus_path = "platform-sound.20"
sysfs.path = "/devices/soc0/sound.20/sound/card0"
device.string = "hw:0"
device.buffering.buffer_size = "17632"
device.buffering.fragment_size = "4408"
device.access_mode = "mmap"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "wm8962-audio Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card"
Ports:
analog-input: Analog Input (priority: 10000)
Active Port: analog-input
Formats:
pcm
Source #2
State: SUSPENDED
Name: bluez_sink.35_BD_7B_5D_CC_AE.monitor
Description: Monitor of J2-USB Bluetooth
Driver: module-bluez5-device.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 24
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor of Sink: bluez_sink.35_BD_7B_5D_CC_AE
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY
Properties:
device.description = "Monitor of J2-USB Bluetooth"
device.class = "monitor"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Formats:
pcm
root@imx6qsabresd:~# pacmd set-default-source 2
5.3 测试蓝牙耳机
//在终端中使用pactl list命令查看此时的配置已经OK
root@imx6qsabresd:~# pactl list sinks
Sink #1
State: SUSPENDED
Name: bluez_sink.35_BD_7B_5D_CC_AE
Description: J2-USB Bluetooth
Driver: module-bluez5-device.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 24
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: bluez_sink.35_BD_7B_5D_CC_AE.monitor
Latency: 0 usec, configured 0 usec
Flags: HARDWARE DECIBEL_VOLUME LATENCY
Properties:
bluetooth.protocol = "a2dp_sink"
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Ports:
headset-output: Headset (priority: 0)
Active Port: headset-output
Formats:
pcm
root@imx6qsabresd:~# pactl list cards
Card #0
Name: bluez_card.35_BD_7B_5D_CC_AE
Driver: module-bluez5-device.c
Owner Module: 24
Properties:
device.description = "J2-USB Bluetooth"
device.string = "35:BD:7B:5D:CC:AE"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "headset"
bluez.path = "/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE"
bluez.class = "0x240404"
bluez.alias = "J2-USB Bluetooth"
device.icon_name = "audio-headset-bluetooth"
device.intended_roles = "phone"
Profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: no)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
headset-output: Headset (priority: 0, latency offset: 0 usec)
Part of profile(s): a2dp_sink, headset_head_unit
headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
Part of profile(s): headset_head_unit
6.使用aplay软件播放音乐
6.1 aplay有时候可以正常播放,有时候不行,不清楚原因
root@imx6qsabresd:~#aplay test.wav
6.2 使用gstream播放器
//噪声测试
root@imx6qsabresd:~# gst-launch-1.0 audiotestsrc ! pulsesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstPulseSinkClock
imx-hdmi-audio imx-hdmi-audio: HDMI Video is not ready!
imx-hdmi-audio imx-hdmi-audio: ASoC: can't open platform imx-hdmi-audio: -22
//播放wav文件
root@imx6qsabresd:~# gst-launch-1.0 filesrc location=audio8k16S.wav ! wavparse !
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstPulseSinkClock
Got EOS from element "pipeline0".
Execution ended after 0:00:05.090986334
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
autoaudiosinkesd
6.3 使用paplay测试
paplay audio8k16S.wav
遇到的问题:
1.
W: [pulseaudio] main.c: This program is not intended to be run as root (unless –system is specified).
E: [pulseaudio] core-util.c: Home directory not accessible: Permission denied
解决办法:启动时加上pulseaudio --system
W: [pulseaudio] main.c: Running in system mode, but –disallow-exit not set!
W: [pulseaudio] main.c: Running in system mode, but –disallow-module-loading not set!
N: [pulseaudio] main.c: Running in system mode, forcibly disabling SHM mode!
N: [pulseaudio] main.c: Running in system mode, forcibly disabling exit idle time!
E: [pulseaudio] main.c: Failed to find user ‘pulse’.
解决办法:新建用户pulse
root@imx6qsabresd:~#useradd pulse
启动bluetoothctl时提示No default controller available
解决办法:没有启动bluetoothd
root@imx6qsabresd:~#bluetoothd&