Skip to content

Commit 2eb6a67

Browse files
ddennedyCopilot
andcommitted
Fix #1238 decklink playback gets choppy or stuck
regression in 7beee28 Co-authored-by: Copilot <copilot@github.com>
1 parent 8a65a39 commit 2eb6a67

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/modules/decklink/consumer_decklink.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* consumer_decklink.cpp -- output through Blackmagic Design DeckLink
3-
* Copyright (C) 2010-2025 Meltytech, LLC
3+
* Copyright (C) 2010-2026 Meltytech, LLC
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public
@@ -239,15 +239,21 @@ class DeckLinkConsumer : public IDeckLinkVideoOutputCallback, public IDeckLinkAu
239239
if (!m_running)
240240
return;
241241

242+
bool flushAudio = false;
243+
242244
pthread_mutex_lock(&m_aqueue_lock);
243245
// When playing rewind or fast forward then we need to keep one
244246
// frame in the queue to prevent playback stalling.
245247
int n = (m_currentSpeed == 0 || m_currentSpeed == 1) ? 0 : 1;
246248
while (mlt_deque_count(m_aqueue) > n)
247249
mlt_frame_close(mlt_frame(mlt_deque_pop_back(m_aqueue)));
248250
m_purge = true;
249-
m_deckLinkOutput->FlushBufferedAudioSamples();
251+
flushAudio = m_isAudio && m_deckLinkOutput;
250252
pthread_mutex_unlock(&m_aqueue_lock);
253+
254+
// The DeckLink SDK may re-enter RenderAudioSamples while flushing.
255+
if (flushAudio)
256+
m_deckLinkOutput->FlushBufferedAudioSamples();
251257
}
252258

253259
protected:

0 commit comments

Comments
 (0)