From: Sebastian Dröge Date: Mon, 23 Mar 2015 12:11:42 +0000 (+0100) Subject: opusenc: Remove useless headers and header_sent variables from the instance struct X-Git-Tag: 1.19.3~507^2~9072 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=42b5cc8938d04f5baeebb7920e91c7508e1a6fda;p=platform%2Fupstream%2Fgstreamer.git opusenc: Remove useless headers and header_sent variables from the instance struct They are only used inside a single function. --- diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index cb3f276f4c..d31962ea68 100644 --- a/ext/opus/gstopusenc.c +++ b/ext/opus/gstopusenc.c @@ -388,7 +388,6 @@ gst_opus_enc_start (GstAudioEncoder * benc) GST_DEBUG_OBJECT (enc, "start"); enc->tags = gst_tag_list_new_empty (); - enc->header_sent = FALSE; enc->encoded_samples = 0; return TRUE; @@ -400,16 +399,12 @@ gst_opus_enc_stop (GstAudioEncoder * benc) GstOpusEnc *enc = GST_OPUS_ENC (benc); GST_DEBUG_OBJECT (enc, "stop"); - enc->header_sent = FALSE; if (enc->state) { opus_multistream_encoder_destroy (enc->state); enc->state = NULL; } gst_tag_list_unref (enc->tags); enc->tags = NULL; - g_slist_foreach (enc->headers, (GFunc) gst_buffer_unref, NULL); - g_slist_free (enc->headers); - enc->headers = NULL; gst_tag_setter_reset_tags (GST_TAG_SETTER (enc)); return TRUE; @@ -971,26 +966,19 @@ gst_opus_enc_handle_frame (GstAudioEncoder * benc, GstBuffer * buf) enc = GST_OPUS_ENC (benc); GST_DEBUG_OBJECT (enc, "handle_frame"); - if (!enc->header_sent) { + if (!gst_pad_has_current_caps (GST_AUDIO_ENCODER_SRC_PAD (benc))) { GstCaps *caps; - g_slist_foreach (enc->headers, (GFunc) gst_buffer_unref, NULL); - g_slist_free (enc->headers); - enc->headers = NULL; - - gst_opus_header_create_caps (&caps, &enc->headers, enc->n_channels, + gst_opus_header_create_caps (&caps, NULL, enc->n_channels, enc->n_stereo_streams, enc->sample_rate, enc->channel_mapping_family, enc->decoding_channel_mapping, gst_tag_setter_get_tag_list (GST_TAG_SETTER (enc))); - /* negotiate with these caps */ GST_DEBUG_OBJECT (enc, "here are the caps: %" GST_PTR_FORMAT, caps); gst_audio_encoder_set_output_format (benc, caps); gst_caps_unref (caps); - - enc->header_sent = TRUE; } GST_DEBUG_OBJECT (enc, "received buffer %p of %" G_GSIZE_FORMAT " bytes", buf, diff --git a/ext/opus/gstopusenc.h b/ext/opus/gstopusenc.h index 4ff9610d6b..80ac328605 100644 --- a/ext/opus/gstopusenc.h +++ b/ext/opus/gstopusenc.h @@ -79,11 +79,8 @@ struct _GstOpusEnc { gint n_channels; gint sample_rate; - gboolean header_sent; guint64 encoded_samples; - GSList *headers; - GstTagList *tags; guint8 channel_mapping_family; diff --git a/ext/opus/gstopusheader.c b/ext/opus/gstopusheader.c index 53969602b4..6155ac0696 100644 --- a/ext/opus/gstopusheader.c +++ b/ext/opus/gstopusheader.c @@ -163,7 +163,7 @@ gst_opus_header_create_caps_from_headers (GstCaps ** caps, GSList ** headers, guint8 *data; g_return_if_fail (caps); - g_return_if_fail (headers && !*headers); + g_return_if_fail (!headers || !*headers); g_return_if_fail (gst_buffer_get_size (buf1) >= 19); gst_buffer_map (buf1, &map, GST_MAP_READ); @@ -199,8 +199,10 @@ gst_opus_header_create_caps_from_headers (GstCaps ** caps, GSList ** headers, "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL); *caps = _gst_caps_set_buffer_array (*caps, "streamheader", buf1, buf2, NULL); - *headers = g_slist_prepend (*headers, gst_buffer_ref (buf2)); - *headers = g_slist_prepend (*headers, gst_buffer_ref (buf1)); + if (headers) { + *headers = g_slist_prepend (*headers, gst_buffer_ref (buf2)); + *headers = g_slist_prepend (*headers, gst_buffer_ref (buf1)); + } } void @@ -211,7 +213,7 @@ gst_opus_header_create_caps (GstCaps ** caps, GSList ** headers, gint nchannels, GstBuffer *buf1, *buf2; g_return_if_fail (caps); - g_return_if_fail (headers && !*headers); + g_return_if_fail (!headers || !*headers); g_return_if_fail (nchannels > 0); g_return_if_fail (sample_rate >= 0); /* 0 -> unset */ g_return_if_fail (channel_mapping_family == 0 || channel_mapping);