Commit d2977ff4 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠
Browse files

ext/flac/gstflacenc.c: Don't crash in chain function if setcaps hasn't been called.

Original commit message from CVS:
* 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.
parent 59e42fc5
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):
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment