From 91699d8ebd2bf2ec7f44622e7e090d720c20bcb3 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Fri, 17 Jan 2003 16:52:33 +0000 Subject: fix several segfaults with -A null CVS patchset: 3943 CVS date: 2003/01/17 16:52:33 --- src/demuxers/demux_aiff.c | 7 ++++- src/demuxers/demux_ipmovie.c | 54 +++++++++++++++++++++------------------ src/demuxers/demux_real.c | 6 ++--- src/demuxers/demux_realaudio.c | 6 ++++- src/demuxers/demux_voc.c | 7 ++++- src/demuxers/demux_vqa.c | 53 +++++++++++++++++++++----------------- src/demuxers/demux_wav.c | 7 ++++- src/demuxers/demux_wc3movie.c | 58 ++++++++++++++++++++++-------------------- 8 files changed, 115 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c index 0bfd8e42a..df38a3312 100644 --- a/src/demuxers/demux_aiff.c +++ b/src/demuxers/demux_aiff.c @@ -19,7 +19,7 @@ * * AIFF File Demuxer by Mike Melanson (melanson@pcisys.net) * - * $Id: demux_aiff.c,v 1.24 2003/01/10 21:10:51 miguelfreitas Exp $ + * $Id: demux_aiff.c,v 1.25 2003/01/17 16:52:33 miguelfreitas Exp $ * */ @@ -204,6 +204,11 @@ static int demux_aiff_send_chunk (demux_plugin_t *this_gen) { } while (remaining_sample_bytes) { + if( !this->audio_fifo ) { + this->status = DEMUX_FINISHED; + break; + } + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->audio_type; buf->extra_info->input_pos = current_file_pos; diff --git a/src/demuxers/demux_ipmovie.c b/src/demuxers/demux_ipmovie.c index cc0d0fa5d..76c26cb2d 100644 --- a/src/demuxers/demux_ipmovie.c +++ b/src/demuxers/demux_ipmovie.c @@ -21,7 +21,7 @@ * For more information regarding the Interplay MVE file format, visit: * http://www.pcisys.net/~melanson/codecs/ * - * $Id: demux_ipmovie.c,v 1.4 2003/01/10 11:57:16 miguelfreitas Exp $ + * $Id: demux_ipmovie.c,v 1.5 2003/01/17 16:52:35 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -341,31 +341,35 @@ this->fps++; /* above calculation usually yields 14.9; we need 15 */ debug_ipmovie (" sending audio frame with pts %lld (%d audio frames)\n", audio_pts, this->audio_frame_count); - while (opcode_size) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = this->audio_type; - buf->extra_info->input_pos = current_file_pos; - buf->extra_info->input_length = this->data_size; - buf->extra_info->input_time = audio_pts / 90; - buf->pts = audio_pts; - - if (opcode_size > buf->max_size) - buf->size = buf->max_size; - else - buf->size = opcode_size; - opcode_size -= buf->size; - - if (this->input->read(this->input, buf->content, buf->size) != - buf->size) { - buf->free_buffer(buf); - chunk_type = CHUNK_BAD; - break; + if(this->audio_fifo) { + while (opcode_size) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = this->audio_type; + buf->extra_info->input_pos = current_file_pos; + buf->extra_info->input_length = this->data_size; + buf->extra_info->input_time = audio_pts / 90; + buf->pts = audio_pts; + + if (opcode_size > buf->max_size) + buf->size = buf->max_size; + else + buf->size = opcode_size; + opcode_size -= buf->size; + + if (this->input->read(this->input, buf->content, buf->size) != + buf->size) { + buf->free_buffer(buf); + chunk_type = CHUNK_BAD; + break; + } + + if (!opcode_size) + buf->decoder_flags |= BUF_FLAG_FRAME_END; + + this->audio_fifo->put (this->audio_fifo, buf); } - - if (!opcode_size) - buf->decoder_flags |= BUF_FLAG_FRAME_END; - - this->audio_fifo->put (this->audio_fifo, buf); + }else{ + this->input->seek(this->input, opcode_size, SEEK_CUR); } break; diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 5670e7d50..51e1e4713 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -28,7 +28,7 @@ * * Based on FFmpeg's libav/rm.c. * - * $Id: demux_real.c,v 1.34 2003/01/11 00:00:54 holstsn Exp $ + * $Id: demux_real.c,v 1.35 2003/01/17 16:52:36 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -434,7 +434,7 @@ static void real_parse_headers (demux_real_t *this) { this->audio_stream_num = mdpr->stream_number; - if (this->audio_buf_type) { + if (this->audio_buf_type && this->audio_fifo) { buf_element_t *buf; /* send header */ @@ -880,7 +880,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) { } /* while(size>2) */ - } else if (stream == this->audio_stream_num) { + } else if (stream == this->audio_stream_num && this->audio_fifo) { buf_element_t *buf; int n; diff --git a/src/demuxers/demux_realaudio.c b/src/demuxers/demux_realaudio.c index 8e54928bb..10b3fc022 100644 --- a/src/demuxers/demux_realaudio.c +++ b/src/demuxers/demux_realaudio.c @@ -19,7 +19,7 @@ * * RealAudio File Demuxer by Mike Melanson (melanson@pcisys.net) * - * $Id: demux_realaudio.c,v 1.13 2003/01/17 16:25:49 miguelfreitas Exp $ + * $Id: demux_realaudio.c,v 1.14 2003/01/17 16:52:38 miguelfreitas Exp $ * */ @@ -144,6 +144,10 @@ static int demux_ra_send_chunk(demux_plugin_t *this_gen) { } while (remaining_sample_bytes) { + if(!this->audio_fifo){ + this->status = DEMUX_FINISHED; + break; + } buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->audio_type; buf->extra_info->input_pos = current_file_pos; diff --git a/src/demuxers/demux_voc.c b/src/demuxers/demux_voc.c index a26aa8af4..47765dd80 100644 --- a/src/demuxers/demux_voc.c +++ b/src/demuxers/demux_voc.c @@ -23,7 +23,7 @@ * It will only play that block if it is PCM data. More variations will be * supported as they are encountered. * - * $Id: demux_voc.c,v 1.24 2003/01/10 21:11:11 miguelfreitas Exp $ + * $Id: demux_voc.c,v 1.25 2003/01/17 16:52:38 miguelfreitas Exp $ * */ @@ -179,6 +179,11 @@ static int demux_voc_send_chunk(demux_plugin_t *this_gen) { } while (remaining_sample_bytes) { + /* abort if no audio fifo */ + if(!this->audio_fifo) + this->status = DEMUX_FINISHED; + break; + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->audio_type; buf->extra_info->input_pos = current_file_pos; diff --git a/src/demuxers/demux_vqa.c b/src/demuxers/demux_vqa.c index 9658614a1..8447f2e37 100644 --- a/src/demuxers/demux_vqa.c +++ b/src/demuxers/demux_vqa.c @@ -27,7 +27,7 @@ * block needs information from the previous audio block in order to be * decoded, thus making random seeking difficult. * - * $Id: demux_vqa.c,v 1.26 2003/01/10 11:57:18 miguelfreitas Exp $ + * $Id: demux_vqa.c,v 1.27 2003/01/17 16:52:38 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -179,30 +179,35 @@ static int demux_vqa_send_chunk(demux_plugin_t *this_gen) { this->audio_frames += (chunk_size * 2 / this->audio_channels); while (chunk_size) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_AUDIO_VQA_IMA; - buf->extra_info->input_pos = current_file_pos; - buf->extra_info->input_length = this->filesize; - buf->extra_info->input_time = audio_pts / 90; - buf->pts = audio_pts; - - if (chunk_size > buf->max_size) - buf->size = buf->max_size; - else - buf->size = chunk_size; - chunk_size -= buf->size; - - if (this->input->read(this->input, buf->content, buf->size) != - buf->size) { - buf->free_buffer(buf); - this->status = DEMUX_FINISHED; - break; + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_AUDIO_VQA_IMA; + buf->extra_info->input_pos = current_file_pos; + buf->extra_info->input_length = this->filesize; + buf->extra_info->input_time = audio_pts / 90; + buf->pts = audio_pts; + + if (chunk_size > buf->max_size) + buf->size = buf->max_size; + else + buf->size = chunk_size; + chunk_size -= buf->size; + + if (this->input->read(this->input, buf->content, buf->size) != + buf->size) { + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + break; + } + + if (!chunk_size) + buf->decoder_flags |= BUF_FLAG_FRAME_END; + + this->audio_fifo->put (this->audio_fifo, buf); + }else{ + this->input->seek(this->input, chunk_size, SEEK_CUR); + chunk_size = 0; } - - if (!chunk_size) - buf->decoder_flags |= BUF_FLAG_FRAME_END; - - this->audio_fifo->put (this->audio_fifo, buf); } /* stay on 16-bit alignment */ if (skip_byte) diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c index 916c12280..5cd8a23cd 100644 --- a/src/demuxers/demux_wav.c +++ b/src/demuxers/demux_wav.c @@ -20,7 +20,7 @@ * MS WAV File Demuxer by Mike Melanson (melanson@pcisys.net) * based on WAV specs that are available far and wide * - * $Id: demux_wav.c,v 1.33 2003/01/10 21:11:12 miguelfreitas Exp $ + * $Id: demux_wav.c,v 1.34 2003/01/17 16:52:39 miguelfreitas Exp $ * */ @@ -171,6 +171,11 @@ static int demux_wav_send_chunk(demux_plugin_t *this_gen) { } while (remaining_sample_bytes) { + if(!this->audio_fifo){ + this->status = DEMUX_FINISHED; + break; + } + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->type = this->audio_type; buf->extra_info->input_pos = current_file_pos; diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c index e6bdcb060..8bc889cd4 100644 --- a/src/demuxers/demux_wc3movie.c +++ b/src/demuxers/demux_wc3movie.c @@ -22,7 +22,7 @@ * For more information on the MVE file format, visit: * http://www.pcisys.net/~melanson/codecs/ * - * $Id: demux_wc3movie.c,v 1.32 2003/01/10 11:57:18 miguelfreitas Exp $ + * $Id: demux_wc3movie.c,v 1.33 2003/01/17 16:52:40 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -224,35 +224,39 @@ static int demux_mve_send_chunk(demux_plugin_t *this_gen) { } else if (chunk_tag == AUDI_TAG) { - audio_pts = this->video_pts - WC3_PTS_INC; + if( this->audio_fifo ) { - while (chunk_size) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_AUDIO_LPCM_LE; - buf->extra_info->input_pos = current_file_pos; - buf->extra_info->input_length = this->data_size; - buf->extra_info->input_time = audio_pts / 90; - buf->pts = audio_pts; - - if (chunk_size > buf->max_size) - buf->size = buf->max_size; - else - buf->size = chunk_size; - chunk_size -= buf->size; - - if (this->input->read(this->input, buf->content, buf->size) != - buf->size) { - buf->free_buffer(buf); - this->status = DEMUX_FINISHED; - break; + audio_pts = this->video_pts - WC3_PTS_INC; + + while (chunk_size) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_AUDIO_LPCM_LE; + buf->extra_info->input_pos = current_file_pos; + buf->extra_info->input_length = this->data_size; + buf->extra_info->input_time = audio_pts / 90; + buf->pts = audio_pts; + + if (chunk_size > buf->max_size) + buf->size = buf->max_size; + else + buf->size = chunk_size; + chunk_size -= buf->size; + + if (this->input->read(this->input, buf->content, buf->size) != + buf->size) { + buf->free_buffer(buf); + this->status = DEMUX_FINISHED; + break; + } + + if (!chunk_size) + buf->decoder_flags |= BUF_FLAG_FRAME_END; + + this->audio_fifo->put (this->audio_fifo, buf); } - - if (!chunk_size) - buf->decoder_flags |= BUF_FLAG_FRAME_END; - - this->audio_fifo->put (this->audio_fifo, buf); + }else{ + this->input->seek(this->input, chunk_size, SEEK_CUR); } - } else if (chunk_tag == VGA_TAG) { while (chunk_size) { -- cgit v1.2.3