Skip to content

Commit

Permalink
Added Unique Identifier to cache key
Browse files Browse the repository at this point in the history
- Renamed `CACHE` to `MANAGER_CACHE` to match the OpenFX Plugin.
  • Loading branch information
latenitefilms committed Jul 13, 2023
1 parent e0c0cc6 commit e1dce36
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Source/Frameworks/gyroflow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::sync::Mutex; // A mutual exclusion primitive usef
// each pixel format:
//---------------------------------------------------------
lazy_static! {
static ref CACHE: Mutex<LruCache<String, Arc<StabilizationManager>>> = Mutex::new(LruCache::new(std::num::NonZeroUsize::new(5).unwrap()));
static ref MANAGER_CACHE: Mutex<LruCache<String, Arc<StabilizationManager>>> = Mutex::new(LruCache::new(std::num::NonZeroUsize::new(5).unwrap()));
}

//---------------------------------------------------------
Expand Down Expand Up @@ -75,7 +75,7 @@ pub extern "C" fn processFrame(
let unique_identifier_pointer = unsafe { CStr::from_ptr(unique_identifier) };
let unique_identifier_string = unique_identifier_pointer.to_string_lossy();

log::info!("[Gyroflow Toolbox] stabilization_result: {:?}", unique_identifier_string);
//log::info!("[Gyroflow Toolbox] unique_identifier_string: {:?}", unique_identifier_string);

//---------------------------------------------------------
// Get Pixel Format:
Expand Down Expand Up @@ -106,8 +106,8 @@ pub extern "C" fn processFrame(
//---------------------------------------------------------
// Cache the manager:
//---------------------------------------------------------
let mut cache = CACHE.lock().unwrap();
let cache_key = format!("{path_string}{output_width}{output_height}{pixel_format_string}");
let mut cache = MANAGER_CACHE.lock().unwrap();
let cache_key = format!("{path_string}{output_width}{output_height}{pixel_format_string}{unique_identifier_string}");
let manager = if let Some(manager) = cache.get(&cache_key) {
//---------------------------------------------------------
// Already cached:
Expand Down

0 comments on commit e1dce36

Please sign in to comment.