MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/xstudio / pop_request

Method pop_request

src/media_reader/src/frame_request_queue.cpp:62–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::optional<FrameRequest>
63FrameRequestQueue::pop_request(
64 const std::map<utility::Uuid, int> &in_flight_frame_requests_per_playhead,
65 const size_t max_num_inflight_requests) {
66 std::optional<FrameRequest> rt = {};
67
68 for (auto p = queue_.begin(); p != queue_.end(); p++) {
69 auto q = in_flight_frame_requests_per_playhead.find((*p)->requesting_playhead_uuid_);
70 // logic here is as follows: if there are no in-flight requests for this playhead, we can pop the request.
71 // If there are in-flight requests but the number of in-flight requests is less than the max allowed,
72 // then we can pop the request if it is NOT for a containerised encoding. If we have multiple frame requests
73 // in-flight for containerised media (like mp4) the a-sync nature of the media reader workers and cache means
74 // the frames will ultimately be read out-of-order. This can kill performance for readers like mp4 which have
75 // motion encoding with I fra
76 if (q == in_flight_frame_requests_per_playhead.end() ||
77 ((*p)->requested_frame_ && !(*p)->requested_frame_->is_containerised_encoding() && size_t(q->second) < max_num_inflight_requests)
78 ) {
79 rt = *(*p);
80 queue_.erase(p);
81 break;
82 }
83 }
84 return rt;
85}
86
87void FrameRequestQueue::prune_stale_frame_requests() {
88

Callers 1

do_precacheMethod · 0.80

Calls 5

beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected