priv = dec->priv;
ctx = &dec->priv->ctx;
- ", duration %" GST_TIME_FORMAT, GST_BUFFER_SIZE (buf),
+ g_return_val_if_fail (ctx->info.bpf != 0, GST_FLOW_ERROR);
+
+ if (G_UNLIKELY (!buf)) {
+ g_assert_not_reached ();
+ return GST_FLOW_OK;
+ }
+
+ GST_LOG_OBJECT (dec, "clipping buffer of size %d with ts %" GST_TIME_FORMAT
- gst_buffer_set_caps (buf, GST_PAD_CAPS (dec->srcpad));
-
++ ", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
+
+ /* clip buffer */
+ buf = gst_audio_buffer_clip (buf, &dec->segment, ctx->info.rate,
+ ctx->info.bpf);
+ if (G_UNLIKELY (!buf)) {
+ GST_DEBUG_OBJECT (dec, "no data after clipping to segment");
+ goto exit;
+ }
+
+ /* decorate */
- dec->segment.last_stop =
+ if (G_UNLIKELY (priv->discont)) {
+ GST_LOG_OBJECT (dec, "marking discont");
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
+ priv->discont = FALSE;
+ }
+
+ /* track where we are */
+ if (G_LIKELY (GST_BUFFER_TIMESTAMP_IS_VALID (buf))) {
+ /* duration should always be valid for raw audio */
+ g_assert (GST_BUFFER_DURATION_IS_VALID (buf));
- ", duration %" GST_TIME_FORMAT, GST_BUFFER_SIZE (buf),
++ dec->segment.position =
+ GST_BUFFER_TIMESTAMP (buf) + GST_BUFFER_DURATION (buf);
+ }
+
+ if (klass->pre_push) {
+ /* last chance for subclass to do some dirty stuff */
+ ret = klass->pre_push (dec, &buf);
+ if (ret != GST_FLOW_OK || !buf) {
+ GST_DEBUG_OBJECT (dec, "subclass returned %s, buf %p",
+ gst_flow_get_name (ret), buf);
+ if (buf)
+ gst_buffer_unref (buf);
+ goto exit;
+ }
+ }
+
+ GST_LOG_OBJECT (dec, "pushing buffer of size %d with ts %" GST_TIME_FORMAT
++ ", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
+ GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
+
+ ret = gst_pad_push (dec->srcpad, buf);
+
+ exit:
+ return ret;
+ }
+
+ /* mini aggregator combining output buffers into fewer larger ones,
+ * if so allowed/configured */
+ static GstFlowReturn
+ gst_audio_decoder_output (GstAudioDecoder * dec, GstBuffer * buf)
+ {
+ GstAudioDecoderPrivate *priv;
+ GstFlowReturn ret = GST_FLOW_OK;
+ GstBuffer *inbuf = NULL;
+
+ priv = dec->priv;
+
if (G_UNLIKELY (priv->agg < 0))
gst_audio_decoder_setup (dec);
if (G_LIKELY (buf)) {
- g_return_val_if_fail (ctx->info.bpf != 0, GST_FLOW_ERROR);
-
- GST_LOG_OBJECT (dec,
- "output buffer of size %" G_GSIZE_FORMAT " with ts %" GST_TIME_FORMAT
+ GST_LOG_OBJECT (dec, "output buffer of size %d with ts %" GST_TIME_FORMAT
- ", duration %" GST_TIME_FORMAT, GST_BUFFER_SIZE (buf),
+ ", duration %" GST_TIME_FORMAT, gst_buffer_get_size (buf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
-
- /* clip buffer */
- buf = gst_audio_buffer_clip (buf, &dec->segment, ctx->info.rate,
- ctx->info.bpf);
- if (G_UNLIKELY (!buf)) {
- GST_DEBUG_OBJECT (dec, "no data after clipping to segment");
- } else {
- GST_LOG_OBJECT (dec,
- "buffer after segment clipping has size %" G_GSIZE_FORMAT " with ts %"
- GST_TIME_FORMAT ", duration %" GST_TIME_FORMAT,
- gst_buffer_get_size (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
- GST_TIME_ARGS (GST_BUFFER_DURATION (buf)));
- }
- } else {
- GST_DEBUG_OBJECT (dec, "no output buffer");
}
again: