diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c index b3f2ea568fb..bb3d9ec8be3 100644 --- a/gst-libs/gst/audio/gstaudioencoder.c +++ b/gst-libs/gst/audio/gstaudioencoder.c @@ -454,20 +454,13 @@ gst_audio_encoder_finalize (GObject * object) * @buffer: encoded data * @samples: number of samples (per channel) represented by encoded data * - * Collects encoded data and/or pushes encoded data downstream. - * Source pad caps must be set when this is called. Depending on the nature - * of the (framing of) the format, subclass can decide whether to push - * encoded data directly or to collect various "frames" in a single buffer. - * Note that the latter behaviour is recommended whenever the format is allowed, - * as it incurs no additional latency and avoids otherwise generating a - * a multitude of (small) output buffers. If not explicitly pushed, - * any available encoded data is pushed at the end of each processing cycle, - * i.e. which encodes as much data as available input data allows. + * Collects encoded data and pushes encoded data downstream. + * Source pad caps must be set when this is called. * * If @samples < 0, then best estimate is all samples provided to encoder * (subclass) so far. @buf may be NULL, in which case next number of @samples * are considered discarded, e.g. as a result of discontinuous transmission, - * and a discontinuity is marked (note that @buf == NULL => push == TRUE). + * and a discontinuity is marked. * * Returns: a #GstFlowReturn that should be escalated to caller (of caller) * @@ -494,6 +487,26 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf, GST_AUDIO_ENCODER_STREAM_LOCK (enc); + GST_LOG_OBJECT (enc, "accepting %d bytes encoded data as %d samples", + buf ? gst_buffer_get_size (buf) : -1, samples); + + /* mark subclass still alive and providing */ + if (G_LIKELY (buf)) + priv->got_data = TRUE; + + if (priv->pending_events) { + GList *pending_events, *l; + + pending_events = priv->pending_events; + priv->pending_events = NULL; + + GST_DEBUG_OBJECT (enc, "Pushing pending events"); + for (l = pending_events; l; l = l->next) + gst_pad_push_event (enc->srcpad, l->data); + g_list_free (pending_events); + } + + /* send after pending events, which likely includes newsegment event */ if (G_UNLIKELY (enc->priv->tags)) { GstTagList *tags; #if 0 @@ -510,29 +523,10 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf, gst_pb_utils_add_codec_description_to_tag_list (tags, GST_TAG_AUDIO_CODEC, caps); #endif - GST_DEBUG_OBJECT (enc, "sending tags %" GST_PTR_FORMAT, tags); gst_element_found_tags_for_pad (GST_ELEMENT (enc), enc->srcpad, tags); } - GST_LOG_OBJECT (enc, "accepting %d bytes encoded data as %d samples", - buf ? gst_buffer_get_size (buf) : -1, samples); - - /* mark subclass still alive and providing */ - priv->got_data = TRUE; - - if (priv->pending_events) { - GList *pending_events, *l; - - pending_events = priv->pending_events; - priv->pending_events = NULL; - - GST_DEBUG_OBJECT (enc, "Pushing pending events"); - for (l = priv->pending_events; l; l = l->next) - gst_pad_push_event (enc->srcpad, l->data); - g_list_free (pending_events); - } - /* remove corresponding samples from input */ if (samples < 0) samples = (enc->priv->offset / ctx->info.bpf); @@ -1287,10 +1281,10 @@ gst_audio_encoder_sink_eventfunc (GstAudioEncoder * enc, GstEvent * event) gst_tag_list_remove_tag (tags, GST_TAG_AUDIO_CODEC); event = gst_event_new_tag (tags); - GST_OBJECT_LOCK (enc); + GST_AUDIO_ENCODER_STREAM_LOCK (enc); enc->priv->pending_events = g_list_append (enc->priv->pending_events, event); - GST_OBJECT_UNLOCK (enc); + GST_AUDIO_ENCODER_STREAM_UNLOCK (enc); handled = TRUE; break; } diff --git a/gst/playback/gstplaybin2.c b/gst/playback/gstplaybin2.c index 5c599c6c102..8498a3ee8fa 100644 --- a/gst/playback/gstplaybin2.c +++ b/gst/playback/gstplaybin2.c @@ -2612,7 +2612,7 @@ pad_added_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group) G_CALLBACK (notify_tags_cb), ntdata, (GClosureNotify) g_free, (GConnectFlags) 0); g_object_set_data (G_OBJECT (sinkpad), "playbin.notify_tags_handler", - (gpointer) notify_tags_handler); + (gpointer) (guintptr) notify_tags_handler); /* store the pad in the array */ GST_DEBUG_OBJECT (playbin, "pad %p added to array", sinkpad); @@ -2714,7 +2714,7 @@ pad_removed_cb (GstElement * decodebin, GstPad * pad, GstSourceGroup * group) gulong notify_tags_handler; notify_tags_handler = - (gulong) g_object_get_data (G_OBJECT (peer), + (guintptr) g_object_get_data (G_OBJECT (peer), "playbin.notify_tags_handler"); if (notify_tags_handler != 0) g_signal_handler_disconnect (G_OBJECT (peer), notify_tags_handler);