From 91a0d439d1fec89d483cd683aad3e1fa376a0b92 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= <sebastian@centricular.com>
Date: Sat, 16 Jan 2016 19:06:48 +0200
Subject: [PATCH] audioaggregator: Add vfunc that is called right before
 finishing an output buffer

Allows to do any final adjustments to the buffer before it's forwarded
downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=760733
---
 gst-libs/gst/audio/gstaudioaggregator.c | 6 ++++++
 gst-libs/gst/audio/gstaudioaggregator.h | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/gst-libs/gst/audio/gstaudioaggregator.c b/gst-libs/gst/audio/gstaudioaggregator.c
index 5d7e8d6..47c7406 100644
--- a/gst-libs/gst/audio/gstaudioaggregator.c
+++ b/gst-libs/gst/audio/gstaudioaggregator.c
@@ -1077,6 +1077,7 @@ gst_audio_aggregator_aggregate (GstAggregator * agg, gboolean timeout)
    */
   GstElement *element;
   GstAudioAggregator *aagg;
+  GstAudioAggregatorClass *klass;
   GList *iter;
   GstFlowReturn ret;
   GstBuffer *outbuf = NULL;
@@ -1090,6 +1091,7 @@ gst_audio_aggregator_aggregate (GstAggregator * agg, gboolean timeout)
 
   element = GST_ELEMENT (agg);
   aagg = GST_AUDIO_AGGREGATOR (agg);
+  klass = GST_AUDIO_AGGREGATOR_GET_CLASS (aagg);
 
   /* Sync pad properties to the stream time */
   gst_aggregator_iterate_sinkpads (agg,
@@ -1346,6 +1348,10 @@ gst_audio_aggregator_aggregate (GstAggregator * agg, gboolean timeout)
 
   GST_OBJECT_UNLOCK (agg);
 
+  if (klass->finish_output_buffer)
+    aagg->priv->current_buffer =
+        klass->finish_output_buffer (aagg, aagg->priv->current_buffer);
+
   /* send it out */
   GST_LOG_OBJECT (aagg,
       "pushing outbuf %p, timestamp %" GST_TIME_FORMAT " offset %"
diff --git a/gst-libs/gst/audio/gstaudioaggregator.h b/gst-libs/gst/audio/gstaudioaggregator.h
index 304bad2..1b3ae0b 100644
--- a/gst-libs/gst/audio/gstaudioaggregator.h
+++ b/gst-libs/gst/audio/gstaudioaggregator.h
@@ -147,6 +147,8 @@ struct _GstAudioAggregatorClass {
   gboolean (* aggregate_one_buffer) (GstAudioAggregator * aagg,
       GstAudioAggregatorPad * pad, GstBuffer * inbuf, guint in_offset,
       GstBuffer * outbuf, guint out_offset, guint num_frames);
+  GstBuffer * ( *finish_output_buffer) (GstAudioAggregator * aagg,
+      GstBuffer * outbuf);
 
   /*< private >*/
   gpointer          _gst_reserved[GST_PADDING];
-- 
2.7.0.rc3