From: Steinar H. Gunderson Date: Sat, 2 Oct 2021 14:12:24 +0000 (+0200) Subject: Newer drivers can seemingly send completions out-of-order on shutdown, so adjust... X-Git-Tag: 2.1.0~8 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=a823a1f7d9f454913044ff8e0e17acbc73f86316 Newer drivers can seemingly send completions out-of-order on shutdown, so adjust asserts accordingly. --- diff --git a/nageru/decklink_output.cpp b/nageru/decklink_output.cpp index fc8de57..5cf3abf 100644 --- a/nageru/decklink_output.cpp +++ b/nageru/decklink_output.cpp @@ -501,8 +501,8 @@ HRESULT DeckLinkOutput::ScheduledFrameCompleted(/* in */ IDeckLinkVideoFrame *co { lock_guard lock(frame_queue_mutex); frame_freelist.push(unique_ptr(frame)); - assert(scheduled_frames.front() == frame); - scheduled_frames.pop_front(); + assert(scheduled_frames.count(frame)); + scheduled_frames.erase(frame); --metric_decklink_output_inflight_frames; } @@ -600,7 +600,7 @@ void DeckLinkOutput::present_thread_func() HRESULT res = output->ScheduleVideoFrame(frame.get(), pts, duration, TIMEBASE); lock_guard lock(frame_queue_mutex); if (res == S_OK) { - scheduled_frames.push_back(frame.release()); // Owned by the driver now. + scheduled_frames.insert(frame.release()); // Owned by the driver now. ++metric_decklink_output_inflight_frames; } else { fprintf(stderr, "Could not schedule video frame! (error=0x%08x)\n", res); diff --git a/nageru/decklink_output.h b/nageru/decklink_output.h index 8213f49..f008dc3 100644 --- a/nageru/decklink_output.h +++ b/nageru/decklink_output.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "DeckLinkAPI.h" @@ -38,6 +39,7 @@ class QSurface; class DeckLinkOutput : public IDeckLinkVideoOutputCallback { public: DeckLinkOutput(movit::ResourcePool *resource_pool, QSurface *surface, unsigned width, unsigned height, unsigned card_index); + ~DeckLinkOutput(); // The IDecklinkInput argument is to work around a bug // in the 11.7 and newer drivers against older SDKs, @@ -138,7 +140,7 @@ private: std::mutex frame_queue_mutex; std::queue> pending_video_frames; // Under . std::queue> frame_freelist; // Under . - std::deque scheduled_frames; // Owned by the driver, so no unique_ptr. Under . + std::unordered_set scheduled_frames; // Owned by the driver, so no unique_ptr. Under . std::condition_variable frame_queues_changed; bool playback_initiated = false, playback_started = false;