> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 排查音频问题

> 在 Qualcomm Linux 平台上捕获并分析音频日志,以诊断和解决音频问题。

本节提供用于音频日志记录和调试的命令。

## **捕获日志**

用户空间和内核音频驱动程序日志有助于发现问题。

| **用户空间日志** | 要捕获用户空间日志: |
| :--------- | :--------- |

```text theme={null}
ssh root@ip-addr
mount -o remount,rw /
cat /var/log/user.log
```

有关更多说明,请参阅[用户空间日志](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/debug-with-user-space-logs)。

| **内核音频驱动程序日志** | 要捕获内核日志: |
| :------------- | :------- |

```text theme={null}
ssh root@ip-addr dmesg
```

要在特定文件中禁用内核日志:

```text theme={null}
echo -n "file <filename> -p" > /sys/kernel/debug/dynamic_debug/control
```

| **动态内核日志** | 动态日志记录默认处于禁用状态。要启用它,请添加 `CONFIG_DYNAMIC_DEBUG` 内核配置,重新编译并重新烧写设备。要启用音频动态内核日志: |
| :--------- | :--------------------------------------------------------------------------- |

```text theme={null}
ssh root@ip-addr
mount -o rw,remount /
mount -t debugfs none /sys/kernel/debug
echo -n "file <filename> +p" > /sys/kernel/debug/dynamic_debug/control
```

