libs: audio: drop use of GSlice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3695>
This commit is contained in:
Tim-Philipp Müller 2023-01-08 16:59:02 +00:00 committed by GStreamer Marge Bot
parent 11b47c4e29
commit 506c65aa27
8 changed files with 21 additions and 22 deletions

View file

@ -33,9 +33,9 @@ gst_audio_buffer_unmap_internal (GstAudioBuffer * buffer, guint n_unmap)
gst_buffer_unmap (buffer->buffer, &buffer->map_infos[i]); gst_buffer_unmap (buffer->buffer, &buffer->map_infos[i]);
} }
if (buffer->planes != buffer->priv_planes_arr) if (buffer->planes != buffer->priv_planes_arr)
g_slice_free1 (buffer->n_planes * sizeof (gpointer), buffer->planes); g_free (buffer->planes);
if (buffer->map_infos != buffer->priv_map_infos_arr) if (buffer->map_infos != buffer->priv_map_infos_arr)
g_slice_free1 (buffer->n_planes * sizeof (GstMapInfo), buffer->map_infos); g_free (buffer->map_infos);
} }
/** /**
@ -146,9 +146,8 @@ gst_audio_buffer_map (GstAudioBuffer * buffer, const GstAudioInfo * info,
buffer->n_planes = GST_AUDIO_BUFFER_CHANNELS (buffer); buffer->n_planes = GST_AUDIO_BUFFER_CHANNELS (buffer);
if (G_UNLIKELY (buffer->n_planes > 8)) { if (G_UNLIKELY (buffer->n_planes > 8)) {
buffer->planes = g_slice_alloc (buffer->n_planes * sizeof (gpointer)); buffer->planes = g_new (gpointer, buffer->n_planes);
buffer->map_infos = buffer->map_infos = g_new (GstMapInfo, buffer->n_planes);
g_slice_alloc (buffer->n_planes * sizeof (GstMapInfo));
} else { } else {
buffer->planes = buffer->priv_planes_arr; buffer->planes = buffer->priv_planes_arr;
buffer->map_infos = buffer->priv_map_infos_arr; buffer->map_infos = buffer->priv_map_infos_arr;

View file

@ -95,7 +95,7 @@ gst_audio_channel_mixer_free (GstAudioChannelMixer * mix)
g_free (mix->matrix_int); g_free (mix->matrix_int);
mix->matrix_int = NULL; mix->matrix_int = NULL;
g_slice_free (GstAudioChannelMixer, mix); g_free (mix);
} }
/* /*
@ -836,7 +836,7 @@ gst_audio_channel_mixer_new_with_matrix (GstAudioChannelMixerFlags flags,
g_return_val_if_fail (in_channels > 0 && in_channels < 64, NULL); g_return_val_if_fail (in_channels > 0 && in_channels < 64, NULL);
g_return_val_if_fail (out_channels > 0 && out_channels < 64, NULL); g_return_val_if_fail (out_channels > 0 && out_channels < 64, NULL);
mix = g_slice_new0 (GstAudioChannelMixer); mix = g_new0 (GstAudioChannelMixer, 1);
mix->in_channels = in_channels; mix->in_channels = in_channels;
mix->out_channels = out_channels; mix->out_channels = out_channels;

View file

@ -197,7 +197,7 @@ audio_chain_new (AudioChain * prev, GstAudioConverter * convert)
{ {
AudioChain *chain; AudioChain *chain;
chain = g_slice_new0 (AudioChain); chain = g_new0 (AudioChain, 1);
chain->prev = prev; chain->prev = prev;
if (convert->current_layout == GST_AUDIO_LAYOUT_NON_INTERLEAVED) { if (convert->current_layout == GST_AUDIO_LAYOUT_NON_INTERLEAVED) {
@ -229,7 +229,7 @@ audio_chain_free (AudioChain * chain)
if (chain->make_func_notify) if (chain->make_func_notify)
chain->make_func_notify (chain->make_func_data); chain->make_func_notify (chain->make_func_data);
g_free (chain->tmp); g_free (chain->tmp);
g_slice_free (AudioChain, chain); g_free (chain);
} }
static gpointer * static gpointer *
@ -1347,7 +1347,7 @@ gst_audio_converter_new (GstAudioConverterFlags flags, GstAudioInfo * in_info,
&& !opt_matrix) && !opt_matrix)
goto unpositioned; goto unpositioned;
convert = g_slice_new0 (GstAudioConverter); convert = g_new0 (GstAudioConverter, 1);
convert->flags = flags; convert->flags = flags;
convert->in = *in_info; convert->in = *in_info;
@ -1481,7 +1481,7 @@ gst_audio_converter_free (GstAudioConverter * convert)
gst_structure_free (convert->config); gst_structure_free (convert->config);
g_slice_free (GstAudioConverter, convert); g_free (convert);
} }
/** /**

View file

@ -61,7 +61,7 @@ ensure_debug_category (void)
GstAudioInfo * GstAudioInfo *
gst_audio_info_copy (const GstAudioInfo * info) gst_audio_info_copy (const GstAudioInfo * info)
{ {
return g_slice_dup (GstAudioInfo, info); return g_memdup2 (info, sizeof (GstAudioInfo));
} }
/** /**
@ -74,7 +74,7 @@ gst_audio_info_copy (const GstAudioInfo * info)
void void
gst_audio_info_free (GstAudioInfo * info) gst_audio_info_free (GstAudioInfo * info)
{ {
g_slice_free (GstAudioInfo, info); g_free (info);
} }
G_DEFINE_BOXED_TYPE (GstAudioInfo, gst_audio_info, G_DEFINE_BOXED_TYPE (GstAudioInfo, gst_audio_info,
@ -93,7 +93,7 @@ gst_audio_info_new (void)
{ {
GstAudioInfo *info; GstAudioInfo *info;
info = g_slice_new (GstAudioInfo); info = g_new (GstAudioInfo, 1);
gst_audio_info_init (info); gst_audio_info_init (info);
return info; return info;

View file

@ -446,7 +446,7 @@ gst_audio_quantize_new (GstAudioDitherMethod dither,
g_return_val_if_fail (format == GST_AUDIO_FORMAT_S32, NULL); g_return_val_if_fail (format == GST_AUDIO_FORMAT_S32, NULL);
g_return_val_if_fail (channels > 0, NULL); g_return_val_if_fail (channels > 0, NULL);
quant = g_slice_new0 (GstAudioQuantize); quant = g_new0 (GstAudioQuantize, 1);
quant->dither = dither; quant->dither = dither;
quant->ns = ns; quant->ns = ns;
quant->flags = flags; quant->flags = flags;
@ -490,7 +490,7 @@ gst_audio_quantize_free (GstAudioQuantize * quant)
g_free (quant->last_random); g_free (quant->last_random);
g_free (quant->dither_buf); g_free (quant->dither_buf);
g_slice_free (GstAudioQuantize, quant); g_free (quant);
} }
/** /**

View file

@ -1366,7 +1366,7 @@ gst_audio_resampler_new (GstAudioResamplerMethod method,
audio_resampler_init (); audio_resampler_init ();
resampler = g_slice_new0 (GstAudioResampler); resampler = g_new0 (GstAudioResampler, 1);
resampler->method = method; resampler->method = method;
resampler->flags = flags; resampler->flags = flags;
resampler->format = format; resampler->format = format;
@ -1634,7 +1634,7 @@ gst_audio_resampler_free (GstAudioResampler * resampler)
g_free (resampler->sbuf); g_free (resampler->sbuf);
if (resampler->options) if (resampler->options)
gst_structure_free (resampler->options); gst_structure_free (resampler->options);
g_slice_free (GstAudioResampler, resampler); g_free (resampler);
} }
/** /**

View file

@ -327,7 +327,7 @@ gst_audio_meta_free (GstMeta * meta, GstBuffer * buffer)
GstAudioMeta *ameta = (GstAudioMeta *) meta; GstAudioMeta *ameta = (GstAudioMeta *) meta;
if (ameta->offsets && ameta->offsets != ameta->priv_offsets_arr) if (ameta->offsets && ameta->offsets != ameta->priv_offsets_arr)
g_slice_free1 (ameta->info.channels * sizeof (gsize), ameta->offsets); g_free (ameta->offsets);
} }
static gboolean static gboolean
@ -413,7 +413,7 @@ gst_buffer_add_audio_meta (GstBuffer * buffer, const GstAudioInfo * info,
#endif #endif
if (G_UNLIKELY (info->channels > 8)) if (G_UNLIKELY (info->channels > 8))
meta->offsets = g_slice_alloc (info->channels * sizeof (gsize)); meta->offsets = g_new (gsize, info->channels);
else else
meta->offsets = meta->priv_offsets_arr; meta->offsets = meta->priv_offsets_arr;

View file

@ -633,7 +633,7 @@ gst_audio_ring_buffer_acquire (GstAudioRingBuffer * buf,
GST_INFO_OBJECT (buf, "Allocating an array for %d timestamps", GST_INFO_OBJECT (buf, "Allocating an array for %d timestamps",
spec->segtotal); spec->segtotal);
buf->timestamps = g_slice_alloc0 (sizeof (GstClockTime) * spec->segtotal); buf->timestamps = g_new0 (GstClockTime, spec->segtotal);
/* initialize array with invalid timestamps */ /* initialize array with invalid timestamps */
for (i = 0; i < spec->segtotal; i++) { for (i = 0; i < spec->segtotal; i++) {
buf->timestamps[i] = GST_CLOCK_TIME_NONE; buf->timestamps[i] = GST_CLOCK_TIME_NONE;
@ -727,7 +727,7 @@ gst_audio_ring_buffer_release (GstAudioRingBuffer * buf)
if (G_LIKELY (buf->timestamps)) { if (G_LIKELY (buf->timestamps)) {
GST_INFO_OBJECT (buf, "Freeing timestamp buffer, %d entries", GST_INFO_OBJECT (buf, "Freeing timestamp buffer, %d entries",
buf->spec.segtotal); buf->spec.segtotal);
g_slice_free1 (sizeof (GstClockTime) * buf->spec.segtotal, buf->timestamps); g_free (buf->timestamps);
buf->timestamps = NULL; buf->timestamps = NULL;
} }