Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvement to video caching thread, to recover from the separation o…
…f cache vs display frame #. Also found a mutex that was needed, to prevent crashing when the video thread calls timeline::GetFrame at certain times... colliding with another thread (and independent of OpenMP).
- Loading branch information
Showing
4 changed files
with
29 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -695,6 +695,7 @@ std::shared_ptr<Frame> Timeline::GetFrame(int64_t requested_frame) | |
|
||
// Check cache | ||
std::shared_ptr<Frame> frame; | ||
std::lock_guard<std::mutex> guard(get_frame_mutex); | ||
#pragma omp critical (T_GetFrame) | ||
frame = final_cache->GetFrame(requested_frame); | ||
if (frame) { | ||
|
@@ -724,6 +725,15 @@ std::shared_ptr<Frame> Timeline::GetFrame(int64_t requested_frame) | |
return frame; | ||
} | ||
|
||
// Check if previous frame was cached? (if not, assume we are seeking somewhere else on the Timeline, and need | ||
// to clear all cache (for continuity sake). For example, jumping back to a previous spot can cause issues with audio | ||
// data where the new jump location doesn't match up with the previously cached audio data. | ||
std::shared_ptr<Frame> previous_frame = final_cache->GetFrame(requested_frame - 1); | ||
if (!previous_frame) { | ||
// Seeking to new place on timeline (destroy cache) | ||
ClearAllCache(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
ferdnyc
Contributor
|
||
} | ||
|
||
// Minimum number of frames to process (for performance reasons) | ||
int minimum_frames = OPEN_MP_NUM_PROCESSORS; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jonoomph
I have to be honest, this strikes me as kind of scorched-earth. I understand the intent, but... well, for starters, won't this mean that the entire cache gets cleared every time you start playing from the BEGINNING of the reader?
GetFrame(0)
will never be in the cache, right?It seems to me that if merely skipping to a different point on the timeline requires invalidating the entire cache, then it's not really a cache at all, anymore. It's just a queue of immediately-pending frames — a readahead buffer. Right?
(Which, if that's all we need, then great! But that could be implemented much more simply using a
std::deque
of frame objects. A simple readahead buffer doesn't require a parent-child hierarchy of custom classes, incredible amounts of ancillary metadata and housekeeping code, and a monitoring and management logic spread across three languages in order to present a constantly-refreshing status display.)