我们正在致力于定制板有音频编解码,AM/FM调谐器,BT耳机,BT经典都由I2S外围控制。我们想路由音频从BT经典到音频编解码,BT经典到BT耳机等等。
我们计划有两个独立的线程连接两个音频设备。在应用程序空间中,我们将提供独立的设备ID,这些ID将指示应该播放音频的设备。
我需要知道我们如何创建一个线程互连2个音频设备?此外,有没有其他方法来路由各种音频设备输出到另一个音频设备?
发布于 2022-11-19 07:52:43
BluetoothAdapter.getDefaultAdapter().getProfileProxy(this, mScanCallback, BluetoothProfile.A2DP);
BluetoothProfile.ServiceListener mScanCallback = new BluetoothProfile.ServiceListener() {
@Override
public void onServiceConnected(int profile, BluetoothProfile proxy) {
if (profile == BluetoothProfile.A2DP) {
proxy.getConnectedDevices().forEach(device -> {
if (selectedDevice1 != null
&& selectedDevice1.getDeviceMAC().equalsIgnoreCase(device.getAddress())) {
try {
Class clazz = Class.forName("android.bluetooth.BluetoothA2dp");
Method method = clazz.getMethod("setActiveDevice", BluetoothDevice.class);
method.invoke(proxy, device);
} catch (Exception e) {
Log.e("TEST", "", e);
}
}
});
}
}
@Override
public void onServiceDisconnected(int i) {
}
};https://stackoverflow.com/questions/61770799
复制相似问题