gboolean force);
static void gst_ffmpegauddec_drain (GstFFMpegAudDec * ffmpegdec);
+static GstFlowReturn
+gst_ffmpegauddec_push_output_buffer (GstFFMpegAudDec * ffmpegdec);
#define GST_FFDEC_PARAMS_QDATA g_quark_from_static_string("avdec-params")
ffmpegdec->context = avcodec_alloc_context3 (klass->in_plugin);
ffmpegdec->opened = FALSE;
+ ffmpegdec->adapter = gst_adapter_new ();
+
gst_audio_decoder_set_drainable (GST_AUDIO_DECODER (ffmpegdec), TRUE);
gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (ffmpegdec), TRUE);
}
av_free (ffmpegdec->context);
ffmpegdec->context = NULL;
+ gst_object_unref (ffmpegdec->adapter);
+ ffmpegdec->adapter = NULL;
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
GST_LOG_OBJECT (ffmpegdec, "closing libav codec");
gst_caps_replace (&ffmpegdec->last_caps, NULL);
+ gst_adapter_clear (ffmpegdec->adapter);
if (ffmpegdec->opened)
gst_ffmpeg_avcodec_close (ffmpegdec->context);
}
if (outbuf) {
- GST_LOG_OBJECT (ffmpegdec, "Decoded data, now pushing buffer %p", outbuf);
+ GST_LOG_OBJECT (ffmpegdec, "Decoded data, now storing buffer %p", outbuf);
- *ret =
- gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), outbuf,
- 1);
+ gst_adapter_push (ffmpegdec->adapter, outbuf);
} else {
GST_DEBUG_OBJECT (ffmpegdec, "We didn't get a decoded buffer");
}
break;
} while (try++ < 10);
}
+ gst_ffmpegauddec_push_output_buffer (ffmpegdec);
}
static void
gst_buffer_unmap (inbuf, &map);
gst_buffer_unref (inbuf);
+ gst_ffmpegauddec_push_output_buffer (ffmpegdec);
+
if (bsize > 0) {
GST_DEBUG_OBJECT (ffmpegdec, "Dropping %d bytes of data", bsize);
}
}
}
+static GstFlowReturn
+gst_ffmpegauddec_push_output_buffer (GstFFMpegAudDec * ffmpegdec)
+{
+ GstBuffer *outbuf;
+ GstFlowReturn ret = GST_FLOW_OK;
+
+ if (gst_adapter_available (ffmpegdec->adapter) > 0) {
+ outbuf = gst_adapter_take_buffer (ffmpegdec->adapter,
+ gst_adapter_available (ffmpegdec->adapter));
+ ret = gst_audio_decoder_finish_frame (GST_AUDIO_DECODER (ffmpegdec), outbuf,
+ 1);
+ }
+ return ret;
+}
+
gboolean
gst_ffmpegauddec_register (GstPlugin * plugin)
{