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-00805f9b34fb00001203-0000-1000-8000-00805f9b34fb0000111f-0000-1000-8000-00805f9b34fb00001116-0000-1000-8000-00805f9b34fb00001115-0000-1000-8000-00805f9b34fb0000110c-0000-1000-8000-00805f9b34fb0000110f-0000-1000-8000-00805f9b34fb0000110a-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-00805f9b34fb0000110e-0000-1000-8000-00805f9b34fb0000111e-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:AEName: J2-USB BluetoothAlias: J2-USB BluetoothClass: 0x240404Icon: audio-cardPaired: yesTrusted: noBlocked: noConnected: yesLegacyPairing: yesUUID: 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 helplist-modules              List loaded moduleslist-cards                List cardslist-sinks                List loaded sinkslist-sources              List loaded sourceslist-clients              List loaded clientslist-sink-inputs          List sink inputslist-source-outputs       List source outputsstat                      Show memory block statisticsinfo                      Show comprehensive statusload-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 cacheplay-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 configurationdump-volumes              Debug: Show the state of all volumesshared                    Debug: Show shared propertiesexit                      Terminate the daemon
root@imx6qsabresd:~#pactl list cards
Card #0Name: alsa_card.platform-sound.20Driver: module-alsa-card.cOwner Module: 7Properties: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-stereoPorts: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-stereoanalog-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-stereoanalog-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 #1Name: bluez_card.35_BD_7B_5D_CC_AEDriver: module-bluez5-device.cOwner Module: 24Properties: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_sinkPorts:headset-output: Headset (priority: 0, latency offset: 0 usec)Part of profile(s): a2dp_sink, headset_head_unitheadset-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: 1name: <bluez_sink.35_BD_7B_5D_CC_AE>driver: <module-bluez5-device.c>flags: HARDWARE DECIBEL_VOLUME LATENCY state: SUSPENDEDsuspend cause: IDLE priority: 9030volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00base volume: 65536 / 100% / 0.00 dBvolume steps: 65537muted: nocurrent latency: 0.00 msmax request: 2 KiBmax rewind: 0 KiBmonitor source: 1sample spec: s16le 2ch 44100Hzchannel map: front-left,front-rightStereoused by: 0linked by: 0fixed latency: 39.51 mscard: 0 <bluez_card.35_BD_7B_5D_CC_AE>module: 24properties: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: <headset-output>
root@imx6qsabresd:~#pacmd list-cards
1 card(s) available.index: 0name: <bluez_card.35_BD_7B_5D_CC_AE>driver: <module-bluez5-device.c>owner module: 24properties: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: <a2dp_sink>sinks:bluez_sink.35_BD_7B_5D_CC_AE/#1: J2-USB Bluetoothsources:bluez_sink.35_BD_7B_5D_CC_AE.monitor/#1: Monitor of J2-USB Bluetoothports: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: 0name: <module-device-restore>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Automatically restore the volume/mute state of devices"module.version = "6.0"index: 1name: <module-stream-restore>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Automatically restore the volume/mute/device state of streams"module.version = "6.0"index: 2name: <module-card-restore>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Automatically restore profile of cards"module.version = "6.0"index: 3name: <module-augment-properties>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Augment the property sets of streams with additional static information"module.version = "6.0"index: 4name: <module-switch-on-port-available>argument: <>used: -1load once: noproperties:index: 5name: <module-udev-detect>argument: <tsched=0>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Detect available audio hardware and load matching drivers"module.version = "6.0"index: 7name: <module-bluetooth-policy>argument: <>used: -1load once: yesproperties:module.author = "Fr茅d茅ric Dalleau"module.description = "When a bluetooth sink or source is added, load module-loopback"module.version = "6.0"index: 8name: <module-bluetooth-discover>argument: <>used: -1load once: yesproperties:module.author = "Jo茫o Paulo Rechi Vita"module.description = "Detect available Bluetooth daemon and load the corresponding discovery module"module.version = "6.0"index: 9name: <module-bluez5-discover>argument: <>used: -1load once: yesproperties: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: 10name: <module-native-protocol-unix>argument: <>used: -1load once: noproperties:module.author = "Lennart Poettering"module.description = "Native protocol (UNIX sockets)"module.version = "6.0"index: 11name: <module-default-device-restore>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Automatically restore the default sink and source"module.version = "6.0"index: 12name: <module-rescue-streams>argument: <>used: -1load once: yesproperties: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: 13name: <module-always-sink>argument: <>used: -1load once: yesproperties: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: 15name: <module-intended-roles>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Automatically set device of streams based on intended roles of devices"module.version = "6.0"index: 16name: <module-suspend-on-idle>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "When a sink/source is idle for too long, suspend it"module.version = "6.0"index: 17name: <module-console-kit>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Create a client for each ConsoleKit session of this user"module.version = "6.0"index: 18name: <module-position-event-sounds>argument: <>used: -1load once: yesproperties: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: 19name: <module-role-cork>argument: <>used: -1load once: yesproperties:module.author = "Lennart Poettering"module.description = "Mute & cork streams with certain roles while others exist"module.version = "6.0"index: 20name: <module-filter-heuristics>argument: <>used: -1load once: yesproperties:module.author = "Colin Guthrie"module.description = "Detect when various filters are desirable"module.version = "6.0"index: 21name: <module-filter-apply>argument: <>used: -1load once: yesproperties:module.author = "Colin Guthrie"module.description = "Load filter sinks automatically when needed"module.version = "6.0"index: 22name: <module-x11-publish>argument: <display=:0>used: -1load once: noproperties:module.author = "Lennart Poettering"module.description = "X11 credential publisher"module.version = "6.0"index: 23name: <module-x11-cork-request>argument: <display=:0>used: -1load once: noproperties:module.author = "Lennart Poettering"module.description = "Synthesize X11 media key events when cork/uncork is requested"module.version = "6.0"index: 24name: <module-bluez5-device>argument: <path=/org/bluez/hci0/dev_35_BD_7B_5D_CC_AE>used: 0load once: noproperties:module.author = "Jo茫o Paulo Rechi Vita"module.description = "BlueZ 5 Bluetooth audio sink and source"module.version = "6.0"index: 25name: <module-cli-protocol-unix>argument: <>used: -1load once: noproperties:module.author = "Lennart Poettering"module.description = "Command line interface protocol (UNIX sockets)"module.version = "6.0"
1 sink(s) available.* index: 1name: <bluez_sink.35_BD_7B_5D_CC_AE>driver: <module-bluez5-device.c>flags: HARDWARE DECIBEL_VOLUME LATENCY state: SUSPENDEDsuspend cause: IDLE priority: 9030volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00base volume: 65536 / 100% / 0.00 dBvolume steps: 65537muted: nocurrent latency: 0.00 msmax request: 2 KiBmax rewind: 0 KiBmonitor source: 1sample spec: s16le 2ch 44100Hzchannel map: front-left,front-rightStereoused by: 0linked by: 0fixed latency: 39.51 mscard: 0 <bluez_card.35_BD_7B_5D_CC_AE>module: 24properties: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: <headset-output>
1 source(s) available.* index: 1name: <bluez_sink.35_BD_7B_5D_CC_AE.monitor>driver: <module-bluez5-device.c>flags: DECIBEL_VOLUME LATENCY state: SUSPENDEDsuspend cause: IDLE priority: 1030volume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00base volume: 65536 / 100% / 0.00 dBvolume steps: 65537muted: nocurrent latency: 0.00 msmax rewind: 0 KiBsample spec: s16le 2ch 44100Hzchannel map: front-left,front-rightStereoused by: 0linked by: 0fixed latency: 39.51 msmonitor_of: 1card: 0 <bluez_card.35_BD_7B_5D_CC_AE>module: 24properties: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: 26driver: <cli.c>owner module: 25properties:application.name = "UNIX socket client"
1 card(s) available.index: 0name: <bluez_card.35_BD_7B_5D_CC_AE>driver: <module-bluez5-device.c>owner module: 24properties: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: <a2dp_sink>sinks:bluez_sink.35_BD_7B_5D_CC_AE/#1: J2-USB Bluetoothsources:bluez_sink.35_BD_7B_5D_CC_AE.monitor/#1: Monitor of J2-USB Bluetoothports: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 #0State: SUSPENDEDName: alsa_output.platform-sound.20.analog-stereoDescription: wm8962-audio Analog StereoDriver: module-alsa-card.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 7Mute: noVolume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00Base Volume: 65536 / 100% / 0.00 dBMonitor Source: alsa_output.platform-sound.20.analog-stereo.monitorLatency: 0 usec, configured 0 usecFlags: 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-headphonesFormats:pcmSink #1State: SUSPENDEDName: bluez_sink.35_BD_7B_5D_CC_AEDescription: J2-USB BluetoothDriver: module-bluez5-device.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 24Mute: noVolume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00Base Volume: 65536 / 100% / 0.00 dBMonitor Source: bluez_sink.35_BD_7B_5D_CC_AE.monitorLatency: 0 usec, configured 0 usecFlags: 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-outputFormats:pcm
root@imx6qsabresd:~# pacmd set-default-sink 1
root@imx6qsabresd:~# pactl list sources
Source #0State: SUSPENDEDName: alsa_output.platform-sound.20.analog-stereo.monitorDescription: Monitor of wm8962-audio Analog StereoDriver: module-alsa-card.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 7Mute: noVolume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00Base Volume: 65536 / 100% / 0.00 dBMonitor of Sink: alsa_output.platform-sound.20.analog-stereoLatency: 0 usec, configured 0 usecFlags: 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:pcmSource #1State: SUSPENDEDName: alsa_input.platform-sound.20.analog-stereoDescription: wm8962-audio Analog StereoDriver: module-alsa-card.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 7Mute: noVolume: front-left: 33804 /  52% / -17.25 dB,   front-right: 33804 /  52% / -17.25 dBbalance 0.00Base Volume: 26090 /  40% / -24.00 dBMonitor of Sink: n/aLatency: 0 usec, configured 0 usecFlags: 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-inputFormats:pcmSource #2State: SUSPENDEDName: bluez_sink.35_BD_7B_5D_CC_AE.monitorDescription: Monitor of J2-USB BluetoothDriver: module-bluez5-device.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 24Mute: noVolume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00Base Volume: 65536 / 100% / 0.00 dBMonitor of Sink: bluez_sink.35_BD_7B_5D_CC_AELatency: 0 usec, configured 0 usecFlags: 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 #1State: SUSPENDEDName: bluez_sink.35_BD_7B_5D_CC_AEDescription: J2-USB BluetoothDriver: module-bluez5-device.cSample Specification: s16le 2ch 44100HzChannel Map: front-left,front-rightOwner Module: 24Mute: noVolume: front-left: 65536 / 100% / 0.00 dB,   front-right: 65536 / 100% / 0.00 dBbalance 0.00Base Volume: 65536 / 100% / 0.00 dBMonitor Source: bluez_sink.35_BD_7B_5D_CC_AE.monitorLatency: 0 usec, configured 0 usecFlags: 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-outputFormats:pcm
root@imx6qsabresd:~# pactl list cards
Card #0Name: bluez_card.35_BD_7B_5D_CC_AEDriver: module-bluez5-device.cOwner Module: 24Properties: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_sinkPorts:headset-output: Headset (priority: 0, latency offset: 0 usec)Part of profile(s): a2dp_sink, headset_head_unitheadset-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&

