From 911cb0f678686e70c4a177ae6b6a75b60c2523ac Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 19 Jan 2005 11:01:09 +0000 Subject: [PATCH] ext/mad/gstmad.c: Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of... Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain): Fail if caps negotiation fails. Should fix #162184, and should definately be in there regardless of it fixing the actual bug. * gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init), (gst_avimux_write_tag), (gst_avimux_riff_get_avi_header), (gst_avimux_riff_get_avix_header), (gst_avimux_riff_get_video_header), (gst_avimux_riff_get_audio_header), (gst_avimux_write_index), (gst_avimux_start_file), (gst_avimux_handle_event), (gst_avimux_change_state): * gst/avi/gstavimux.h: Refactor structure writing to use GST_WRITE_UINT macros, add metadata writing support. --- ChangeLog | 16 ++++++++++++++++ ext/mad/gstmad.c | 19 ++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40ad0cdc13..97c4be34ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-01-19 Ronald S. Bultje + + * ext/mad/gstmad.c: (gst_mad_check_caps_reset), (gst_mad_chain): + Fail if caps negotiation fails. Should fix #162184, and should + definately be in there regardless of it fixing the actual bug. + * gst/avi/gstavimux.c: (gst_avimux_get_type), (gst_avimux_init), + (gst_avimux_write_tag), (gst_avimux_riff_get_avi_header), + (gst_avimux_riff_get_avix_header), + (gst_avimux_riff_get_video_header), + (gst_avimux_riff_get_audio_header), (gst_avimux_write_index), + (gst_avimux_start_file), (gst_avimux_handle_event), + (gst_avimux_change_state): + * gst/avi/gstavimux.h: + Refactor structure writing to use GST_WRITE_UINT macros, add + metadata writing support. + 2005-01-18 Ronald S. Bultje * gst/playback/gststreaminfo.c: (gst_stream_info_dispose): diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index e531fe0ae3..6ce7db4e8f 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -1126,7 +1126,7 @@ mpg123_parse_xing_header (struct mad_header *header, /* internal function to check if the header has changed and thus the * caps need to be reset. Only call during normal mode, not resyncing */ -static void +static gboolean gst_mad_check_caps_reset (GstMad * mad) { guint nchannels; @@ -1157,8 +1157,10 @@ gst_mad_check_caps_reset (GstMad * mad) mad->pending_channels = nchannels; mad->pending_rate = rate; } + /* Now, we already have a valid caps set and will continue to use + * that for a while longer, so we cans afely return TRUE here. */ if (++mad->times_pending < 3) - return; + return TRUE; } } gst_mad_update_info (mad); @@ -1182,9 +1184,15 @@ gst_mad_check_caps_reset (GstMad * mad) mad->caps_set = TRUE; /* set back to FALSE on discont */ mad->channels = nchannels; mad->rate = rate; + } else { + GST_ELEMENT_ERROR (mad, CORE, NEGOTIATION, (NULL), + ("Failed to negotiate %d Hz, %d channels", rate, nchannels)); + return FALSE; } gst_caps_free (caps); } + + return TRUE; } static void @@ -1370,7 +1378,6 @@ gst_mad_chain (GstPad * pad, GstData * _data) GST_DEBUG ("synced to data: 0x%0x 0x%0x", *mad->stream.ptr.byte, *(mad->stream.ptr.byte + 1)); - mad_stream_sync (&mad->stream); /* recoverable errors pass */ } @@ -1403,8 +1410,10 @@ gst_mad_chain (GstPad * pad, GstData * _data) } /* if we're not resyncing/in error, check if caps need to be set again */ - if (!mad->in_error) - gst_mad_check_caps_reset (mad); + if (!mad->in_error) { + if (!gst_mad_check_caps_reset (mad)) + goto end; + } nsamples = MAD_NSBSAMPLES (&mad->frame.header) * (mad->stream.options & MAD_OPTION_HALFSAMPLERATE ? 16 : 32);