From 36c94c8401395e65aeb722e05d24915c9a361c97 Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 21 Apr 2006 23:22:04 +0000 Subject: =?UTF-8?q?Fix=20MP3=20playing=20when=20mad=20is=20disabled=20(pat?= =?UTF-8?q?ch=20from=20Diego=20Petten=C3=B2)=20This=20patch=20validates=20?= =?UTF-8?q?codec=20and=20context=20before=20trying=20to=20call=20ffmpeg=20?= =?UTF-8?q?to=20avoid=20crashes=20when=20mad=20is=20not=20enabled=20and=20?= =?UTF-8?q?an=20mp3=20is=20tried=20to=20be=20played.=20This=20way,=20if=20?= =?UTF-8?q?mad=20support=20is=20not=20enabled=20it=20can=20fail=20"gracefu?= =?UTF-8?q?lly"=20without=20having=20a=20segfault=20that=20takes=20down=20?= =?UTF-8?q?the=20frontend=20entirely.=20Thanks=20to=20Ian=20Monroe=20=20for=20the=20backtrace=20from=20which=20I=20started?= =?UTF-8?q?=20testing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CVS patchset: 7978 CVS date: 2006/04/21 23:22:04 --- src/libffmpeg/audio_decoder.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libffmpeg/audio_decoder.c b/src/libffmpeg/audio_decoder.c index 11efbbba7..53e1415ee 100644 --- a/src/libffmpeg/audio_decoder.c +++ b/src/libffmpeg/audio_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_decoder.c,v 1.23 2006/03/07 08:03:08 tmattern Exp $ + * $Id: audio_decoder.c,v 1.24 2006/04/21 23:22:04 dsalt Exp $ * * xine audio decoder plugin using ffmpeg * @@ -242,6 +242,13 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) } else if (!(buf->decoder_flags & BUF_FLAG_SPECIAL)) { if( !this->decoder_ok ) { + if ( ! this->context || ! this->codec ) { + xprintf (this->stream->xine, XINE_VERBOSITY_LOG, + _("ffmpeg_audio_dec: trying to open null codec\n")); + _x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_HANDLED, 0); + return; + } + pthread_mutex_lock (&ffmpeg_lock); if (avcodec_open (this->context, this->codec) < 0) { pthread_mutex_unlock (&ffmpeg_lock); -- cgit v1.2.3