有关更多说明,请参阅[启用动态调试](https://dragonwingdocs.qualcomm.com/System/Debug-Subsystem/enable-kernel-debugging)。

## **分析日志**

分析播放和录制用例的用户空间和内核音频驱动程序日志。

### **播放日志**

以下日志片段显示了为播放用例收集的信息。

```text theme={null}
//Open Low latency Playback stream. Details of each stream type can be found at sources/audio/opensource/arpal-lx/inc/PalDefs.h
2022-04-28T18:02:08.748280+00:00 pipewire: pal_stream_open: 224: Enter, stream type:1

//Verify the backend device, sample rate, bitwidth, channels etc
2022-04-28T18:02:08.748627+00:00 pipewire: setMediaConfig: 1056: CODEC_DMA-LPAIF_WSA-RX-0 rate ch fmt data_fmt 48000 2 2 1

//Start playback stream
2022-04-28T18:02:08.751947+00:00 pipewire: pal_stream_start: 338: Enter. Stream handle 0xffff94001040K

//Map the metadata with kvh2xml.h file for playback use case details.
2022-04-28T18:02:08.853157+00:00 pipewire: metadata_print: 82 key:0xa1000000, value:0xa100000e//PCM_LL_PLAYBACK
2022-04-28T18:02:08.853395+00:00 pipewire: metadata_print: 82 key:0xab000000, value:0x1
2022-04-28T18:02:08.853660+00:00 pipewire: metadata_print: 82 key:0xa2000000, value:0xa2000001//Speaker
2022-04-28T18:02:08.853881+00:00 pipewire: metadata_print: 82 key:0xac000000, value:0xac000002//DEVICEPP_RX_AUDIO_MBDRC

//Verify the graph opened for playback use case
2022-04-28T18:02:08.856934+00:00 pipewire: print_graph_alias: 2334 GKV Alias 142 | StreamRX_PCM_LL_Playback_DeviceRX_Speaker_Instance_Instance_1_DevicePP_Rx_Audio_MBDRC
//graph_open called
2022-04-28T18:02:08.859509+00:00 pipewire: graph_open: 709 graph_handle 0x47534c

//Configure hardware endpoint module
2022-04-28T18:02:08.864386+00:00 pipewire: configure_hw_ep_media_config: 636 entry mod tag c0000004 miid 43b1 mid 7001023
2022-04-28T18:02:08.864495+00:00 pipewire: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 2, data_fmt 1
2022-04-28T18:02:08.864603+00:00 pipewire: configure_hw_ep_media_config: 676 exit, ret 0

//graph_start entry
2022-04-28T18:02:08.867234+00:00 pipewire: graph_start: 899 entry graph_handle 0x47534c
//Stream started
2022-04-28T18:02:08.867864+00:00 pipewire: pal_stream_start: 387: Exit. status 0

//graph_stop entry
2022-04-28T18:02:25.037338+00:00 pipewire: graph_stop: 928 entry graph_handle 0x47534c
//Stop the PAL stream once playback completes
2022-04-28T18:02:25.039923+00:00 pipewire: pal_stream_stop: 441: Exit. status 0

//graph_close entry
2022-04-28T18:02:25.050944+00:00 pipewire: graph_close: 762 entry handle 0x47534c
//Close the PAL stream
2022-04-28T18:02:25.054510+00:00 pipewire: pal_stream_close: 322: Exit. status 0
```

### **录制日志**

以下日志片段显示了为录制用例收集的信息。

```text theme={null}
//Open Recording stream for PAL_STREAM_RAW. Details of stream type can be found at sources/audio/opensource/arpal-lx/inc/PalDefs.h
Apr 29 09:23:11 pipewire[862]: pal_stream_open: 224: Enter, stream type:9

//Verify the backend device, sample rate, bitwidth, channels etc
Apr 29 09:23:11 pipewire[862]: setMediaConfig: 1056: CODEC_DMA-LPAIF_VA-TX-0 rate ch fmt data_fmt 48000 1 2 1

//Start recording stream
Apr 29 09:23:11 pipewire[862]: pal_stream_start: 338: Enter. Stream handle 0xffff6c001040K

//graph_open entry
Apr 29 09:23:11 pipewire[862]: graph_open: 709 graph_handle 0x47534c

//Metadata details to identify the use case
Apr 29 09:23:11 pipewire[862]: metadata_print: 82 key:0xb1000000, value:0xb1000009//RAW_RECORD
Apr 29 09:23:11 pipewire[862]: metadata_print: 82 key:0xa3000000, value:0xa3000004//HANDSETMIC

//Verify the graph opened for recording use case
Apr 29 09:23:11 pipewire[862]: print_graph_alias: 2334 GKV Alias 29 | DeviceTX_Handset_Mic_StreamTX_RAW_Record

//Configure hardware endpoint module
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 636 entry mod tag c0000005 miid 43af mid 7001024
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 1, data_fmt 1
Apr 29 09:23:11 pipewire[862]: configure_hw_ep_media_config: 676 exit, ret 0

//graph_start entry
Apr 29 09:23:11 pipewire[862]: graph_start: 899 entry graph_handle 0x47534c
//Stream recording started
Apr 29 09:23:11 pipewire[862]: pal_stream_start: 387: Exit. status 0


//graph_stop entry
Apr 29 09:23:26 pipewire[862]: graph_stop: 928 entry graph_handle 0x47534c
//Stop the PAL stream once user stops recording
Apr 29 09:23:26 pipewire[862]: D: [regular2] pal-source.c: pal_stream_stop returned 0

//Close the PAL stream
Apr 29 09:23:26 pipewire[862]: pal_stream_close: 284: Enter. Stream handle :0xffff6c001040K
//graph_close entry
Apr 29 09:23:26 pipewire[862]: graph_close: 762 entry handle 0x47534c
//Close the PAL stream
Apr 29 09:23:26 pipewire[862]: pal_stream_close: 322: Exit. status 0
```

## **使用 QXDM 启用诊断日志记录**

QXDM Professional™(QXDM Pro)为诊断客户端提供快速原型平台。它提供 GUI 来可视化从设备传输的数据,并允许您使用 DMC(诊断掩码配置)文件配置和过滤音频日志。

### **为音频日志记录配置 QXDM**

1. 在您的 PC 上打开 QXDM Professional。

2. 连接到目标设备。

3. 选择 **File** → **Manage Configuration**。

4. 从列表中选择所需用例的 DMC 日志掩码。

5. 应用 DMC 配置,开始捕获音频诊断日志。

<Note>
  从 Qualcomm Software Center 下载 QXDM Professional。有关更多详细信息,请参阅 QACT V8.1 User Guide(80-VM407-21)。
</Note>

### **音频诊断所需的工具**

要获得完整的音频诊断能力,需要以下工具:

| 工具                    | 用途                  |
| :-------------------- | :------------------ |
| QACT v8.1             | 配置和校准音频用例与功能        |
| QXDM Professional     | 配置和过滤音频诊断日志         |
| Qualcomm USB 驱动程序     | PC 与目标设备之间的 USB 连接  |
| Qualcomm 统一工具服务(QUTS) | QXDM 和 QACT 连接所需的服务 |

从 Qualcomm Software Center 下载所有工具。

### **分析 MI2S/TDM 捕获日志**

验证 MI2S 或 TDM 捕获时,检查以下日志模式以确认操作正确:

应为扬声器麦克风调用设备打开:

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: open: 469: Enter. deviceCount 0 for device id 28 (PAL_DEVICE_IN_SPEAKER_MIC)
```

用于捕获的后端应显示正确的 MI2S 接口、采样率和声道数:

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: setMediaConfig: 1056: MI2S-LPAIF-TX-PRIMARY rate ch fmt data_fmt 48000 2 2 1
```

设备打开应以状态 0 退出并显示正确的设备计数:

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: open: 504: Exit. deviceCount 1 for device id 28 (PAL_DEVICE_IN_SPEAKER_MIC), exit status: 0
```

硬件端点应正确配置为 48 kHz、立体声、16 位:

```text theme={null}
Apr 29 15:50:46 pipewire[1001]: configure_hw_ep_media_config: 664 rate 48000 bw 16 ch 2, data_fmt 1
```

## **后续步骤**

* [音频补充文档](../audio-addendum-overview) — 使用 QACT 和 QXDM 进行校准和诊断
* [自定义音频图](customize-audio-graph) — 修改音频图和 PAL 配置
* [高级音频功能](advanced-audio-features) — 启用回声消除和噪声抑制
