From 4f1ddeddbae60f12e652c96fc0cb65402c056fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 22 Mar 2007 00:17:41 +0000 Subject: ext/wavpack/gstwavpackenc.*: Put the write helpers into the GstWavpackEnc struct directly and not as a pointer to sav... Original commit message from CVS: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block): * ext/wavpack/gstwavpackenc.h: Put the write helpers into the GstWavpackEnc struct directly and not as a pointer to save two small, but useless mallocs. This also makes it possible to drop the finalize method. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_push_buffer): For consistency reasons also set GST_BUFFER_OFFSET_END on the outgoing buffers the same way wavpackenc does it. --- ext/wavpack/gstwavpackenc.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'ext/wavpack/gstwavpackenc.c') diff --git a/ext/wavpack/gstwavpackenc.c b/ext/wavpack/gstwavpackenc.c index 8992d0c1..fbeb2c7f 100644 --- a/ext/wavpack/gstwavpackenc.c +++ b/ext/wavpack/gstwavpackenc.c @@ -83,7 +83,6 @@ static int gst_wavpack_enc_push_block (void *id, void *data, int32_t count); static gboolean gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event); static GstStateChangeReturn gst_wavpack_enc_change_state (GstElement * element, GstStateChange transition); -static void gst_wavpack_enc_finalize (GObject * object); static void gst_wavpack_enc_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_wavpack_enc_get_property (GObject * object, guint prop_id, @@ -274,7 +273,6 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass) /* set state change handler */ gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_wavpack_enc_change_state); - gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_wavpack_enc_finalize); /* set property handlers */ gobject_class->set_property = @@ -372,12 +370,10 @@ gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass) enc->md5_context = NULL; gst_wavpack_enc_reset (enc); - enc->wv_id = g_new0 (GstWavpackEncWriteID, 1); - enc->wv_id->correction = FALSE; - enc->wv_id->wavpack_enc = enc; - enc->wvc_id = g_new0 (GstWavpackEncWriteID, 1); - enc->wvc_id->correction = TRUE; - enc->wvc_id->wavpack_enc = enc; + enc->wv_id.correction = FALSE; + enc->wv_id.wavpack_enc = enc; + enc->wvc_id.correction = TRUE; + enc->wvc_id.wavpack_enc = enc; /* set default values of params */ enc->mode = GST_WAVPACK_ENC_MODE_DEFAULT; @@ -388,18 +384,6 @@ gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass) enc->joint_stereo_mode = GST_WAVPACK_JS_MODE_AUTO; } -static void -gst_wavpack_enc_finalize (GObject * object) -{ - GstWavpackEnc *enc = GST_WAVPACK_ENC (object); - - /* free the blockout helpers */ - g_free (enc->wv_id); - g_free (enc->wvc_id); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - static gboolean gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps) { @@ -694,8 +678,8 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf) if (!enc->wp_context) { /* create raw context */ enc->wp_context = - WavpackOpenFileOutput (gst_wavpack_enc_push_block, enc->wv_id, - (enc->correction_mode > 0) ? enc->wvc_id : NULL); + WavpackOpenFileOutput (gst_wavpack_enc_push_block, &enc->wv_id, + (enc->correction_mode > 0) ? &enc->wvc_id : NULL); if (!enc->wp_context) { GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL), ("error creating Wavpack context")); @@ -784,7 +768,7 @@ gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * enc) if (ret) { /* try to rewrite the first block */ GST_DEBUG_OBJECT (enc, "rewriting first block ..."); - ret = gst_wavpack_enc_push_block (enc->wv_id, + ret = gst_wavpack_enc_push_block (&enc->wv_id, enc->first_block, enc->first_block_size); } else { GST_WARNING_OBJECT (enc, "rewriting of first block failed. " -- cgit v1.2.1