Files
MeowOS-For-R3P2/patch_v2/meow_audiod/bt_dev.h
T

28 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* bt_dev.h — 蓝牙 A2DP 设备自识别(DEV 自动更新纯逻辑,宿主可单测)。
*
* 背景:/usr/data/alsa.conf 的 `pcm.bluealsa`(plug→bluealsa)需把 DEV/device 钉在当前
* 连接的 A2DP sink 设备 MAC 上才能正确出声。本模块提供两段纯逻辑(无 meow_* / popen / 文件
* I/O —— meow_audiod 负责读文件与执行系统命令):
* - bt_dev_detect_mac:从 `bluealsa-cli list-pcms` 输出提取第一个 a2dpsrc 端点的设备 MAC;
* - bt_dev_rewrite:幂等改写 alsa.conf 文本,把 `pcm.bluealsa` 块内 `DEV=<mac>` 与
* `device <mac>` 两处换成目标 MAC(保留引号风格 / codec / 其余 token)。
* 纯 libc(string / stdlib),独立编译,宿主零链接重。
*/
#ifndef BT_DEV_H
#define BT_DEV_H
#include <stddef.h>
/* 解析 bluealsa-cli list-pcms 输出,取第一个 a2dpsrc/a2dp_source 端点的设备 MAC。
* 返回 0=找到并写入 mac(NUL 结尾),-1=无 a2dpsrc 端点 / 参数非法。macsz 建议 ≥18。 */
int bt_dev_detect_mac(const char *listpcms, char *mac, size_t macsz);
/* 幂等改写 alsa.conf 文本(in_len 不含 NUL):把 `pcm.bluealsa` 块内 `DEV=<mac>` 与
* `device <mac>` 两处 MAC 换成 mac(保留引号风格、codec/其它 token 原样)。
* 返回 0=已改动(*out 与 *out_len 给出新文本,调用方负责 free);1=无需改动(两端已一致);
* -1=无 pcm.bluealsa / 无 DEV= 或 device token / 参数非法(不动)。 */
int bt_dev_rewrite(const char *in, size_t in_len, const char *mac,
char **out, size_t *out_len);
#endif /* BT_DEV_H */