diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-03-23 13:11:42 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-03-23 13:12:25 +0100 |
commit | 42b5cc8938d04f5baeebb7920e91c7508e1a6fda (patch) | |
tree | 250fedd5a2ba5b8e534c4173b30542844b753a99 /ext/opus | |
parent | 856bb027f993413494ed76ef9f282ead99812075 (diff) | |
download | gstreamer-plugins-bad-42b5cc8938d04f5baeebb7920e91c7508e1a6fda.tar.gz |
opusenc: Remove useless headers and header_sent variables from the instance struct
They are only used inside a single function.
Diffstat (limited to 'ext/opus')
-rw-r--r-- | ext/opus/gstopusenc.c | 16 | ||||
-rw-r--r-- | ext/opus/gstopusenc.h | 3 | ||||
-rw-r--r-- | ext/opus/gstopusheader.c | 10 |
3 files changed, 8 insertions, 21 deletions
diff --git a/ext/opus/gstopusenc.c b/ext/opus/gstopusenc.c index cb3f276f4..d31962ea6 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 4ff9610d6..80ac32860 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 53969602b..6155ac069 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); |