Skip to content

Commit

Permalink
Merge pull request #3 from darbyjohnston/main
Browse files Browse the repository at this point in the history
Compare fixes
  • Loading branch information
ggarra13 authored Mar 18, 2024
2 parents 3627fbc + 1aefa94 commit 2a4a8cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
4 changes: 3 additions & 1 deletion lib/tlTimeline/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ namespace tl
const auto t0 = std::chrono::steady_clock::now();

// Get mutex protected values.
std::vector<std::shared_ptr<Timeline> > compare;
bool clearRequests = false;
bool clearCache = false;
{
std::unique_lock<std::mutex> lock(p.mutex.mutex);
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;
Expand All @@ -224,6 +225,7 @@ namespace tl
{
p.clearRequests();
}
p.thread.compare = compare;

// Clear the cache.
if (clearCache)
Expand Down
2 changes: 1 addition & 1 deletion lib/tlTimeline/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace tl
static std::shared_ptr<Player> create(
const std::shared_ptr<Timeline>&,
const std::shared_ptr<system::Context>&,
const PlayerOptions & = PlayerOptions());
const PlayerOptions& = PlayerOptions());

//! Get the context.
const std::weak_ptr<system::Context>& getContext() const;
Expand Down
25 changes: 13 additions & 12 deletions lib/tlTimeline/PlayerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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));
}
}
}
Expand All @@ -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(
Expand All @@ -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));
}
}
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 2a4a8cb

Please sign in to comment.