ext/vorbis/oggvorbisenc.c: properly fail when we can't setup the vorbis encoder due to unsupported settings

Original commit message from CVS:
* ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_sinkconnect),
(gst_oggvorbisenc_setup):
properly fail when we can't setup the vorbis encoder due to
unsupported settings
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_sinkconnect),
(gst_vorbisenc_setup):
same
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_link):
fix case where warnings occured when one pad was unlinked while the
other's link function was called
This commit is contained in:
Benjamin Otte 2004-05-24 19:19:29 +00:00
parent 72f03b689d
commit 2e050e0378
4 changed files with 49 additions and 17 deletions

View file

@ -1,3 +1,16 @@
2004-05-24 Benjamin Otte <otte@gnome.org>
* ext/vorbis/oggvorbisenc.c: (gst_oggvorbisenc_sinkconnect),
(gst_oggvorbisenc_setup):
properly fail when we can't setup the vorbis encoder due to
unsupported settings
* ext/vorbis/vorbisenc.c: (gst_vorbisenc_sinkconnect),
(gst_vorbisenc_setup):
same
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_link):
fix case where warnings occured when one pad was unlinked while the
other's link function was called
2004-05-24 Thomas Vander Stichele <thomas at apestaart dot org> 2004-05-24 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/tcp/Makefile.am: * gst/tcp/Makefile.am:

View file

@ -224,6 +224,7 @@ gst_oggvorbisenc_sinkconnect (GstPad * pad, const GstCaps * caps)
GstStructure *structure; GstStructure *structure;
vorbisenc = GST_OGGVORBISENC (gst_pad_get_parent (pad)); vorbisenc = GST_OGGVORBISENC (gst_pad_get_parent (pad));
vorbisenc->setup = FALSE;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &vorbisenc->channels); gst_structure_get_int (structure, "channels", &vorbisenc->channels);
@ -655,14 +656,24 @@ gst_oggvorbisenc_setup (OggVorbisEnc * vorbisenc)
vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai); vorbis_encode_ctl (&vorbisenc->vi, OV_ECTL_RATEMANAGE_SET, &ai);
} }
} else { } else {
if (vorbis_encode_setup_managed (&vorbisenc->vi, int ret;
vorbisenc->channels,
GST_LOG_OBJECT (vorbisenc,
"calling setup_managed with channels=%d, frequency=%d, bitrate=[%d,%d,%d]",
vorbisenc->channels, vorbisenc->frequency,
vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1,
vorbisenc->bitrate,
vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1);
ret =
vorbis_encode_setup_managed (&vorbisenc->vi, vorbisenc->channels,
vorbisenc->frequency, vorbisenc->frequency,
vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1, vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1,
vorbisenc->bitrate, vorbisenc->bitrate,
vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1)) { vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1);
g_warning if (ret != 0) {
("vorbisenc: initialisation failed: invalid parameters for bitrate\n"); GST_ERROR_OBJECT (vorbisenc,
"vorbisenc: initialisation failed: invalid parameters for bitrate (returned: %d)",
ret);
vorbis_info_clear (&vorbisenc->vi); vorbis_info_clear (&vorbisenc->vi);
return FALSE; return FALSE;
} }

View file

@ -228,6 +228,7 @@ gst_vorbisenc_sinkconnect (GstPad * pad, const GstCaps * caps)
GstStructure *structure; GstStructure *structure;
vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad)); vorbisenc = GST_VORBISENC (gst_pad_get_parent (pad));
vorbisenc->setup = FALSE;
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
gst_structure_get_int (structure, "channels", &vorbisenc->channels); gst_structure_get_int (structure, "channels", &vorbisenc->channels);
@ -622,6 +623,8 @@ update_start_message (VorbisEnc * vorbisenc)
static gboolean static gboolean
gst_vorbisenc_setup (VorbisEnc * vorbisenc) gst_vorbisenc_setup (VorbisEnc * vorbisenc)
{ {
vorbisenc->setup = FALSE;
if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0 if (vorbisenc->bitrate < 0 && vorbisenc->min_bitrate < 0
&& vorbisenc->max_bitrate < 0) { && vorbisenc->max_bitrate < 0) {
vorbisenc->quality_set = TRUE; vorbisenc->quality_set = TRUE;
@ -635,9 +638,10 @@ gst_vorbisenc_setup (VorbisEnc * vorbisenc)
if (vorbisenc->quality_set) { if (vorbisenc->quality_set) {
if (vorbis_encode_setup_vbr (&vorbisenc->vi, if (vorbis_encode_setup_vbr (&vorbisenc->vi,
vorbisenc->channels, vorbisenc->frequency, vorbisenc->quality)) { vorbisenc->channels, vorbisenc->frequency,
g_warning vorbisenc->quality) != 0) {
("vorbisenc: initialisation failed: invalid parameters for quality"); GST_ERROR_OBJECT (vorbisenc,
"vorbisenc: initialisation failed: invalid parameters for quality");
vorbis_info_clear (&vorbisenc->vi); vorbis_info_clear (&vorbisenc->vi);
return FALSE; return FALSE;
} }
@ -662,8 +666,8 @@ gst_vorbisenc_setup (VorbisEnc * vorbisenc)
vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1, vorbisenc->max_bitrate > 0 ? vorbisenc->max_bitrate : -1,
vorbisenc->bitrate, vorbisenc->bitrate,
vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1)) { vorbisenc->min_bitrate > 0 ? vorbisenc->min_bitrate : -1)) {
g_warning GST_ERROR_OBJECT (vorbisenc,
("vorbisenc: initialisation failed: invalid parameters for bitrate\n"); "vorbisenc: initialisation failed: invalid parameters for bitrate");
vorbis_info_clear (&vorbisenc->vi); vorbis_info_clear (&vorbisenc->vi);
return FALSE; return FALSE;
} }

View file

@ -400,11 +400,15 @@ gst_audio_convert_link (GstPad * pad, const GstCaps * caps)
return ret; return ret;
/* woohoo, got it */ /* woohoo, got it */
if (!gst_audio_convert_parse_caps (gst_pad_get_negotiated_caps (otherpad), othercaps = (GstCaps *) gst_pad_get_negotiated_caps (otherpad);
&other_ac_caps)) { if (othercaps) {
if (!gst_audio_convert_parse_caps (othercaps, &other_ac_caps)) {
g_critical ("internal negotiation error"); g_critical ("internal negotiation error");
return GST_PAD_LINK_REFUSED; return GST_PAD_LINK_REFUSED;
} }
} else {
other_ac_caps = ac_caps;
}
if (this->sink == pad) { if (this->sink == pad) {
this->srccaps = other_ac_caps; this->srccaps = other_ac_caps;