From f7f0c55e5faf5fa3fb998050a7518795cfa4ccc3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Tue, 7 Aug 2012 17:24:33 +0200 Subject: [PATCH] audiodecoder: getter for allocator Sometimes the decoder would use the allocator for something else than just allocating output buffers, for example, querying different parameters. This patch expose a getter accessor for the negotiated memory allocator. --- gst-libs/gst/audio/gstaudiodecoder.c | 27 +++++++++++++++++++++++++++ gst-libs/gst/audio/gstaudiodecoder.h | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index 791004e..852f191 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -2921,3 +2921,30 @@ done: return buffer; } + +/** + * gst_audio_decoder_get_allocator: + * @dec: a #GstAudioDecoder + * @allocator: (out) (allow-none) (transfer full): the #GstAllocator + * used + * @params: (out) (allow-none) (transfer full): the + * #GstAllocatorParams of @allocator + * + * Lets #GstAudioDecoder sub-classes to know the memory @allocator + * used by the base class and its @params. + * + * Unref the @allocator after use it. + */ +void +gst_audio_decoder_get_allocator (GstAudioDecoder * dec, + GstAllocator ** allocator, GstAllocationParams * params) +{ + g_return_if_fail (GST_IS_AUDIO_DECODER (dec)); + + if (allocator) + *allocator = dec->priv->ctx.allocator ? + gst_object_ref (dec->priv->ctx.allocator) : NULL; + + if (params) + *params = dec->priv->ctx.params; +} diff --git a/gst-libs/gst/audio/gstaudiodecoder.h b/gst-libs/gst/audio/gstaudiodecoder.h index cbc2464..4132dbb 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.h +++ b/gst-libs/gst/audio/gstaudiodecoder.h @@ -344,6 +344,10 @@ void gst_audio_decoder_set_needs_format (GstAudioDecoder * dec, gboolean gst_audio_decoder_get_needs_format (GstAudioDecoder * dec); +void gst_audio_decoder_get_allocator (GstAudioDecoder * dec, + GstAllocator ** allocator, + GstAllocationParams * params); + void gst_audio_decoder_merge_tags (GstAudioDecoder * dec, const GstTagList * tags, GstTagMergeMode mode); -- 2.7.4