Skip to content
  • Piotr Brzeziński's avatar
    queuearray: Add sorting and sorted pushing · 601e31fe
    Piotr Brzeziński authored and GStreamer Marge Bot's avatar GStreamer Marge Bot committed
    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().
    
    Part-of: <gstreamer/gstreamer!5112>
    601e31fe