嵌入式linux开发板使用pulseaudio连接蓝牙耳机播放音频文件相关推荐

  1. linux开发板通过网线连接电脑(win10)连接网络问题

    最近开始学习嵌入式Linux开发,使用野火imx6ull开发板,想把开发板通过网线连接到笔记本(笔记本连接WiFi),共享使用网络:查询了很多资料后成功实现,我现在把这个方法分享出来. 1.禁用防火墙 ...

  2. 嵌入式Linux开发板上NFS文件系统的使用【ZT】

    本文转载于http://www.dz863.com/RTOS/Embedded-linux/Linux-NFS.htm 本文描述了在开发嵌入式linux系统时调试程序的一个方法,本文以深圳远峰的YF2 ...

  3. 嵌入式Linux开发板_WIFI无线网卡驱动移植

    在线课堂:https://www.100ask.net/index(课程观看) 论  坛:http://bbs.100ask.net/(学术答疑) 开 发 板:https://100ask.taoba ...

  4. 嵌入式linux开发板USB功能测试 Sigmstar星辰科技SD222D

    一.内核配置 首先需要配置内核,进入kernel文件夹,执行指令make menuconfig 进入图形化界面 Devices Drivers--->[*]USB supprot----> ...

  5. 迅为IMX8MM开发板Yocto系统使用Gstarwmra播放音频和视频

    Gplay 是基于 Gstreamer 实现的音视频播放器,他能够自动根据硬件自动选择合适的插件进行音视频 播放,运行也十分简单,我们输入以下命令播放 mp4 视频. gst-play-1.0 /gs ...

  6. crt无法网络连接linux开发板,securceCRT网络连接不正常解决途径

    作为一名初学的小白,在完成作业练习时出现了很多别人看起来简单却让我十分头疼的问题,其中最麻烦和头疼的就是用securceCRT时出现的网络连接不正常. 在查看VM ware虚拟机时用ifconfig查 ...

  7. Linux开发板开机自动连接WiFi,IMX6UL(讯为开发板)。

    总共需要修改三个文件 1.wpa_supplicant.conf 2.link_wifi.sh 3.rc.local 1.wpa_supplicant.conf 文件路径:/etc/wpa_suppl ...

  8. ubuntu20.04.1 64位搭建嵌入式linux开发环境

    目录 背景 开发环境的搭建 1.交叉编译工具的安装 2.开发工具和依赖库的安装 2.1. 必需部分 2.2.可选部分 ubuntu20.04.1 64位配置和编译Linux3.0内核 背景 市面上的嵌 ...

  9. 嵌入式Linux开发——解决uboot无法使用nfs服务从ubuntu中下载文件(TTT、cannot mount等错误)

    前言: 最近在学习正点原子嵌入式Linux开发板uboot的移植实验,移植完之后想测试网络部分的驱动能否工作正常.最后经过测试发现tftp可以正常下载,nfs却一直报错无法下载文件,最后也是折磨了两天 ...

