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) 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; diff --git a/lib/tlTimeline/PlayerPrivate.cpp b/lib/tlTimeline/PlayerPrivate.cpp index 79fde7b7..9f962e86 100644 --- a/lib/tlTimeline/PlayerPrivate.cpp +++ b/lib/tlTimeline/PlayerPrivate.cpp @@ -298,10 +298,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( @@ -313,8 +314,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)); } } } @@ -335,10 +335,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( @@ -350,8 +351,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)); } } } @@ -436,14 +436,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); }