Skip to content

queuearray: Add sorting and sorted pushing

Piotr Brzeziński requested to merge thewildtree/gstreamer:queuearray-sort into main

Adds gst_queue_array_sort for sorting and gst_queue_array_push_sorted{,struct} for pushing in a sorted order. All three functions accept a comparison GCompareDataFunc along with optional user_data to pass to it.

In gst_queue_array_sort a small workaround was needed to correctly sort non-struct arrays. Like what _find() already does, we need to dereference our pointers first, to make sure we can use the same comparison functions everywhere. This is done via a small wrapper around the provided comparison function. The array can also wrap around (tail ends up 'before' the head), in which case we have to reorder the array (similar to what do_expand() does) to then be able to use an existing sorting function, like g_qsort_with_data().

I am working on a refactor for vtdec to have a separate output thread, similar to what was done to vtenc in !4967 (merged), thus having sorted pushes in GstQueueArray will be handy.

Edited by Piotr Brzeziński

Merge request reports