Preserve voice autoplay ordering while decoding in a worker

This commit is contained in:
evgeny committed 2026-10-01 18:29:43 +03:00
1 parent 172cc3a649
commit 318d72708c
3 files changed
+6 -3

No files matched your search

+4 -3
View File
@@ -968,7 +968,7 @@ void MainWindow::autoPlayCheckNewMessage(const QString& channelId) {
}
void MainWindow::autoPlayTimerTick() {
if (SoundManager::instance()->isCurrentPcmPlaying())
if (VoicePlayer::isPreparing() || SoundManager::instance()->isCurrentPcmPlaying())
return;
while (!m_autoPlayQueue.isEmpty()) {
@@ -996,8 +996,9 @@ void MainWindow::autoPlayTimerTick() {
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "auto-play: playing ch=%s msg=%lld file=%s dur=%.1fs",
qPrintable(chId), (long long)msgId, qPrintable(fullPath), (double)dur);
MessageDelegate::stopAllAutoPlay();
float actualDur = VoicePlayer::playOpusFile(fullPath);
MessageDelegate::startAutoPlay(fullPath, actualDur);
VoicePlayer::playOpusFile(fullPath, this, [fullPath](float actualDur) {
MessageDelegate::startAutoPlay(fullPath, actualDur);
});
return;
}
}
+1
View File
@@ -86,6 +86,7 @@ static unsigned s_decodeGeneration = 0; /* Только GUI-поток. */
static bool s_decoding = false;
void VoicePlayer::cancelPending() { s_decodeGeneration++; }
bool VoicePlayer::isPreparing() { return s_decoding; }
/* Декодирование и выделение PCM выполняются в worker; GUI принимает готовый буфер. */
void VoicePlayer::playOpusFile(const QString& filePath, QObject* context, std::function<void(float)> ready) {
+1
View File
@@ -12,6 +12,7 @@ class VoicePlayer {
public:
static void playOpusFile(const QString& filePath, QObject* context, std::function<void(float)> ready);
static void cancelPending();
static bool isPreparing();
static int decodeOpusFile(const QString& filePath, std::vector<int16_t>& outPcm,
int& outSampleRate, int& outChannels, float& outDurationSec);
static float playOpusFromReader(MediaBlockReader& reader);