最新文章

  1. 远程处理Remoting
  2. highstock 只显示所有 不显示 月_小米34寸曲面显示器深度体验 办公体验极佳 但是还有个大弱点...
  3. python3连接sql server数据库_Python3操作SQL Server数据库(实例讲解)
  4. 一个复平面上的不等式
  5. 公钥、私钥、数字签名和数字证书的概念及解密
  6. python语法学习第五天--函数(2)
  7. 使用Notepad2替代系统笔记本
  8. 安装签名不一致什么意思_探灵之夜嫁安装失败签名不一致怎么办-夜嫁安装失败签名不一致解决方法-松松手游网...
  9. 计算机组策略恢复,Win10重置组策略编辑器的方法
  10. 银行IT系统整体架构
  11. 记一次前端优化首屏加载
  12. android 铃音制作工具,来电铃声大全制作软件
  13. echarts 地图上如何打点
  14. 一款非常棒的开源微社区轻论坛类源码
  15. Vue3使用axios的配置教程
  16. 智能优化算法:CEC23组常用测试函数公式介绍
  17. 啊哈C——学习2.8一起来找茬
  18. 【计算几何】atan2函数
  19. 【已解决】CentOS 7 安装MySQL80报错:pkgconfig(openssl) is needed by mysql-community-devel-8.0.28-1.el7.x86_64
  20. 如何利用有限的数据发表更多的SCI论文?——利用ArcGIS探究环境和生态因子对水体、土壤和大气污染物的影响

热门文章

  1. 计算机音乐谱水手,Aloha Heja He简谱-Achim Reichel-抖音神曲,一首德国水手老歌再次燃爆整个少年青春...
  2. PECL轻松安装PHP扩展
  3. 查找方法----二分查找
  4. 随笔——基尔霍夫热辐射定律中灰体发射率和吸收率相等的推导逻辑
  5. Flutter开发之JSON解析
  6. Flex中实现double-click修改DataGrid
  7. activiti使用详解(一)
  8. win7计算机中找不到硬盘分区,解决方案:系统找不到硬盘分区的原因
  9. python批量添加经纬度照片水印,照片水印,坐标转换
  10. Dreamweaver CC 2018使用(个人使用总结)