mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
gstreamer: use g_sort_array() instead of deprecated g_qsort_with_data()
Fixes compiler warnings with the latest GLib versions. See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4127 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7384>
This commit is contained in:
parent
cb89358d74
commit
6031f9ece1
6 changed files with 37 additions and 7 deletions
|
@ -34,6 +34,26 @@ G_BEGIN_DECLS
|
||||||
#define g_memdup2(ptr,sz) ((G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL))
|
#define g_memdup2(ptr,sz) ((G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !GLIB_CHECK_VERSION(2, 81, 1)
|
||||||
|
#define g_sort_array(a,n,s,f,udata) gst_g_sort_array(a,n,s,f,udata)
|
||||||
|
|
||||||
|
// Don't need to maintain ABI compat here (n_elements), since we never pass
|
||||||
|
// the function as pointer but always call it directly ourselves.
|
||||||
|
static inline void
|
||||||
|
gst_g_sort_array (const void *array,
|
||||||
|
gssize n_elements,
|
||||||
|
size_t element_size,
|
||||||
|
GCompareDataFunc compare_func,
|
||||||
|
void *user_data)
|
||||||
|
{
|
||||||
|
if (n_elements >= 0 && n_elements <= G_MAXINT) {
|
||||||
|
g_qsort_with_data (array, n_elements, element_size, compare_func, user_data);
|
||||||
|
} else {
|
||||||
|
g_abort ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,6 +90,8 @@
|
||||||
extern HMODULE _priv_gst_dll_handle;
|
extern HMODULE _priv_gst_dll_handle;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "glib-compat-private.h"
|
||||||
|
|
||||||
#define GST_CAT_DEFAULT preset_debug
|
#define GST_CAT_DEFAULT preset_debug
|
||||||
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
|
||||||
|
|
||||||
|
@ -546,7 +548,7 @@ gst_preset_default_get_preset_names (GstPreset * preset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sort the array now */
|
/* sort the array now */
|
||||||
g_qsort_with_data (groups, num_groups, sizeof (gchar *),
|
g_sort_array (groups, num_groups, sizeof (gchar *),
|
||||||
(GCompareDataFunc) compare_strings, NULL);
|
(GCompareDataFunc) compare_strings, NULL);
|
||||||
|
|
||||||
return groups;
|
return groups;
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include "gstvecdeque.h"
|
#include "gstvecdeque.h"
|
||||||
|
|
||||||
|
#include "glib-compat-private.h"
|
||||||
|
|
||||||
#define gst_vec_deque_idx(a, i) \
|
#define gst_vec_deque_idx(a, i) \
|
||||||
((a)->array + (((a)->head + (i)) % (a)->size) * (a)->elt_size)
|
((a)->array + (((a)->head + (i)) % (a)->size) * (a)->elt_size)
|
||||||
|
|
||||||
|
@ -607,7 +609,7 @@ gst_vec_deque_sort (GstVecDeque * array, GCompareDataFunc compare_func,
|
||||||
if (array->length == 0)
|
if (array->length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* To be able to use g_qsort_with_data, we might need to rearrange:
|
/* To be able to use g_sort_array, we might need to rearrange:
|
||||||
* [0-----TAIL][HEAD-----SIZE] -> [HEAD-------TAIL] */
|
* [0-----TAIL][HEAD-----SIZE] -> [HEAD-------TAIL] */
|
||||||
if (array->head >= array->tail) {
|
if (array->head >= array->tail) {
|
||||||
gsize t1 = array->head;
|
gsize t1 = array->head;
|
||||||
|
@ -631,7 +633,7 @@ gst_vec_deque_sort (GstVecDeque * array, GCompareDataFunc compare_func,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array->struct_array) {
|
if (array->struct_array) {
|
||||||
g_qsort_with_data (array->array +
|
g_sort_array (array->array +
|
||||||
(array->head % array->size) * array->elt_size, array->length,
|
(array->head % array->size) * array->elt_size, array->length,
|
||||||
array->elt_size, compare_func, user_data);
|
array->elt_size, compare_func, user_data);
|
||||||
} else {
|
} else {
|
||||||
|
@ -639,7 +641,7 @@ gst_vec_deque_sort (GstVecDeque * array, GCompareDataFunc compare_func,
|
||||||
* to dereference our pointers before passing them for comparison.
|
* to dereference our pointers before passing them for comparison.
|
||||||
* This matches the behaviour of gst_vec_deque_find(). */
|
* This matches the behaviour of gst_vec_deque_find(). */
|
||||||
QueueSortData sort_data = { compare_func, user_data };
|
QueueSortData sort_data = { compare_func, user_data };
|
||||||
g_qsort_with_data (array->array +
|
g_sort_array (array->array +
|
||||||
(array->head % array->size) * array->elt_size, array->length,
|
(array->head % array->size) * array->elt_size, array->length,
|
||||||
array->elt_size, (GCompareDataFunc) compare_wrapper, &sort_data);
|
array->elt_size, (GCompareDataFunc) compare_wrapper, &sort_data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@
|
||||||
#include "gstnetclientclock.h"
|
#include "gstnetclientclock.h"
|
||||||
#include "gstnetutils.h"
|
#include "gstnetutils.h"
|
||||||
|
|
||||||
|
#include "gst/glib-compat-private.h"
|
||||||
|
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -427,7 +429,7 @@ gst_net_client_internal_clock_observe_times (GstNetClientInternalClock * self,
|
||||||
self->last_rtts_missing--;
|
self->last_rtts_missing--;
|
||||||
} else {
|
} else {
|
||||||
memcpy (&last_rtts, &self->last_rtts, sizeof (last_rtts));
|
memcpy (&last_rtts, &self->last_rtts, sizeof (last_rtts));
|
||||||
g_qsort_with_data (&last_rtts,
|
g_sort_array (&last_rtts,
|
||||||
MEDIAN_PRE_FILTERING_WINDOW, sizeof (GstClockTime),
|
MEDIAN_PRE_FILTERING_WINDOW, sizeof (GstClockTime),
|
||||||
(GCompareDataFunc) compare_clock_time, NULL);
|
(GCompareDataFunc) compare_clock_time, NULL);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,8 @@
|
||||||
|
|
||||||
#include <gst/base/base.h>
|
#include <gst/base/base.h>
|
||||||
|
|
||||||
|
#include "gst/glib-compat-private.h"
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
@ -1457,7 +1459,7 @@ update_mean_path_delay (PtpDomainData * domain, PtpPendingSync * sync)
|
||||||
} else {
|
} else {
|
||||||
memcpy (&last_path_delays, &domain->last_path_delays,
|
memcpy (&last_path_delays, &domain->last_path_delays,
|
||||||
sizeof (last_path_delays));
|
sizeof (last_path_delays));
|
||||||
g_qsort_with_data (&last_path_delays,
|
g_sort_array (&last_path_delays,
|
||||||
MEDIAN_PRE_FILTERING_WINDOW, sizeof (GstClockTime),
|
MEDIAN_PRE_FILTERING_WINDOW, sizeof (GstClockTime),
|
||||||
(GCompareDataFunc) compare_clock_time, NULL);
|
(GCompareDataFunc) compare_clock_time, NULL);
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,8 @@
|
||||||
#include <TargetConditionals.h>
|
#include <TargetConditionals.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "gst/glib-compat-private.h"
|
||||||
|
|
||||||
/* "R" : support color
|
/* "R" : support color
|
||||||
* "X" : do not clear the screen when leaving the pager
|
* "X" : do not clear the screen when leaving the pager
|
||||||
* "F" : skip the pager if content fit into the screen
|
* "F" : skip the pager if content fit into the screen
|
||||||
|
@ -429,7 +431,7 @@ print_object_properties_info (GObject * obj, GObjectClass * obj_class,
|
||||||
gboolean first_flag;
|
gboolean first_flag;
|
||||||
|
|
||||||
property_specs = g_object_class_list_properties (obj_class, &num_properties);
|
property_specs = g_object_class_list_properties (obj_class, &num_properties);
|
||||||
g_qsort_with_data (property_specs, num_properties, sizeof (gpointer),
|
g_sort_array (property_specs, num_properties, sizeof (gpointer),
|
||||||
(GCompareDataFunc) sort_gparamspecs, NULL);
|
(GCompareDataFunc) sort_gparamspecs, NULL);
|
||||||
|
|
||||||
n_print ("%s%s%s:\n", HEADING_COLOR, desc, RESET_COLOR);
|
n_print ("%s%s%s:\n", HEADING_COLOR, desc, RESET_COLOR);
|
||||||
|
|
Loading…
Reference in a new issue