fix: 修复 Linux 下快捷键和音频设备问题
1. GlobalShortcuts Portal 缺少 app_id 导致 "An app id is required" 错误 - 添加 app_id="io.impress.voice-input" 到 CreateSession 选项 2. 音频设备索引为 -1 时增加详细诊断日志 - 输出所有可用设备和 Host API 信息 - 当设备总数为 0 时提示安装 ALSA 依赖 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
3cf6b13392
commit
27c3374ea3
@ -185,8 +185,25 @@ bool AudioCapture::start(int deviceIndex, int sampleRate, int bufferSizeMs) {
|
||||
// 选择设备
|
||||
int devIdx = deviceIndex < 0 ? Pa_GetDefaultInputDevice() : deviceIndex;
|
||||
if (devIdx < 0 || devIdx >= Pa_GetDeviceCount()) {
|
||||
// 诊断:输出所有设备和 Host API 信息
|
||||
LOG_ERROR(kTag, QString("无效的音频设备索引: %1 (默认设备: %2)")
|
||||
.arg(deviceIndex).arg(Pa_GetDefaultInputDevice()));
|
||||
LOG_ERROR(kTag, QString("设备总数: %1, Host API 总数: %2")
|
||||
.arg(Pa_GetDeviceCount()).arg(Pa_GetHostApiCount()));
|
||||
for (int i = 0; i < Pa_GetDeviceCount(); i++) {
|
||||
const PaDeviceInfo* info = Pa_GetDeviceInfo(i);
|
||||
if (info) {
|
||||
LOG_DEBUG(kTag, QString(" 设备 #%1: %2 (输入通道: %3, 采样率: %4)")
|
||||
.arg(i).arg(info->name).arg(info->maxInputChannels)
|
||||
.arg(info->defaultSampleRate));
|
||||
}
|
||||
}
|
||||
if (Pa_GetDeviceCount() == 0) {
|
||||
LOG_ERROR(kTag, "PortAudio 未检测到任何音频设备。"
|
||||
"请确认系统已安装 ALSA/PulseAudio/PipeWire 音频服务,"
|
||||
"并且 libasound2 库可用(Debian: sudo apt install libasound2, "
|
||||
"Fedora: sudo dnf install alsa-lib)。");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -87,6 +87,7 @@ bool CapsLockVoiceHotkey::start() {
|
||||
QVariantMap options;
|
||||
options["handle_token"] = requestToken;
|
||||
options["session_handle_token"] = sessionToken;
|
||||
options["app_id"] = "io.impress.voice-input";
|
||||
|
||||
QDBusMessage reply = portal.call("CreateSession", options);
|
||||
if (reply.type() == QDBusMessage::ErrorMessage) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user