ext/lame/gstlame.c: Fix up case where there is no peer, in which case _get_allowed_caps() will return NULL.

Original commit message from CVS:
* ext/lame/gstlame.c:
Fix up case where there is no peer, in which case
_get_allowed_caps() will return NULL.
This commit is contained in:
Tim-Philipp Müller 2007-09-26 13:40:35 +00:00
parent 7d1a8026d4
commit 6370d24f99
2 changed files with 23 additions and 10 deletions

View file

@ -1,3 +1,9 @@
2007-09-26 Tim-Philipp Müller <tim at centricular dot net>
* ext/lame/gstlame.c:
Fix up case where there is no peer, in which case
_get_allowed_caps() will return NULL.
2007-09-25 Tim-Philipp Müller <tim at centricular dot net> 2007-09-25 Tim-Philipp Müller <tim at centricular dot net>
* ext/lame/gstlame.c: * ext/lame/gstlame.c:

View file

@ -1162,9 +1162,7 @@ gst_lame_setup (GstLame * lame)
}G_STMT_END }G_STMT_END
int retval; int retval;
GstCaps *src_caps; GstCaps *allowed_caps;
GstStructure *structure;
gint samplerate;
GST_DEBUG_OBJECT (lame, "starting setup"); GST_DEBUG_OBJECT (lame, "starting setup");
@ -1185,15 +1183,24 @@ gst_lame_setup (GstLame * lame)
lame_set_in_samplerate (lame->lgf, lame->samplerate); lame_set_in_samplerate (lame->lgf, lame->samplerate);
/* let lame choose default samplerate unless outgoing sample rate is fixed */ /* let lame choose default samplerate unless outgoing sample rate is fixed */
src_caps = gst_pad_get_allowed_caps (lame->srcpad); allowed_caps = gst_pad_get_allowed_caps (lame->srcpad);
structure = gst_caps_get_structure (src_caps, 0);
if (gst_structure_get_int (structure, "rate", &samplerate)) { if (allowed_caps != NULL) {
GST_DEBUG_OBJECT (lame, "Setting sample rate to %d as fixed in src caps", GstStructure *structure;
samplerate); gint samplerate;
lame_set_out_samplerate (lame->lgf, samplerate);
structure = gst_caps_get_structure (allowed_caps, 0);
if (gst_structure_get_int (structure, "rate", &samplerate)) {
GST_DEBUG_OBJECT (lame, "Setting sample rate to %d as fixed in src caps",
samplerate);
lame_set_out_samplerate (lame->lgf, samplerate);
} else {
GST_DEBUG_OBJECT (lame, "Letting lame choose sample rate");
lame_set_out_samplerate (lame->lgf, 0);
}
} else { } else {
GST_DEBUG_OBJECT (lame, "Letting lame choose sample rate"); GST_DEBUG_OBJECT (lame, "No peer yet, letting lame choose sample rate");
lame_set_out_samplerate (lame->lgf, 0); lame_set_out_samplerate (lame->lgf, 0);
} }