From 739473f36717ecc5c1295f9afcb7aaa1d0d44f75 Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Fri, 15 Mar 2024 11:39:34 -0700 Subject: [PATCH 1/3] Formattting --- lib/tlTimeline/Player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tlTimeline/Player.h b/lib/tlTimeline/Player.h index 9944ae31..3695dc3a 100644 --- a/lib/tlTimeline/Player.h +++ b/lib/tlTimeline/Player.h @@ -98,7 +98,7 @@ namespace tl static std::shared_ptr create( const std::shared_ptr&, const std::shared_ptr&, - const PlayerOptions & = PlayerOptions()); + const PlayerOptions& = PlayerOptions()); //! Get the context. const std::weak_ptr& getContext() const; From d8ac60e0dfcc071114c821374a529ac266043279 Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Fri, 15 Mar 2024 13:27:42 -0700 Subject: [PATCH 2/3] Refactoring --- lib/tlTimeline/PlayerPrivate.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/tlTimeline/PlayerPrivate.cpp b/lib/tlTimeline/PlayerPrivate.cpp index dbd4b451..4bea2438 100644 --- a/lib/tlTimeline/PlayerPrivate.cpp +++ b/lib/tlTimeline/PlayerPrivate.cpp @@ -290,10 +290,11 @@ namespace tl if (j == thread.videoDataRequests.end()) { //std::cout << this << " video request: " << time << std::endl; - thread.videoDataRequests[time].clear(); + auto& request = thread.videoDataRequests[time]; + request.clear(); io::Options ioOptions2 = thread.ioOptions; ioOptions2["Layer"] = string::Format("{0}").arg(thread.videoLayer); - thread.videoDataRequests[time].push_back(timeline->getVideo(time, ioOptions2)); + request.push_back(timeline->getVideo(time, ioOptions2)); for (size_t i = 0; i < thread.compare.size(); ++i) { const otime::RationalTime time2 = timeline::getCompareTime( @@ -305,8 +306,7 @@ namespace tl arg(i < thread.compareVideoLayers.size() ? thread.compareVideoLayers[i] : thread.videoLayer); - thread.videoDataRequests[time].push_back( - thread.compare[i]->getVideo(time2, ioOptions2)); + request.push_back(thread.compare[i]->getVideo(time2, ioOptions2)); } } } @@ -327,10 +327,11 @@ namespace tl if (j == thread.videoDataRequests.end()) { //std::cout << this << " video request: " << time << std::endl; - thread.videoDataRequests[time].clear(); + auto& request = thread.videoDataRequests[time]; + request.clear(); io::Options ioOptions2 = thread.ioOptions; ioOptions2["Layer"] = string::Format("{0}").arg(thread.videoLayer); - thread.videoDataRequests[time].push_back(timeline->getVideo(time, ioOptions2)); + request.push_back(timeline->getVideo(time, ioOptions2)); for (size_t i = 0; i < thread.compare.size(); ++i) { const otime::RationalTime time2 = timeline::getCompareTime( @@ -342,8 +343,7 @@ namespace tl arg(i < thread.compareVideoLayers.size() ? thread.compareVideoLayers[i] : thread.videoLayer); - thread.videoDataRequests[time].push_back( - thread.compare[i]->getVideo(time2, ioOptions2)); + request.push_back(thread.compare[i]->getVideo(time2, ioOptions2)); } } } @@ -428,14 +428,15 @@ namespace tl if (ready) { const otime::RationalTime time = videoDataRequestsIt->first; - thread.videoDataCache[time].clear(); + auto& videoDataCache = thread.videoDataCache[time]; + videoDataCache.clear(); for (auto videoDataRequestIt = videoDataRequestsIt->second.begin(); videoDataRequestIt != videoDataRequestsIt->second.end(); ++videoDataRequestIt) { - auto data = videoDataRequestIt->future.get(); - data.time = time; - thread.videoDataCache[data.time].push_back(data); + auto videoData = videoDataRequestIt->future.get(); + videoData.time = time; + videoDataCache.push_back(videoData); } videoDataRequestsIt = thread.videoDataRequests.erase(videoDataRequestsIt); } From 1aefa94692ec94f14b4d19bd6492c78a7a3caff0 Mon Sep 17 00:00:00 2001 From: Darby Johnston Date: Sun, 17 Mar 2024 10:05:10 -0700 Subject: [PATCH 3/3] Compare fix --- lib/tlTimeline/Player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tlTimeline/Player.cpp b/lib/tlTimeline/Player.cpp index 3b52d482..88114bdc 100644 --- a/lib/tlTimeline/Player.cpp +++ b/lib/tlTimeline/Player.cpp @@ -198,6 +198,7 @@ namespace tl const auto t0 = std::chrono::steady_clock::now(); // Get mutex protected values. + std::vector > compare; bool clearRequests = false; bool clearCache = false; { @@ -205,7 +206,7 @@ namespace tl p.thread.playback = p.mutex.playback; p.thread.currentTime = p.mutex.currentTime; p.thread.inOutRange = p.mutex.inOutRange; - p.thread.compare = p.mutex.compare; + compare = p.mutex.compare; p.thread.compareTime = p.mutex.compareTime; p.thread.ioOptions = p.mutex.ioOptions; p.thread.videoLayer = p.mutex.videoLayer; @@ -224,6 +225,7 @@ namespace tl { p.clearRequests(); } + p.thread.compare = compare; // Clear the cache. if (clearCache)