Browse Source

Drain startup audio on END and validate Opus fixture failures

master
evgeny 1 week ago
parent
commit
79701feef1
  1. 8
      tools/chatgui/src/streamplayer_window.cpp
  2. 6
      tools/chatgui/tests/test_stream_view.cpp

8
tools/chatgui/src/streamplayer_window.cpp

@ -186,7 +186,7 @@ void StreamPlayerWindow::decode() {
uint32_t videoRevision = 0;
auto reset = [&] {
avcodec_free_context(&decoder);
opus_codec_decoder_destroy(opus); opus = nullptr; expectedAudio = -1; waitKey = true;
opus_codec_decoder_destroy(opus); opus = nullptr; expectedAudio = -1; waitKey = true; prerollSamples = 0;
std::lock_guard<std::mutex> guard(p.lock);
p.videos.clear(); p.videoBytes = 0; p.audios.clear(); p.prefillUntil = 0; p.videoBase = p.audioPts = -1;
emit statusChanged(text("Waiting for a key frame…"));
@ -213,7 +213,11 @@ void StreamPlayerWindow::decode() {
: record.reason == STREAM_CLOSE_GROUP ? "The channel is closed" : "Could not continue the stream";
fail(text(reason)); break;
}
if (record.kind == StreamRecordKind::End) { std::lock_guard<std::mutex> guard(p.lock); p.ended = true; break; }
if (record.kind == StreamRecordKind::End) {
std::lock_guard<std::mutex> guard(p.lock); p.ended = true;
if (p.videoBase < 0) p.audios.clear();
break;
}
if (record.pts > INT64_MAX) { fail(text("Invalid stream timestamp")); break; }
if (record.kind == StreamRecordKind::Audio) {
if (!p.audioAvailable) continue;

6
tools/chatgui/tests/test_stream_view.cpp

@ -196,7 +196,11 @@ private slots:
pcm[2 * i + 1] = static_cast<int16_t>(1500 * std::sin((sampleFrame + i) * 0.13));
}
sampleFrame += 960;
int length = opus_codec_encode(opus.get(), pcm, 960, encoded, sizeof(encoded)); QVERIFY(length > 0);
int length = opus_codec_encode(opus.get(), pcm, 960, encoded, sizeof(encoded));
if (length <= 0) {
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "desktop startup fixture Opus encode failed result=%d", length);
return QList<QByteArray>{};
}
packets.append(QByteArray(reinterpret_cast<const char*>(encoded), length));
}
return packets;

Loading…
Cancel
Save