MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / GetSmallestFrame

Method GetSmallestFrame

src/CacheMemory.cpp:117–137  ·  view source on GitHub ↗

Get the smallest frame number (or NULL shared_ptr if no frame is found)

Source from the content-addressed store, hash-verified

115
116// Get the smallest frame number (or NULL shared_ptr if no frame is found)
117std::shared_ptr<Frame> CacheMemory::GetSmallestFrame()
118{
119 // Create a scoped lock, to protect the cache from multiple threads
120 const std::lock_guard<std::recursive_mutex> lock(*cacheMutex);
121
122 // Loop through frame numbers
123 std::deque<int64_t>::iterator itr;
124 int64_t smallest_frame = -1;
125 for(itr = frame_numbers.begin(); itr != frame_numbers.end(); ++itr)
126 {
127 if (*itr < smallest_frame || smallest_frame == -1)
128 smallest_frame = *itr;
129 }
130
131 // Return frame (if any)
132 if (smallest_frame != -1) {
133 return frames[smallest_frame];
134 } else {
135 return NULL;
136 }
137}
138
139// Gets the maximum bytes value
140int64_t CacheMemory::GetBytes()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected