蜡笔不信

蜡笔不信

2个粉丝

13

问答

3

专栏

2

资料

蜡笔不信  发布于  2023-09-07 17:11:57
采纳率 16%
13个问答
1037

RK3568 ANDROID11.0音频问题

悬赏E币 30 个
已结题

客户现有三路音频(现在mic),优先顺序要求是:蓝牙>ES8311>rk809, ES8311(L)和rk809(H)通过GPIO的电平选择,有大佬知道怎么修改吗?
注:ES8311、RK809、蓝牙均已调通。

我来回答
回答5个
时间排序
认可量排序

Stranger

10个粉丝

0

问答

5

专栏

6

资料

Stranger 2023-09-08 08:56:07
认可0

这样做的意义是啥?

蜡笔不信
蜡笔不信   回复   Stranger  2023-09-08 09:32:05
0

客户需要,谢谢大佬!

Stranger

10个粉丝

0

问答

5

专栏

6

资料

Stranger 2023-09-08 08:59:17
认可0

在frameworks/av/services/audiopolicy/enginedefault/src/Engine.cpp,或者GPIO状态,配置相关优先级策略

Stranger

10个粉丝

0

问答

5

专栏

6

资料

Stranger 2023-09-08 09:03:18
认可0
易百纳技术社区该回答已被题主采纳为最佳答案

sp Engine::getDeviceForInputSource(audio_source_t inputSource) const
{
const DeviceVector availableOutputDevices = getApmObserver()->getAvailableOutputDevices();
const DeviceVector availableInputDevices = getApmObserver()->getAvailableInputDevices();
const SwAudioOutputCollection &outputs = getApmObserver()->getOutputs();
DeviceVector availableDevices = availableInputDevices;
sp primaryOutput = outputs.getPrimaryOutput();
DeviceVector availablePrimaryDevices = primaryOutput == nullptr ? DeviceVector()
: availableInputDevices.getDevicesFromHwModule(primaryOutput->getModuleHandle());
sp device;

// when a call is active, force device selection to match source VOICE_COMMUNICATION
// for most other input sources to avoid rerouting call TX audio
if (isInCall()) {
    switch (inputSource) {
    case AUDIO_SOURCE_DEFAULT:
    case AUDIO_SOURCE_MIC:
    case AUDIO_SOURCE_VOICE_RECOGNITION:
    case AUDIO_SOURCE_UNPROCESSED:
    case AUDIO_SOURCE_HOTWORD:
    case AUDIO_SOURCE_CAMCORDER:
    case AUDIO_SOURCE_VOICE_PERFORMANCE:
        inputSource = AUDIO_SOURCE_VOICE_COMMUNICATION;
        break;
    default:
        break;
    }
}

switch (inputSource) {
case AUDIO_SOURCE_DEFAULT:
case AUDIO_SOURCE_MIC:
    device = availableDevices.getDevice(
            AUDIO_DEVICE_IN_BLUETOOTH_A2DP, String8(""), AUDIO_FORMAT_DEFAULT);
    if (device != nullptr) break;
    if (getForceUse(AUDIO_POLICY_FORCE_FOR_RECORD) == AUDIO_POLICY_FORCE_BT_SCO) {
        device = availableDevices.getDevice(
                AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, String8(""), AUDIO_FORMAT_DEFAULT);
        if (device != nullptr) break;
    }
    device = availableDevices.getFirstExistingDevice({
            AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET,
            AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC});
    break;

case AUDIO_SOURCE_VOICE_COMMUNICATION:
    // Allow only use of devices on primary input if in call and HAL does not support routing
    // to voice call path.
    if ((getPhoneState() == AUDIO_MODE_IN_CALL) &&
            (availableOutputDevices.getDevice(AUDIO_DEVICE_OUT_TELEPHONY_TX,
                    String8(""), AUDIO_FORMAT_DEFAULT)) == nullptr) {
        LOG_ALWAYS_FATAL_IF(availablePrimaryDevices.isEmpty(), "Primary devices not found");
        availableDevices = availablePrimaryDevices;
    }

    switch (getForceUse(AUDIO_POLICY_FORCE_FOR_COMMUNICATION)) {
    case AUDIO_POLICY_FORCE_BT_SCO:
        // if SCO device is requested but no SCO device is available, fall back to default case
        device = availableDevices.getDevice(
                AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET, String8(""), AUDIO_FORMAT_DEFAULT);
        if (device != nullptr) {
            break;
        }
        FALLTHROUGH_INTENDED;

    default:    // FORCE_NONE
        device = availableDevices.getFirstExistingDevice({
                AUDIO_DEVICE_IN_WIRED_HEADSET, AUDIO_DEVICE_IN_USB_HEADSET,
                AUDIO_DEVICE_IN_USB_DEVICE, AUDIO_DEVICE_IN_BUILTIN_MIC});
       //如果想要修改顺序,调整列表里的设备即可
        break;

    case AUDIO_POLICY_FORCE_SPEAKER:
        device = availableDevices.getFirstExistingDevice({
                AUDIO_DEVICE_IN_BACK_MIC, AUDIO_DEVICE_IN_BUILTIN_MIC});
        break;
    }
    break;

case AUDIO_SOURCE_VOICE_RECOGNITION:
case AUDIO_SOURCE_UNPROCESSED:
case AUDIO_SOURCE_HOTWORD:
case AUDIO_SOURCE_CAMCORDER:
case AUDIO_SOURCE_VOICE_DOWNLINK:
case AUDIO_SOURCE_VOICE_CALL:
case AUDIO_SOURCE_VOICE_UPLINK:
case AUDIO_SOURCE_VOICE_PERFORMANCE:
case AUDIO_SOURCE_REMOTE_SUBMIX:
case AUDIO_SOURCE_FM_TUNER:
case AUDIO_SOURCE_ECHO_REFERENCE:
default:
    ALOGW("getDeviceForInputSource() invalid input source %d", inputSource);
    break;
}
if (device == nullptr) {
    ALOGV("getDeviceForInputSource() no device found for source %d", inputSource);
    device = availableDevices.getDevice(
            AUDIO_DEVICE_IN_STUB, String8(""), AUDIO_FORMAT_DEFAULT);
    ALOGE_IF(device == nullptr,
             "getDeviceForInputSource() no default device defined");
}
ALOGV_IF(device != nullptr,
         "getDeviceForInputSource()input source %d, device %08x",
         inputSource, device->type());
return device;

}

Janus

2个粉丝

0

问答

0

专栏

0

资料

Janus 2023-10-18 13:52:30
认可0

学习了,谢谢!

或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
+ 添加网盘链接/附件

Markdown 语法

  • 加粗**内容**
  • 斜体*内容*
  • 删除线~~内容~~
  • 引用> 引用内容
  • 代码`代码`
  • 代码块```编程语言↵代码```
  • 链接[链接标题](url)
  • 无序列表- 内容
  • 有序列表1. 内容
  • 缩进内容
  • 图片![alt](url)
相关问答
无更多相似问答 去提问
举报反馈

举报类型

  • 内容涉黄/赌/毒
  • 内容侵权/抄袭
  • 政治相关
  • 涉嫌广告
  • 侮辱谩骂
  • 其他

详细说明

易百纳技术社区