fix: 修复 chunkCompleted 信号文件路径为空的 bug

closeCurrentFile() 会清空 currentFilePath_,之前代码在 closeCurrentFile()
之后才读取 currentFilePath_ 赋值给 completedPath,导致 emit 的路径为空。
修复:在 closeCurrentFile() 之前先保存文件路径和时长。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Alvin Young 2026-06-11 14:08:16 +08:00
parent f4b7149435
commit 79085b862b

View File

@ -115,13 +115,15 @@ void StreamingAudioWriter::writeSamples(const std::vector<float>& samples) {
.arg(silenceFramesAfterSpeech_)
.arg(vad_->currentEnergy(), 0, 'f', 4));
// 完成当前文件
// 保存文件信息(必须在 closeCurrentFile 之前)
QString completedPath = currentFilePath_;
int durationMs = static_cast<int>(samplesWritten_ * 1000 / sampleRate_);
// 完成并关闭当前文件
finalizeWavFile();
closeCurrentFile();
// 发射完成信号
int durationMs = static_cast<int>(samplesWritten_ * 1000 / sampleRate_);
QString completedPath = currentFilePath_;
emit chunkCompleted(completedPath, durationMs);
// 打开新文件