summaryrefslogtreecommitdiffstats
path: root/ext/wavpack
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-08-21 13:59:52 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-08-21 13:59:52 +0000
commit11fc25f7aff298fdb54ecebcfa182ab2193f3000 (patch)
tree20af9c3ec276ebb970634c719f71154af03dc262 /ext/wavpack
parentaea5c4eca3ba7612a7acfa47c26499911e10e2cf (diff)
downloadgst-plugins-bad-11fc25f7aff298fdb54ecebcfa182ab2193f3000.tar.gz
gst-plugins-bad-11fc25f7aff298fdb54ecebcfa182ab2193f3000.tar.bz2
gst-plugins-bad-11fc25f7aff298fdb54ecebcfa182ab2193f3000.zip
ext/wavpack/: More clean-ups: use shorter variable names to make code easier to read; prefix structures we define wit...
Original commit message from CVS: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_format_samples), (gst_wavpack_enc_push_block), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event), (gst_wavpack_enc_change_state), (gst_wavpack_enc_set_property), (gst_wavpack_enc_get_property): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_loop): More clean-ups: use shorter variable names to make code easier to read; prefix structures we define with 'Gst' to make it clearer where they come from.
Diffstat (limited to 'ext/wavpack')
-rw-r--r--ext/wavpack/gstwavpackenc.c405
-rw-r--r--ext/wavpack/gstwavpackenc.h10
-rw-r--r--ext/wavpack/gstwavpackparse.c155
3 files changed, 281 insertions, 289 deletions
diff --git a/ext/wavpack/gstwavpackenc.c b/ext/wavpack/gstwavpackenc.c
index 09ff3e7a..9eaf45c6 100644
--- a/ext/wavpack/gstwavpackenc.c
+++ b/ext/wavpack/gstwavpackenc.c
@@ -256,56 +256,55 @@ gst_wavpack_enc_class_init (GstWavpackEncClass * klass)
}
static void
-gst_wavpack_enc_init (GstWavpackEnc * wavpack_enc, GstWavpackEncClass * gclass)
+gst_wavpack_enc_init (GstWavpackEnc * enc, GstWavpackEncClass * gclass)
{
- wavpack_enc->sinkpad =
- gst_pad_new_from_static_template (&sink_factory, "sink");
- gst_pad_set_setcaps_function (wavpack_enc->sinkpad,
+ enc->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink");
+ gst_pad_set_setcaps_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_set_caps));
- gst_pad_set_chain_function (wavpack_enc->sinkpad,
+ gst_pad_set_chain_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_enc_chain));
- gst_pad_set_event_function (wavpack_enc->sinkpad,
+ gst_pad_set_event_function (enc->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_enc_sink_event));
- gst_element_add_pad (GST_ELEMENT (wavpack_enc), wavpack_enc->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (enc), enc->sinkpad);
/* setup src pad */
- wavpack_enc->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
- gst_element_add_pad (GST_ELEMENT (wavpack_enc), wavpack_enc->srcpad);
+ enc->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_element_add_pad (GST_ELEMENT (enc), enc->srcpad);
/* initialize object attributes */
- wavpack_enc->wp_config = NULL;
- wavpack_enc->wp_context = NULL;
- wavpack_enc->first_block = NULL;
- wavpack_enc->first_block_size = 0;
- wavpack_enc->md5_context = NULL;
- wavpack_enc->samplerate = 0;
- wavpack_enc->width = 0;
- wavpack_enc->channels = 0;
-
- wavpack_enc->wv_id = (write_id *) g_malloc0 (sizeof (write_id));
- wavpack_enc->wv_id->correction = FALSE;
- wavpack_enc->wv_id->wavpack_enc = wavpack_enc;
- wavpack_enc->wvc_id = (write_id *) g_malloc0 (sizeof (write_id));
- wavpack_enc->wvc_id->correction = TRUE;
- wavpack_enc->wvc_id->wavpack_enc = wavpack_enc;
+ enc->wp_config = NULL;
+ enc->wp_context = NULL;
+ enc->first_block = NULL;
+ enc->first_block_size = 0;
+ enc->md5_context = NULL;
+ enc->samplerate = 0;
+ enc->width = 0;
+ enc->channels = 0;
+
+ 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;
/* set default values of params */
- wavpack_enc->mode = 1;
- wavpack_enc->bitrate = 0.0;
- wavpack_enc->correction_mode = 0;
- wavpack_enc->md5 = FALSE;
- wavpack_enc->extra_processing = FALSE;
- wavpack_enc->joint_stereo_mode = 0;
+ enc->mode = 1;
+ enc->bitrate = 0.0;
+ enc->correction_mode = 0;
+ enc->md5 = FALSE;
+ enc->extra_processing = FALSE;
+ enc->joint_stereo_mode = 0;
}
static void
gst_wavpack_enc_finalize (GObject * object)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (object);
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (object);
/* free the blockout helpers */
- g_free (wavpack_enc->wv_id);
- g_free (wavpack_enc->wvc_id);
+ g_free (enc->wv_id);
+ g_free (enc->wvc_id);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -313,146 +312,144 @@ gst_wavpack_enc_finalize (GObject * object)
static gboolean
gst_wavpack_enc_sink_set_caps (GstPad * pad, GstCaps * caps)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
GstStructure *structure = gst_caps_get_structure (caps, 0);
int depth = 0;
/* check caps and put relevant parts into our object attributes */
- if ((!gst_structure_get_int (structure, "channels", &wavpack_enc->channels))
- || (!gst_structure_get_int (structure, "rate", &wavpack_enc->samplerate))
- || (!gst_structure_get_int (structure, "width", &wavpack_enc->width))
- || (!(gst_structure_get_int (structure, "depth", &depth))
- || depth != wavpack_enc->width)) {
- GST_ELEMENT_ERROR (wavpack_enc, LIBRARY, INIT, (NULL),
+ if (!gst_structure_get_int (structure, "channels", &enc->channels) ||
+ !gst_structure_get_int (structure, "rate", &enc->samplerate) ||
+ !gst_structure_get_int (structure, "width", &enc->width) ||
+ !(gst_structure_get_int (structure, "depth", &depth) ||
+ depth != enc->width)) {
+ GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL),
("got invalid caps: %", GST_PTR_FORMAT, caps));
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
return FALSE;
}
/* set fixed src pad caps now that we know what we will get */
caps = gst_caps_new_simple ("audio/x-wavpack",
- "channels", G_TYPE_INT, wavpack_enc->channels,
- "rate", G_TYPE_INT, wavpack_enc->samplerate,
- "width", G_TYPE_INT, wavpack_enc->width,
- "framed", G_TYPE_BOOLEAN, TRUE, NULL);
+ "channels", G_TYPE_INT, enc->channels,
+ "rate", G_TYPE_INT, enc->samplerate,
+ "width", G_TYPE_INT, enc->width, "framed", G_TYPE_BOOLEAN, TRUE, NULL);
- if (!gst_pad_set_caps (wavpack_enc->srcpad, caps)) {
- GST_ELEMENT_ERROR (wavpack_enc, LIBRARY, INIT, (NULL),
+ if (!gst_pad_set_caps (enc->srcpad, caps)) {
+ GST_ELEMENT_ERROR (enc, LIBRARY, INIT, (NULL),
("setting caps failed: %", GST_PTR_FORMAT, caps));
gst_caps_unref (caps);
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
return FALSE;
}
- gst_pad_use_fixed_caps (wavpack_enc->srcpad);
+ gst_pad_use_fixed_caps (enc->srcpad);
gst_caps_unref (caps);
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
return TRUE;
}
static void
-gst_wavpack_enc_set_wp_config (GstWavpackEnc * wavpack_enc)
+gst_wavpack_enc_set_wp_config (GstWavpackEnc * enc)
{
- wavpack_enc->wp_config = (WavpackConfig *) g_malloc0 (sizeof (WavpackConfig));
+ enc->wp_config = g_new0 (WavpackConfig, 1);
/* set general stream informations in the WavpackConfig */
- wavpack_enc->wp_config->bytes_per_sample = (wavpack_enc->width + 7) >> 3;
- wavpack_enc->wp_config->bits_per_sample = wavpack_enc->width;
- wavpack_enc->wp_config->num_channels = wavpack_enc->channels;
+ enc->wp_config->bytes_per_sample = (enc->width + 7) >> 3;
+ enc->wp_config->bits_per_sample = enc->width;
+ enc->wp_config->num_channels = enc->channels;
/* TODO: handle more than 2 channels correctly! */
- if (wavpack_enc->channels == 1) {
- wavpack_enc->wp_config->channel_mask = 0x4;
- } else if (wavpack_enc->channels == 2) {
- wavpack_enc->wp_config->channel_mask = 0x2 | 0x1;
+ if (enc->channels == 1) {
+ enc->wp_config->channel_mask = 0x4;
+ } else if (enc->channels == 2) {
+ enc->wp_config->channel_mask = 0x2 | 0x1;
}
- wavpack_enc->wp_config->sample_rate = wavpack_enc->samplerate;
+ enc->wp_config->sample_rate = enc->samplerate;
/*
* Set parameters in WavpackConfig
*/
/* Encoding mode */
- switch (wavpack_enc->mode) {
+ switch (enc->mode) {
case 0:
- wavpack_enc->wp_config->flags |= CONFIG_FAST_FLAG;
+ enc->wp_config->flags |= CONFIG_FAST_FLAG;
break;
case 1: /* default */
break;
case 2:
- wavpack_enc->wp_config->flags |= CONFIG_HIGH_FLAG;
+ enc->wp_config->flags |= CONFIG_HIGH_FLAG;
break;
}
/* Bitrate, enables lossy mode */
- if (wavpack_enc->bitrate >= 2.0) {
- wavpack_enc->wp_config->flags |= CONFIG_HYBRID_FLAG;
- if (wavpack_enc->bitrate >= 24000.0) {
- wavpack_enc->wp_config->bitrate = wavpack_enc->bitrate / 1000.0;
- wavpack_enc->wp_config->flags |= CONFIG_BITRATE_KBPS;
+ if (enc->bitrate >= 2.0) {
+ enc->wp_config->flags |= CONFIG_HYBRID_FLAG;
+ if (enc->bitrate >= 24000.0) {
+ enc->wp_config->bitrate = enc->bitrate / 1000.0;
+ enc->wp_config->flags |= CONFIG_BITRATE_KBPS;
} else {
- wavpack_enc->wp_config->bitrate = wavpack_enc->bitrate;
+ enc->wp_config->bitrate = enc->bitrate;
}
}
/* Correction Mode, only in lossy mode */
- if (wavpack_enc->wp_config->flags & CONFIG_HYBRID_FLAG) {
- if (wavpack_enc->correction_mode > 0) {
- wavpack_enc->wvcsrcpad =
+ if (enc->wp_config->flags & CONFIG_HYBRID_FLAG) {
+ if (enc->correction_mode > 0) {
+ enc->wvcsrcpad =
gst_pad_new_from_static_template (&wvcsrc_factory, "wvcsrc");
/* try to add correction src pad, don't set correction mode on failure */
GstCaps *caps = gst_caps_new_simple ("audio/x-wavpack-correction",
"framed", G_TYPE_BOOLEAN, TRUE, NULL);
- gst_element_no_more_pads (GST_ELEMENT (wavpack_enc));
+ gst_element_no_more_pads (GST_ELEMENT (enc));
- GST_DEBUG_OBJECT (wavpack_enc, "Adding correction pad with caps %"
+ GST_DEBUG_OBJECT (enc, "Adding correction pad with caps %"
GST_PTR_FORMAT, caps);
- if (!gst_pad_set_caps (wavpack_enc->wvcsrcpad, caps)) {
- wavpack_enc->correction_mode = 0;
- GST_WARNING_OBJECT (wavpack_enc, "setting correction caps failed");
+ if (!gst_pad_set_caps (enc->wvcsrcpad, caps)) {
+ enc->correction_mode = 0;
+ GST_WARNING_OBJECT (enc, "setting correction caps failed");
} else {
- gst_pad_use_fixed_caps (wavpack_enc->wvcsrcpad);
- gst_element_add_pad (GST_ELEMENT (wavpack_enc), wavpack_enc->wvcsrcpad);
- wavpack_enc->wp_config->flags |= CONFIG_CREATE_WVC;
- if (wavpack_enc->correction_mode == 2) {
- wavpack_enc->wp_config->flags |= CONFIG_OPTIMIZE_WVC;
+ gst_pad_use_fixed_caps (enc->wvcsrcpad);
+ gst_element_add_pad (GST_ELEMENT (enc), enc->wvcsrcpad);
+ enc->wp_config->flags |= CONFIG_CREATE_WVC;
+ if (enc->correction_mode == 2) {
+ enc->wp_config->flags |= CONFIG_OPTIMIZE_WVC;
}
}
gst_caps_unref (caps);
}
} else {
- if (wavpack_enc->correction_mode > 0) {
- wavpack_enc->correction_mode = 0;
- GST_WARNING_OBJECT (wavpack_enc, "setting correction mode only has "
+ if (enc->correction_mode > 0) {
+ enc->correction_mode = 0;
+ GST_WARNING_OBJECT (enc, "setting correction mode only has "
"any effect if a bitrate is provided.");
}
}
- gst_element_no_more_pads (GST_ELEMENT (wavpack_enc));
+ gst_element_no_more_pads (GST_ELEMENT (enc));
/* MD5, setup MD5 context */
- if ((wavpack_enc->md5) && !(wavpack_enc->md5_context)) {
- wavpack_enc->wp_config->flags |= CONFIG_MD5_CHECKSUM;
- wavpack_enc->md5_context = (MD5_CTX *) g_malloc0 (sizeof (MD5_CTX));
- MD5Init (wavpack_enc->md5_context);
+ if ((enc->md5) && !(enc->md5_context)) {
+ enc->wp_config->flags |= CONFIG_MD5_CHECKSUM;
+ enc->md5_context = g_new0 (MD5_CTX, 1);
+ MD5Init (enc->md5_context);
}
/* Extra encode processing */
- if (wavpack_enc->extra_processing) {
- wavpack_enc->wp_config->flags |= CONFIG_EXTRA_MODE;
+ if (enc->extra_processing) {
+ enc->wp_config->flags |= CONFIG_EXTRA_MODE;
}
/* Joint stereo mode */
- switch (wavpack_enc->joint_stereo_mode) {
+ switch (enc->joint_stereo_mode) {
case 0: /* default */
break;
case 1:
- wavpack_enc->wp_config->flags |= CONFIG_JOINT_OVERRIDE;
- wavpack_enc->wp_config->flags &= ~CONFIG_JOINT_STEREO;
+ enc->wp_config->flags |= CONFIG_JOINT_OVERRIDE;
+ enc->wp_config->flags &= ~CONFIG_JOINT_STEREO;
break;
case 2:
- wavpack_enc->wp_config->flags |=
- (CONFIG_JOINT_OVERRIDE | CONFIG_JOINT_STEREO);
+ enc->wp_config->flags |= (CONFIG_JOINT_OVERRIDE | CONFIG_JOINT_STEREO);
break;
}
}
@@ -461,7 +458,7 @@ static int32_t *
gst_wavpack_enc_format_samples (const uchar * src_data, uint32_t sample_count,
guint width)
{
- int32_t *data = (int32_t *) g_malloc0 (sizeof (int32_t) * sample_count);
+ int32_t *data = g_new0 (int32_t, sample_count);
/* put all samples into an int32_t*, no matter what
* width we have and convert them from little endian
@@ -500,23 +497,23 @@ gst_wavpack_enc_format_samples (const uchar * src_data, uint32_t sample_count,
static int
gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
{
- write_id *wid = (write_id *) id;
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (wid->wavpack_enc);
+ GstWavpackEncWriteID *wid = (GstWavpackEncWriteID *) id;
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (wid->wavpack_enc);
GstFlowReturn *flow;
GstBuffer *buffer;
GstPad *pad;
guchar *block = (guchar *) data;
- pad = (wid->correction) ? wavpack_enc->wvcsrcpad : wavpack_enc->srcpad;
+ pad = (wid->correction) ? enc->wvcsrcpad : enc->srcpad;
flow =
- (wid->correction) ? &wavpack_enc->wvcsrcpad_last_return : &wavpack_enc->
+ (wid->correction) ? &enc->wvcsrcpad_last_return : &enc->
srcpad_last_return;
*flow = gst_pad_alloc_buffer_and_set_caps (pad, GST_BUFFER_OFFSET_NONE,
count, GST_PAD_CAPS (pad), &buffer);
if (*flow != GST_FLOW_OK) {
- GST_WARNING_OBJECT (wavpack_enc, "flow on %s:%s = %s",
+ GST_WARNING_OBJECT (enc, "flow on %s:%s = %s",
GST_DEBUG_PAD_NAME (pad), gst_flow_get_name (*flow));
return FALSE;
}
@@ -527,7 +524,7 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
/* if it's a Wavpack block set buffer timestamp and duration, etc */
WavpackHeader wph;
- GST_LOG_OBJECT (wavpack_enc, "got %d bytes of encoded wavpack %sdata",
+ GST_LOG_OBJECT (enc, "got %d bytes of encoded wavpack %sdata",
count, (wid->correction) ? "correction " : "");
gst_wavpack_read_header (&wph, block);
@@ -539,10 +536,10 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
/* save header for later reference, so we can re-send it later on
* EOS with fixed up values for total sample count etc. */
- if (wavpack_enc->first_block == NULL && !wid->correction) {
- gst_pad_push_event (wavpack_enc->srcpad, event);
- wavpack_enc->first_block = g_memdup (block, count);
- wavpack_enc->first_block_size = count;
+ if (enc->first_block == NULL && !wid->correction) {
+ gst_pad_push_event (enc->srcpad, event);
+ enc->first_block = g_memdup (block, count);
+ enc->first_block_size = count;
}
}
@@ -550,15 +547,15 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
* the wavpack header */
GST_BUFFER_TIMESTAMP (buffer) =
gst_util_uint64_scale_int (GST_SECOND, wph.block_index,
- wavpack_enc->samplerate);
+ enc->samplerate);
GST_BUFFER_DURATION (buffer) =
gst_util_uint64_scale_int (GST_SECOND, wph.block_samples,
- wavpack_enc->samplerate);
+ enc->samplerate);
GST_BUFFER_OFFSET (buffer) = wph.block_index;
GST_BUFFER_OFFSET_END (buffer) = wph.block_index + wph.block_samples;
} else {
/* if it's something else set no timestamp and duration on the buffer */
- GST_DEBUG_OBJECT (wavpack_enc, "got %d bytes of unknown data", count);
+ GST_DEBUG_OBJECT (enc, "got %d bytes of unknown data", count);
GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE;
GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE;
@@ -568,7 +565,7 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
*flow = gst_pad_push (pad, buffer);
if (*flow != GST_FLOW_OK) {
- GST_WARNING_OBJECT (wavpack_enc, "flow on %s:%s = %s",
+ GST_WARNING_OBJECT (enc, "flow on %s:%s = %s",
GST_DEBUG_PAD_NAME (pad), gst_flow_get_name (*flow));
return FALSE;
}
@@ -579,46 +576,44 @@ gst_wavpack_enc_push_block (void *id, void *data, int32_t count)
static GstFlowReturn
gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
- uint32_t sample_count =
- GST_BUFFER_SIZE (buf) / ((wavpack_enc->width + 7) >> 3);
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
+ uint32_t sample_count = GST_BUFFER_SIZE (buf) / ((enc->width + 7) >> 3);
int32_t *data;
GstFlowReturn ret;
/* reset the last returns to GST_FLOW_OK. This is only set to something else
* while WavpackPackSamples() or more specific gst_wavpack_enc_push_block()
* so not valid anymore */
- wavpack_enc->srcpad_last_return = wavpack_enc->wvcsrcpad_last_return =
- GST_FLOW_OK;
+ enc->srcpad_last_return = enc->wvcsrcpad_last_return = GST_FLOW_OK;
GST_DEBUG ("got %u raw samples", sample_count);
/* check if we already have a valid WavpackContext, otherwise make one */
- if (!wavpack_enc->wp_context) {
+ if (!enc->wp_context) {
/* create raw context */
- wavpack_enc->wp_context =
- WavpackOpenFileOutput (gst_wavpack_enc_push_block, wavpack_enc->wv_id,
- (wavpack_enc->correction_mode > 0) ? wavpack_enc->wvc_id : NULL);
- if (!wavpack_enc->wp_context) {
- GST_ELEMENT_ERROR (wavpack_enc, LIBRARY, INIT, (NULL),
+ enc->wp_context =
+ 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"));
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
/* set the WavpackConfig according to our parameters */
- gst_wavpack_enc_set_wp_config (wavpack_enc);
+ gst_wavpack_enc_set_wp_config (enc);
/* set the configuration to the context now that we know everything
* and initialize the encoder */
- if (!WavpackSetConfiguration (wavpack_enc->wp_context,
- wavpack_enc->wp_config, (uint32_t) (-1))
- || !WavpackPackInit (wavpack_enc->wp_context)) {
- GST_ELEMENT_ERROR (wavpack_enc, LIBRARY, SETTINGS, (NULL),
+ if (!WavpackSetConfiguration (enc->wp_context,
+ enc->wp_config, (uint32_t) (-1))
+ || !WavpackPackInit (enc->wp_context)) {
+ GST_ELEMENT_ERROR (enc, LIBRARY, SETTINGS, (NULL),
("error setting up wavpack encoding context"));
- WavpackCloseFile (wavpack_enc->wp_context);
- gst_object_unref (wavpack_enc);
+ WavpackCloseFile (enc->wp_context);
+ gst_object_unref (enc);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
@@ -627,9 +622,8 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf)
/* if we want to append the MD5 sum to the stream update it here
* with the current raw samples */
- if (wavpack_enc->md5) {
- MD5Update (wavpack_enc->md5_context, GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ if (enc->md5) {
+ MD5Update (enc->md5_context, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
}
/* put all samples into an int32_t*, no matter what
@@ -637,62 +631,61 @@ gst_wavpack_enc_chain (GstPad * pad, GstBuffer * buf)
* to host byte order */
data =
gst_wavpack_enc_format_samples (GST_BUFFER_DATA (buf), sample_count,
- wavpack_enc->width);
+ enc->width);
gst_buffer_unref (buf);
/* encode and handle return values from encoding */
- if (WavpackPackSamples (wavpack_enc->wp_context, data,
- sample_count / wavpack_enc->channels)) {
+ if (WavpackPackSamples (enc->wp_context, data, sample_count / enc->channels)) {
GST_DEBUG ("encoding samples successful");
ret = GST_FLOW_OK;
} else {
- if ((wavpack_enc->srcpad_last_return == GST_FLOW_RESEND) ||
- (wavpack_enc->wvcsrcpad_last_return == GST_FLOW_RESEND)) {
+ if ((enc->srcpad_last_return == GST_FLOW_RESEND) ||
+ (enc->wvcsrcpad_last_return == GST_FLOW_RESEND)) {
ret = GST_FLOW_RESEND;
- } else if ((wavpack_enc->srcpad_last_return == GST_FLOW_OK) ||
- (wavpack_enc->wvcsrcpad_last_return == GST_FLOW_OK)) {
+ } else if ((enc->srcpad_last_return == GST_FLOW_OK) ||
+ (enc->wvcsrcpad_last_return == GST_FLOW_OK)) {
ret = GST_FLOW_OK;
- } else if ((wavpack_enc->srcpad_last_return == GST_FLOW_NOT_LINKED) &&
- (wavpack_enc->wvcsrcpad_last_return == GST_FLOW_NOT_LINKED)) {
+ } else if ((enc->srcpad_last_return == GST_FLOW_NOT_LINKED) &&
+ (enc->wvcsrcpad_last_return == GST_FLOW_NOT_LINKED)) {
ret = GST_FLOW_NOT_LINKED;
- } else if ((wavpack_enc->srcpad_last_return == GST_FLOW_WRONG_STATE) &&
- (wavpack_enc->wvcsrcpad_last_return == GST_FLOW_WRONG_STATE)) {
+ } else if ((enc->srcpad_last_return == GST_FLOW_WRONG_STATE) &&
+ (enc->wvcsrcpad_last_return == GST_FLOW_WRONG_STATE)) {
ret = GST_FLOW_WRONG_STATE;
} else {
- GST_ELEMENT_ERROR (wavpack_enc, LIBRARY, ENCODE, (NULL),
+ GST_ELEMENT_ERROR (enc, LIBRARY, ENCODE, (NULL),
("encoding samples failed"));
ret = GST_FLOW_ERROR;
}
}
g_free (data);
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
return ret;
}
static void
-gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * wavpack_enc)
+gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * enc)
{
GstEvent *event = gst_event_new_new_segment (TRUE, 1.0, GST_FORMAT_BYTES,
0, GST_BUFFER_OFFSET_NONE, 0);
gboolean ret;
- g_return_if_fail (wavpack_enc);
- g_return_if_fail (wavpack_enc->first_block);
+ g_return_if_fail (enc);
+ g_return_if_fail (enc->first_block);
/* update the sample count in the first block */
- WavpackUpdateNumSamples (wavpack_enc->wp_context, wavpack_enc->first_block);
+ WavpackUpdateNumSamples (enc->wp_context, enc->first_block);
/* try to seek to the beginning of the output */
- ret = gst_pad_push_event (wavpack_enc->srcpad, event);
+ ret = gst_pad_push_event (enc->srcpad, event);
if (ret) {
/* try to rewrite the first block */
- GST_DEBUG_OBJECT (wavpack_enc, "rewriting first block ...");
- ret = gst_wavpack_enc_push_block (wavpack_enc->wv_id,
- wavpack_enc->first_block, wavpack_enc->first_block_size);
+ GST_DEBUG_OBJECT (enc, "rewriting first block ...");
+ ret = gst_wavpack_enc_push_block (enc->wv_id,
+ enc->first_block, enc->first_block_size);
} else {
- GST_WARNING_OBJECT (wavpack_enc, "rewriting of first block failed. "
+ GST_WARNING_OBJECT (enc, "rewriting of first block failed. "
"Seeking to first block failed!");
}
}
@@ -700,7 +693,7 @@ gst_wavpack_enc_rewrite_first_block (GstWavpackEnc * wavpack_enc)
static gboolean
gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (gst_pad_get_parent (pad));
gboolean ret = TRUE;
GST_DEBUG ("Received %s event on sinkpad", GST_EVENT_TYPE_NAME (event));
@@ -708,31 +701,31 @@ gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:
/* Encode all remaining samples and flush them to the src pads */
- WavpackFlushSamples (wavpack_enc->wp_context);
+ WavpackFlushSamples (enc->wp_context);
/* write the MD5 sum if we have to write one */
- if ((wavpack_enc->md5) && (wavpack_enc->md5_context)) {
+ if ((enc->md5) && (enc->md5_context)) {
guchar md5_digest[16];
- MD5Final (md5_digest, wavpack_enc->md5_context);
- WavpackStoreMD5Sum (wavpack_enc->wp_context, md5_digest);
+ MD5Final (md5_digest, enc->md5_context);
+ WavpackStoreMD5Sum (enc->wp_context, md5_digest);
}
/* Try to rewrite the first frame with the correct sample number */
- if (wavpack_enc->first_block)
- gst_wavpack_enc_rewrite_first_block (wavpack_enc);
+ if (enc->first_block)
+ gst_wavpack_enc_rewrite_first_block (enc);
/* close the context if not already happened */
- if (wavpack_enc->wp_context) {
- WavpackCloseFile (wavpack_enc->wp_context);
- wavpack_enc->wp_context = NULL;
+ if (enc->wp_context) {
+ WavpackCloseFile (enc->wp_context);
+ enc->wp_context = NULL;
}
ret = gst_pad_event_default (pad, event);
break;
case GST_EVENT_NEWSEGMENT:
- if (wavpack_enc->wp_context) {
- GST_WARNING_OBJECT (wavpack_enc, "got NEWSEGMENT after encoding "
+ if (enc->wp_context) {
+ GST_WARNING_OBJECT (enc, "got NEWSEGMENT after encoding "
"already started");
}
/* drop NEWSEGMENT events, we create our own when pushing
@@ -745,7 +738,7 @@ gst_wavpack_enc_sink_event (GstPad * pad, GstEvent * event)
break;
}
- gst_object_unref (wavpack_enc);
+ gst_object_unref (enc);
return ret;
}
@@ -753,15 +746,14 @@ static GstStateChangeReturn
gst_wavpack_enc_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (element);
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
/* set the last returned GstFlowReturns of the two pads to GST_FLOW_OK
* as they're only set to something else in WavpackPackSamples() or more
* specific gst_wavpack_enc_push_block() and nothing happened there yet */
- wavpack_enc->srcpad_last_return = wavpack_enc->wvcsrcpad_last_return =
- GST_FLOW_OK;
+ enc->srcpad_last_return = enc->wvcsrcpad_last_return = GST_FLOW_OK;
case GST_STATE_CHANGE_READY_TO_PAUSED:
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
default:
@@ -775,29 +767,28 @@ gst_wavpack_enc_change_state (GstElement * element, GstStateChange transition)
break;
case GST_STATE_CHANGE_PAUSED_TO_READY:
/* close and free everything stream related */
- if (wavpack_enc->wp_context) {
- WavpackCloseFile (wavpack_enc->wp_context);
- wavpack_enc->wp_context = NULL;
+ if (enc->wp_context) {
+ WavpackCloseFile (enc->wp_context);
+ enc->wp_context = NULL;
}
- if (wavpack_enc->wp_config) {
- g_free (wavpack_enc->wp_config);
- wavpack_enc->wp_config = NULL;
+ if (enc->wp_config) {
+ g_free (enc->wp_config);
+ enc->wp_config = NULL;
}
- if (wavpack_enc->first_block) {
- g_free (wavpack_enc->first_block);
- wavpack_enc->first_block = NULL;
- wavpack_enc->first_block_size = 0;
+ if (enc->first_block) {
+ g_free (enc->first_block);
+ enc->first_block = NULL;
+ enc->first_block_size = 0;
}
- if (wavpack_enc->md5_context) {
- g_free (wavpack_enc->md5_context);
- wavpack_enc->md5_context = NULL;
+ if (enc->md5_context) {
+ g_free (enc->md5_context);
+ enc->md5_context = NULL;
}
/* reset the last returns to GST_FLOW_OK. This is only set to something else
* while WavpackPackSamples() or more specific gst_wavpack_enc_push_block()
* so not valid anymore */
- wavpack_enc->srcpad_last_return = wavpack_enc->wvcsrcpad_last_return =
- GST_FLOW_OK;
+ enc->srcpad_last_return = enc->wvcsrcpad_last_return = GST_FLOW_OK;
break;
case GST_STATE_CHANGE_READY_TO_NULL:
break;
@@ -812,19 +803,19 @@ static void
gst_wavpack_enc_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (object);
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (object);
switch (prop_id) {
case ARG_MODE:
- wavpack_enc->mode = g_value_get_enum (value);
+ enc->mode = g_value_get_enum (value);
break;
case ARG_BITRATE:{
gdouble val = g_value_get_double (value);
if ((val >= 24000.0) && (val <= 9600000.0)) {
- wavpack_enc->bitrate = val;
+ enc->bitrate = val;
} else {
- wavpack_enc->bitrate = 0.0;
+ enc->bitrate = 0.0;
}
break;
}
@@ -832,23 +823,23 @@ gst_wavpack_enc_set_property (GObject * object, guint prop_id,
gdouble val = g_value_get_double (value);
if ((val >= 2.0) && (val <= 24.0)) {
- wavpack_enc->bitrate = val;
+ enc->bitrate = val;
} else {
- wavpack_enc->bitrate = 0.0;
+ enc->bitrate = 0.0;
}
break;
}
case ARG_CORRECTION_MODE:
- wavpack_enc->correction_mode = g_value_get_enum (value);
+ enc->correction_mode = g_value_get_enum (value);
break;
case ARG_MD5:
- wavpack_enc->md5 = g_value_get_boolean (value);
+ enc->md5 = g_value_get_boolean (value);
break;
case ARG_EXTRA_PROCESSING:
- wavpack_enc->extra_processing = g_value_get_boolean (value);
+ enc->extra_processing = g_value_get_boolean (value);
break;
case ARG_JOINT_STEREO_MODE:
- wavpack_enc->joint_stereo_mode = g_value_get_enum (value);
+ enc->joint_stereo_mode = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -860,37 +851,37 @@ static void
gst_wavpack_enc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
- GstWavpackEnc *wavpack_enc = GST_WAVPACK_ENC (object);
+ GstWavpackEnc *enc = GST_WAVPACK_ENC (object);
switch (prop_id) {
case ARG_MODE:
- g_value_set_enum (value, wavpack_enc->mode);
+ g_value_set_enum (value, enc->mode);
break;
case ARG_BITRATE:
- if (wavpack_enc->bitrate >= 24000.0) {
- g_value_set_double (value, wavpack_enc->bitrate);
+ if (enc->bitrate >= 24000.0) {
+ g_value_set_double (value, enc->bitrate);
} else {
g_value_set_double (value, 0.0);
}
break;
case ARG_BITSPERSAMPLE:
- if (wavpack_enc->bitrate <= 24.0) {
- g_value_set_double (value, wavpack_enc->bitrate);
+ if (enc->bitrate <= 24.0) {
+ g_value_set_double (value, enc->bitrate);
} else {
g_value_set_double (value, 0.0);
}
break;
case ARG_CORRECTION_MODE:
- g_value_set_enum (value, wavpack_enc->correction_mode);
+ g_value_set_enum (value, enc->correction_mode);
break;
case ARG_MD5:
- g_value_set_boolean (value, wavpack_enc->md5);
+ g_value_set_boolean (value, enc->md5);
break;
case ARG_EXTRA_PROCESSING:
- g_value_set_boolean (value, wavpack_enc->extra_processing);
+ g_value_set_boolean (value, enc->extra_processing);
break;
case ARG_JOINT_STEREO_MODE:
- g_value_set_enum (value, wavpack_enc->joint_stereo_mode);
+ g_value_set_enum (value, enc->joint_stereo_mode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
diff --git a/ext/wavpack/gstwavpackenc.h b/ext/wavpack/gstwavpackenc.h
index b7a9300e..2777007a 100644
--- a/ext/wavpack/gstwavpackenc.h
+++ b/ext/wavpack/gstwavpackenc.h
@@ -28,7 +28,8 @@
#include <wavpack/md5.h>
G_BEGIN_DECLS
-/* #define's don't like whitespacey bits */
+
+/* defines don't like whitespacey bits */
#define GST_TYPE_WAVPACK_ENC \
(gst_wavpack_enc_get_type())
#define GST_WAVPACK_ENC(obj) \
@@ -39,6 +40,7 @@ G_BEGIN_DECLS
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WAVPACK_ENC))
#define GST_IS_WAVPACK_ENC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAVPACK_ENC))
+
typedef struct _GstWavpackEnc GstWavpackEnc;
typedef struct _GstWavpackEncClass GstWavpackEncClass;
@@ -46,7 +48,7 @@ typedef struct
{
gboolean correction;
GstWavpackEnc *wavpack_enc;
-} write_id;
+} GstWavpackEncWriteID;
struct _GstWavpackEnc
@@ -66,7 +68,8 @@ struct _GstWavpackEnc
gint channels;
gint width;
- write_id *wv_id, *wvc_id;
+ GstWavpackEncWriteID *wv_id;
+ GstWavpackEncWriteID *wvc_id;
guint mode;
gdouble bitrate;
@@ -90,4 +93,5 @@ GType gst_wavpack_enc_get_type (void);
gboolean gst_wavpack_enc_plugin_init (GstPlugin * plugin);
G_END_DECLS
+
#endif /* __GST_WAVPACK_ENC_H__ */
diff --git a/ext/wavpack/gstwavpackparse.c b/ext/wavpack/gstwavpackparse.c
index 57d825f7..af46f7a7 100644
--- a/ext/wavpack/gstwavpackparse.c
+++ b/ext/wavpack/gstwavpackparse.c
@@ -64,7 +64,7 @@ gst_wavpack_parse_sink_activate_pull (GstPad * sinkpad, gboolean active);
static void gst_wavpack_parse_loop (GstElement * element);
static GstStateChangeReturn gst_wavpack_parse_change_state (GstElement *
element, GstStateChange transition);
-static void gst_wavpack_parse_reset (GstWavpackParse * wavpackparse);
+static void gst_wavpack_parse_reset (GstWavpackParse * parse);
static gint64 gst_wavpack_parse_get_upstream_length (GstWavpackParse * wvparse);
static GstBuffer *gst_wavpack_parse_pull_buffer (GstWavpackParse * wvparse,
gint64 offset, guint size, GstFlowReturn * flow);
@@ -187,44 +187,42 @@ gst_wavpack_parse_index_append_entry (GstWavpackParse * wvparse,
}
static void
-gst_wavpack_parse_reset (GstWavpackParse * wavpackparse)
+gst_wavpack_parse_reset (GstWavpackParse * parse)
{
- wavpackparse->total_samples = -1;
- wavpackparse->samplerate = 0;
- wavpackparse->channels = 0;
+ parse->total_samples = -1;
+ parse->samplerate = 0;
+ parse->channels = 0;
- gst_segment_init (&wavpackparse->segment, GST_FORMAT_UNDEFINED);
+ gst_segment_init (&parse->segment, GST_FORMAT_UNDEFINED);
- wavpackparse->current_offset = 0;
- wavpackparse->need_newsegment = TRUE;
- wavpackparse->upstream_length = -1;
+ parse->current_offset = 0;
+ parse->need_newsegment = TRUE;
+ parse->upstream_length = -1;
- if (wavpackparse->entries) {
- g_array_free (wavpackparse->entries, TRUE);
- wavpackparse->entries = NULL;
+ if (parse->entries) {
+ g_array_free (parse->entries, TRUE);
+ parse->entries = NULL;
}
- if (wavpackparse->adapter) {
- gst_adapter_clear (wavpackparse->adapter);
- g_object_unref (wavpackparse->adapter);
- wavpackparse->adapter = NULL;
+ if (parse->adapter) {
+ gst_adapter_clear (parse->adapter);
+ g_object_unref (parse->adapter);
+ parse->adapter = NULL;
}
- if (wavpackparse->srcpad != NULL) {
+ if (parse->srcpad != NULL) {
gboolean res;
- GST_DEBUG_OBJECT (wavpackparse, "Removing src pad");
- res = gst_element_remove_pad (GST_ELEMENT (wavpackparse),
- wavpackparse->srcpad);
+ GST_DEBUG_OBJECT (parse, "Removing src pad");
+ res = gst_element_remove_pad (GST_ELEMENT (parse), parse->srcpad);
g_return_if_fail (res != FALSE);
- gst_object_unref (wavpackparse->srcpad);
- wavpackparse->srcpad = NULL;
+ gst_object_unref (parse->srcpad);
+ parse->srcpad = NULL;
}
- g_list_foreach (wavpackparse->queued_events, (GFunc) gst_mini_object_unref,
- NULL);
- g_list_free (wavpackparse->queued_events);
- wavpackparse->queued_events = NULL;
+ g_list_foreach (parse->queued_events, (GFunc) gst_mini_object_unref, NULL);
+ g_list_free (parse->queued_events);
+ parse->queued_events = NULL;
}
static const GstQueryType *
@@ -243,7 +241,7 @@ gst_wavpack_parse_get_src_query_types (GstPad * pad)
static gboolean
gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
{
- GstWavpackParse *wavpackparse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
+ GstWavpackParse *parse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
GstFormat format;
gboolean ret = FALSE;
@@ -252,14 +250,14 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
gint64 cur, len;
guint rate;
- GST_OBJECT_LOCK (wavpackparse);
- cur = wavpackparse->segment.last_stop;
- len = wavpackparse->total_samples;
- rate = wavpackparse->samplerate;
- GST_OBJECT_UNLOCK (wavpackparse);
+ GST_OBJECT_LOCK (parse);
+ cur = parse->segment.last_stop;
+ len = parse->total_samples;
+ rate = parse->samplerate;
+ GST_OBJECT_UNLOCK (parse);
if (len <= 0 || rate == 0) {
- GST_DEBUG_OBJECT (wavpackparse, "haven't read header yet");
+ GST_DEBUG_OBJECT (parse, "haven't read header yet");
break;
}
@@ -276,7 +274,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
ret = TRUE;
break;
default:
- GST_DEBUG_OBJECT (wavpackparse, "cannot handle position query in "
+ GST_DEBUG_OBJECT (parse, "cannot handle position query in "
"%s format", gst_format_get_name (format));
break;
}
@@ -286,15 +284,15 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
gint64 len;
guint rate;
- GST_OBJECT_LOCK (wavpackparse);
- rate = wavpackparse->samplerate;
+ GST_OBJECT_LOCK (parse);
+ rate = parse->samplerate;
/* FIXME: return 0 if we work in push based mode to let totem
* recognize that we can't seek */
- len = (wavpackparse->adapter) ? 0 : wavpackparse->total_samples;
- GST_OBJECT_UNLOCK (wavpackparse);
+ len = (parse->adapter) ? 0 : parse->total_samples;
+ GST_OBJECT_UNLOCK (parse);
if (len < 0 || rate == 0) {
- GST_DEBUG_OBJECT (wavpackparse, "haven't read header yet");
+ GST_DEBUG_OBJECT (parse, "haven't read header yet");
break;
}
@@ -311,7 +309,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
ret = TRUE;
break;
default:
- GST_DEBUG_OBJECT (wavpackparse, "cannot handle duration query in "
+ GST_DEBUG_OBJECT (parse, "cannot handle duration query in "
"%s format", gst_format_get_name (format));
break;
}
@@ -326,9 +324,9 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
gst_pad_query_duration (pad, &format, &duration);
/* can't seek in streaming mode yet */
- GST_OBJECT_LOCK (wavpackparse);
- seekable = (wavpackparse->adapter != NULL);
- GST_OBJECT_UNLOCK (wavpackparse);
+ GST_OBJECT_LOCK (parse);
+ seekable = (parse->adapter != NULL);
+ GST_OBJECT_UNLOCK (parse);
gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, 0, duration);
ret = TRUE;
@@ -341,7 +339,7 @@ gst_wavpack_parse_src_query (GstPad * pad, GstQuery * query)
}
}
- gst_object_unref (wavpackparse);
+ gst_object_unref (parse);
return ret;
}
@@ -632,57 +630,56 @@ gst_wavpack_parse_sink_event (GstPad * pad, GstEvent * event)
static gboolean
gst_wavpack_parse_src_event (GstPad * pad, GstEvent * event)
{
- GstWavpackParse *wavpackparse;
+ GstWavpackParse *parse;
gboolean ret;
- wavpackparse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
+ parse = GST_WAVPACK_PARSE (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:
- ret = gst_wavpack_parse_handle_seek_event (wavpackparse, event);
+ ret = gst_wavpack_parse_handle_seek_event (parse, event);
break;
default:
ret = gst_pad_event_default (pad, event);
break;
}
- gst_object_unref (wavpackparse);
+ gst_object_unref (parse);
return ret;
}
static void
-gst_wavpack_parse_init (GstWavpackParse * wavpackparse,
- GstWavpackParseClass * gclass)
+gst_wavpack_parse_init (GstWavpackParse * parse, GstWavpackParseClass * gclass)
{
- GstElementClass *klass = GST_ELEMENT_GET_CLASS (wavpackparse);
+ GstElementClass *klass = GST_ELEMENT_GET_CLASS (parse);
GstPadTemplate *tmpl;
tmpl = gst_element_class_get_pad_template (klass, "sink");
- wavpackparse->sinkpad = gst_pad_new_from_template (tmpl, "sink");
+ parse->sinkpad = gst_pad_new_from_template (tmpl, "sink");
- gst_pad_set_activate_function (wavpackparse->sinkpad,
+ gst_pad_set_activate_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_activate));
- gst_pad_set_activatepull_function (wavpackparse->sinkpad,
+ gst_pad_set_activatepull_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_activate_pull));
- gst_pad_set_event_function (wavpackparse->sinkpad,
+ gst_pad_set_event_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_event));
- gst_pad_set_chain_function (wavpackparse->sinkpad,
+ gst_pad_set_chain_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_wavpack_parse_chain));
- gst_element_add_pad (GST_ELEMENT (wavpackparse), wavpackparse->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad);
- wavpackparse->srcpad = NULL;
- gst_wavpack_parse_reset (wavpackparse);
+ parse->srcpad = NULL;
+ gst_wavpack_parse_reset (parse);
}
static gint64
-gst_wavpack_parse_get_upstream_length (GstWavpackParse * wavpackparse)
+gst_wavpack_parse_get_upstream_length (GstWavpackParse * parse)
{
gint64 length = -1;
GstFormat format = GST_FORMAT_BYTES;
- if (!gst_pad_query_peer_duration (wavpackparse->sinkpad, &format, &length)) {
+ if (!gst_pad_query_peer_duration (parse->sinkpad, &format, &length)) {
length = -1;
} else {
GST_DEBUG ("upstream length: %" G_GINT64_FORMAT, length);
@@ -943,12 +940,12 @@ gst_wavpack_parse_resync_loop (GstWavpackParse * parse, WavpackHeader * header)
static void
gst_wavpack_parse_loop (GstElement * element)
{
- GstWavpackParse *wavpackparse = GST_WAVPACK_PARSE (element);
+ GstWavpackParse *parse = GST_WAVPACK_PARSE (element);
GstFlowReturn flow_ret;
WavpackHeader header = { {0,}, 0, };
GstBuffer *buf = NULL;
- flow_ret = gst_wavpack_parse_resync_loop (wavpackparse, &header);
+ flow_ret = gst_wavpack_parse_resync_loop (parse, &header);
if (flow_ret == GST_FLOW_UNEXPECTED) {
goto eos;
@@ -956,11 +953,11 @@ gst_wavpack_parse_loop (GstElement * element)
goto pause;
}
- GST_LOG_OBJECT (wavpackparse, "Read header at offset %" G_GINT64_FORMAT
- ": chunk size = %u+8", wavpackparse->current_offset, header.ckSize);
+ GST_LOG_OBJECT (parse, "Read header at offset %" G_GINT64_FORMAT
+ ": chunk size = %u+8", parse->current_offset, header.ckSize);
- buf = gst_wavpack_parse_pull_buffer (wavpackparse,
- wavpackparse->current_offset, header.ckSize + 8, &flow_ret);
+ buf = gst_wavpack_parse_pull_buffer (parse, parse->current_offset,
+ header.ckSize + 8, &flow_ret);
if (buf == NULL && flow_ret == GST_FLOW_UNEXPECTED) {
goto eos;
@@ -968,19 +965,19 @@ gst_wavpack_parse_loop (GstElement * element)
goto pause;
}
- if (wavpackparse->srcpad == NULL) {
- if (!gst_wavpack_parse_create_src_pad (wavpackparse, buf, &header)) {
- GST_ELEMENT_ERROR (wavpackparse, STREAM, DECODE, (NULL), (NULL));
+ if (parse->srcpad == NULL) {
+ if (!gst_wavpack_parse_create_src_pad (parse, buf, &header)) {
+ GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), (NULL));
goto pause;
}
}
- gst_wavpack_parse_index_append_entry (wavpackparse,
- wavpackparse->current_offset, header.block_index, header.block_samples);
+ gst_wavpack_parse_index_append_entry (parse, parse->current_offset,
+ header.block_index, header.block_samples);
- flow_ret = gst_wavpack_parse_push_buffer (wavpackparse, buf, &header);
+ flow_ret = gst_wavpack_parse_push_buffer (parse, buf, &header);
if (flow_ret != GST_FLOW_OK) {
- GST_DEBUG_OBJECT (wavpackparse, "Push failed, flow: %s",
+ GST_DEBUG_OBJECT (parse, "Push failed, flow: %s",
gst_flow_get_name (flow_ret));
goto pause;
}
@@ -989,16 +986,16 @@ gst_wavpack_parse_loop (GstElement * element)
eos:
{
- GST_DEBUG_OBJECT (wavpackparse, "sending EOS");
- if (wavpackparse->srcpad) {
- gst_pad_push_event (wavpackparse->srcpad, gst_event_new_eos ());
+ GST_DEBUG_OBJECT (parse, "sending EOS");
+ if (parse->srcpad) {
+ gst_pad_push_event (parse->srcpad, gst_event_new_eos ());
}
/* fall through and pause task */
}
pause:
{
- GST_DEBUG_OBJECT (wavpackparse, "Pausing task");
- gst_pad_pause_task (wavpackparse->sinkpad);
+ GST_DEBUG_OBJECT (parse, "Pausing task");
+ gst_pad_pause_task (parse->sinkpad);
return;
}
}