| 60 | } |
| 61 | |
| 62 | std::optional<FrameRequest> |
| 63 | FrameRequestQueue::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 | |
| 87 | void FrameRequestQueue::prune_stale_frame_requests() { |
| 88 |
no test coverage detected