summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/flac/gstflacenc.c26
2 files changed, 23 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index ef59ac7e..84c7648c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-24 Tim-Philipp Müller <tim at centricular dot net>
+
+ * ext/flac/gstflacenc.c: (gst_flac_enc_sink_setcaps),
+ (gst_flac_enc_chain):
+ Don't crash in chain function if setcaps hasn't been called.
+
2007-05-24 Wim Taymans <wim@fluendo.com>
* gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_parse_methods):
diff --git a/ext/flac/gstflacenc.c b/ext/flac/gstflacenc.c
index b257681b..255d6c76 100644
--- a/ext/flac/gstflacenc.c
+++ b/ext/flac/gstflacenc.c
@@ -373,8 +373,8 @@ gst_flac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
GstFlacEnc *flacenc;
GstStructure *structure;
FLAC__SeekableStreamEncoderState state;
+ gint depth, chans, rate, width;
- /* takes a ref on flacenc */
flacenc = GST_FLAC_ENC (gst_pad_get_parent (pad));
if (FLAC__seekable_stream_encoder_get_state (flacenc->encoder) !=
@@ -383,11 +383,17 @@ gst_flac_enc_sink_setcaps (GstPad * pad, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0);
- if (!gst_structure_get_int (structure, "channels", &flacenc->channels)
- || !gst_structure_get_int (structure, "depth", &flacenc->depth)
- || !gst_structure_get_int (structure, "rate", &flacenc->sample_rate))
- /* we got caps incompatible with the template? */
- g_return_val_if_reached (FALSE);
+ if (!gst_structure_get_int (structure, "channels", &chans) ||
+ !gst_structure_get_int (structure, "width", &width) ||
+ !gst_structure_get_int (structure, "depth", &depth) ||
+ !gst_structure_get_int (structure, "rate", &rate)) {
+ GST_DEBUG_OBJECT (flacenc, "incomplete caps: %" GST_PTR_FORMAT, caps);
+ return FALSE;
+ }
+
+ flacenc->channels = chans;
+ flacenc->depth = depth;
+ flacenc->sample_rate = rate;
caps = gst_caps_new_simple ("audio/x-flac",
"channels", G_TYPE_INT, flacenc->channels,
@@ -662,7 +668,11 @@ gst_flac_enc_chain (GstPad * pad, GstBuffer * buffer)
gulong i;
FLAC__bool res;
- flacenc = GST_FLAC_ENC (gst_pad_get_parent (pad));
+ flacenc = GST_FLAC_ENC (GST_PAD_PARENT (pad));
+
+ /* make sure setcaps has been called and the encoder is setup */
+ if (G_UNLIKELY (flacenc->depth == 0))
+ return GST_FLOW_NOT_NEGOTIATED;
depth = flacenc->depth;
@@ -692,8 +702,6 @@ gst_flac_enc_chain (GstPad * pad, GstBuffer * buffer)
g_free (data);
- gst_object_unref (flacenc);
-
if (res)
return GST_FLOW_OK;
else