examples: compositor: fix build with older GLib versions

Don't use g_hash_table_steal_extended() which was only
added in 2.58.

Fixes #801

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/772>
This commit is contained in:
Tim-Philipp Müller 2020-08-01 00:22:28 +01:00
parent 5ad727f9ee
commit 141062c4d6

View file

@ -35,8 +35,7 @@ check_aggregated_buffer (GstElement * agg, GstPad * pad,
gst_aggregator_peek_next_sample (GST_AGGREGATOR (agg), gst_aggregator_peek_next_sample (GST_AGGREGATOR (agg),
GST_AGGREGATOR_PAD (pad)); GST_AGGREGATOR_PAD (pad));
g_hash_table_steal_extended (consumed_buffers, pad, NULL, pad_consumed_buffers = g_hash_table_lookup (consumed_buffers, pad);
(gpointer *) & pad_consumed_buffers);
for (tmp = pad_consumed_buffers; tmp; tmp = tmp->next) { for (tmp = pad_consumed_buffers; tmp; tmp = tmp->next) {
GstBuffer *consumed_buffer = (GstBuffer *) tmp->data; GstBuffer *consumed_buffer = (GstBuffer *) tmp->data;
@ -56,6 +55,7 @@ check_aggregated_buffer (GstElement * agg, GstPad * pad,
} }
g_list_free_full (pad_consumed_buffers, (GDestroyNotify) gst_buffer_unref); g_list_free_full (pad_consumed_buffers, (GDestroyNotify) gst_buffer_unref);
g_hash_table_steal (consumed_buffers, pad);
return TRUE; return TRUE;
} }
@ -73,14 +73,18 @@ pad_buffer_consumed_cb (GstAggregatorPad * pad, GstBuffer * buffer,
GHashTable * consumed_buffers) GHashTable * consumed_buffers)
{ {
GList *pad_consumed_buffers; GList *pad_consumed_buffers;
gboolean was_empty;
g_hash_table_steal_extended (consumed_buffers, pad, NULL, pad_consumed_buffers = g_hash_table_lookup (consumed_buffers, pad);
(gpointer *) & pad_consumed_buffers);
was_empty = (pad_consumed_buffers == NULL);
pad_consumed_buffers = pad_consumed_buffers =
g_list_append (pad_consumed_buffers, gst_buffer_ref (buffer)); g_list_append (pad_consumed_buffers, gst_buffer_ref (buffer));
g_hash_table_insert (consumed_buffers, pad, pad_consumed_buffers); /* we know the list's head pointer doesn't change when items get appended */
if (was_empty)
g_hash_table_insert (consumed_buffers, pad, pad_consumed_buffers);
} }
static gboolean static gboolean