From 00eefe1016adb7d586a3cf79f015afc6e367f920 Mon Sep 17 00:00:00 2001 From: Daniel Caujolle-Bert Date: Mon, 28 May 2001 12:08:20 +0000 Subject: Ability to playback streams without loaded audio driver. CVS patchset: 89 CVS date: 2001/05/28 12:08:20 --- src/demuxers/demux_avi.c | 45 ++++++++++++++++++++++--------------- src/demuxers/demux_elem.c | 21 ++++++++++-------- src/demuxers/demux_mpeg.c | 49 +++++++++++++++++++++++++++-------------- src/demuxers/demux_mpeg_block.c | 31 ++++++++++++++++---------- src/demuxers/demux_mpgaudio.c | 31 ++++++++++++++++---------- src/xine-engine/audio_decoder.c | 17 +++++++++++++- src/xine-engine/xine.c | 13 +++++------ 7 files changed, 131 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 6becaaa48..c22a0c2b7 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.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: demux_avi.c,v 1.9 2001/05/24 23:15:40 f1rmb Exp $ + * $Id: demux_avi.c,v 1.10 2001/05/28 12:08:20 f1rmb Exp $ * * demultiplexer for avi streams * @@ -700,7 +700,7 @@ static long AVI_read_video(demux_avi_t *this, avi_t *AVI, char *vidbuf, static int demux_avi_next (demux_avi_t *this) { - buf_element_t *buf; + buf_element_t *buf = NULL; if (this->avi->video_frames <= this->avi->video_posf) return 0; @@ -708,7 +708,8 @@ static int demux_avi_next (demux_avi_t *this) { if (this->avi->audio_chunks <= this->avi->audio_posc) return 0; - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + if(this->audio_fifo) + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); buf->content = buf->mem; buf->DTS = 0 ; /* FIXME */ @@ -754,7 +755,8 @@ static int demux_avi_next (demux_avi_t *this) { break; } - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); } else { /* read video */ @@ -779,7 +781,7 @@ static int demux_avi_next (demux_avi_t *this) { static void *demux_avi_loop (void *this_gen) { - buf_element_t *buf; + buf_element_t *buf = NULL; demux_avi_t *this = (demux_avi_t *) this_gen; do { @@ -791,9 +793,12 @@ static void *demux_avi_loop (void *this_gen) { buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_END; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + this->audio_fifo->put (this->audio_fifo, buf); + } xprintf (VERBOSE|DEMUX, "demux_avi: demux loop finished.\n"); @@ -881,9 +886,11 @@ static void demux_avi_start (demux_plugin_t *this_gen, buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_START; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_START; + this->audio_fifo->put (this->audio_fifo, buf); + } buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->content = buf->mem; @@ -893,13 +900,15 @@ static void demux_avi_start (demux_plugin_t *this_gen, buf->type = BUF_VIDEO_AVI; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->content = buf->mem; - memcpy (buf->content, &this->avi->wavex, - sizeof (this->avi->wavex)); - buf->size = sizeof (this->avi->wavex); - buf->type = BUF_AUDIO_AVI; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->content = buf->mem; + memcpy (buf->content, &this->avi->wavex, + sizeof (this->avi->wavex)); + buf->size = sizeof (this->avi->wavex); + buf->type = BUF_AUDIO_AVI; + this->audio_fifo->put (this->audio_fifo, buf); + } pthread_create (&this->thread, NULL, demux_avi_loop, this) ; } diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index f64dd4b0f..265ba20e5 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.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: demux_elem.c,v 1.7 2001/05/28 01:28:10 f1rmb Exp $ + * $Id: demux_elem.c,v 1.8 2001/05/28 12:08:20 f1rmb Exp $ * * demultiplexer for elementary mpeg streams * @@ -85,7 +85,7 @@ static int demux_mpeg_elem_next (demux_mpeg_elem_t *this) { * */ static void *demux_mpeg_elem_loop (void *this_gen) { - buf_element_t *buf; + buf_element_t *buf = NULL; demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; do { @@ -103,9 +103,11 @@ static void *demux_mpeg_elem_loop (void *this_gen) { buf->type = BUF_CONTROL_END; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + this->audio_fifo->put (this->audio_fifo, buf); + } pthread_exit(NULL); } @@ -158,10 +160,11 @@ static void demux_mpeg_elem_start (demux_plugin_t *this_gen, buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_START; - this->audio_fifo->put (this->audio_fifo, buf); - + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_START; + this->audio_fifo->put (this->audio_fifo, buf); + } /* * now start demuxing */ diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index 719be6886..c1919494c 100644 --- a/src/demuxers/demux_mpeg.c +++ b/src/demuxers/demux_mpeg.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: demux_mpeg.c,v 1.11 2001/05/24 23:15:40 f1rmb Exp $ + * $Id: demux_mpeg.c,v 1.12 2001/05/28 12:08:20 f1rmb Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -102,7 +102,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { int nLen, i; uint32_t w, flags, header_len, pts; - buf_element_t *buf; + buf_element_t *buf = NULL; nLen = read_bytes(this, 2); @@ -145,7 +145,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { /* contents */ - buf = this->input->read_block (this->input, this->audio_fifo, nLen-4); + if(this->audio_fifo) + buf = this->input->read_block (this->input, this->audio_fifo, nLen-4); if (buf == NULL) { this->status = DEMUX_FINISHED; @@ -156,7 +157,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { buf->DTS = 0 ; /* FIXME */ buf->input_pos = this->input->get_current_pos (this->input); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); } else if ((nID & 0xe0) == 0xc0) { int track = nID & 0x1f; @@ -188,7 +190,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { /* read rest of header */ i = this->input->read (this->input, this->dummy_space, header_len); - buf = this->input->read_block (this->input, this->audio_fifo, nLen); + if(this->audio_fifo) + buf = this->input->read_block (this->input, this->audio_fifo, nLen); if (buf == NULL) { this->status = DEMUX_FINISHED; @@ -199,7 +202,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { buf->DTS = 0; /* FIXME */ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); } else if ((nID >= 0xbc) && ((nID & 0xf0) == 0xe0)) { @@ -232,7 +236,8 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) { /* contents */ - buf = this->input->read_block (this->input, this->audio_fifo, nLen); + if(this->audio_fifo) + buf = this->input->read_block (this->input, this->audio_fifo, nLen); if (buf == NULL) { this->status = DEMUX_FINISHED; @@ -261,7 +266,7 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID) uint32_t w; int i; int pts; - buf_element_t *buf; + buf_element_t *buf = NULL; xprintf (VERBOSE|DEMUX, " packet ("); @@ -344,7 +349,8 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID) xprintf (VERBOSE|DEMUX|AUDIO, ", audio #%d", track); - buf = this->input->read_block (this->input, this->audio_fifo, nLen); + if(this->audio_fifo) + buf = this->input->read_block (this->input, this->audio_fifo, nLen); if (buf == NULL) { this->status = DEMUX_FINISHED; @@ -355,7 +361,8 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID) buf->DTS = 0; /* FIXME */ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); } else if ((nID & 0xf0) == 0xe0) { @@ -473,16 +480,21 @@ static void *demux_mpeg_loop (void *this_gen) { demux_mpeg_resync (this, w); } while (this->status == DEMUX_OK) ; - + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_END; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + this->audio_fifo->put (this->audio_fifo, buf); + } + xprintf (VERBOSE|DEMUX, "demux loop finished (status: %d, buf:%x)\n", this->status, w); + printf ("demux loop finished (status: %d, buf:%x)\n", + this->status, w); pthread_exit(NULL); } @@ -524,9 +536,12 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_START; - this->audio_fifo->put (this->audio_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_START; + this->audio_fifo->put (this->audio_fifo, buf); + } pthread_create (&this->thread, NULL, demux_mpeg_loop, this) ; } diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 4c5b01bae..2c23f5d3a 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.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: demux_mpeg_block.c,v 1.7 2001/05/24 23:15:40 f1rmb Exp $ + * $Id: demux_mpeg_block.c,v 1.8 2001/05/28 12:08:20 f1rmb Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -59,7 +59,7 @@ typedef struct demux_mpeg_block_s { static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { - buf_element_t *buf; + buf_element_t *buf = NULL; unsigned char *p; int bMpeg1=0; uint32_t nHeaderLen; @@ -242,7 +242,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { buf->DTS = nDTS ; buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); return ; } else if ((p[0]&0xf0) == 0xa0) { @@ -265,7 +266,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { buf->DTS = nDTS ; buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); return ; } @@ -299,7 +301,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { buf->DTS = nDTS; buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR); - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put (this->audio_fifo, buf); return ; @@ -315,7 +318,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) { static void *demux_mpeg_block_loop (void *this_gen) { - buf_element_t *buf; + buf_element_t *buf = NULL; demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; do { @@ -333,9 +336,11 @@ static void *demux_mpeg_block_loop (void *this_gen) { buf->type = BUF_CONTROL_END; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + this->audio_fifo->put (this->audio_fifo, buf); + } pthread_exit(NULL); } @@ -387,10 +392,12 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_START; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_START; + this->audio_fifo->put (this->audio_fifo, buf); + } /* * now start demuxing */ diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 010fed8c3..e362b5332 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.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: demux_mpgaudio.c,v 1.6 2001/05/28 01:28:10 f1rmb Exp $ + * $Id: demux_mpgaudio.c,v 1.7 2001/05/28 12:08:20 f1rmb Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -227,10 +227,11 @@ static int mpg123_head_check(unsigned long head) { static int demux_mpgaudio_next (demux_mpgaudio_t *this) { - buf_element_t *buf; - - buf = this->input->read_block(this->input, - this->audio_fifo, 2048); + buf_element_t *buf = NULL; + + if(this->audio_fifo) + buf = this->input->read_block(this->input, + this->audio_fifo, 2048); if (buf == NULL) { this->status = DEMUX_FINISHED; @@ -242,7 +243,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this) { buf->input_pos = this->input->seek(this->input, 0, SEEK_CUR); buf->type = BUF_AUDIO_AVI; - this->audio_fifo->put(this->audio_fifo, buf); + if(this->audio_fifo) + this->audio_fifo->put(this->audio_fifo, buf); return (buf->size == 2048); } @@ -266,9 +268,11 @@ static void *demux_mpgaudio_loop (void *this_gen) { buf->type = BUF_CONTROL_END; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + this->audio_fifo->put (this->audio_fifo, buf); + } pthread_exit(NULL); } @@ -309,10 +313,13 @@ static void demux_mpgaudio_start (demux_plugin_t *this_gen, buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); buf->type = BUF_CONTROL_START; this->video_fifo->put (this->video_fifo, buf); - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_START; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_START; + this->audio_fifo->put (this->audio_fifo, buf); + } + /* * now start demuxing */ diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index cdd73ec6b..8b947856b 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/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.9 2001/05/24 23:15:40 f1rmb Exp $ + * $Id: audio_decoder.c,v 1.10 2001/05/28 12:08:20 f1rmb Exp $ * * * functions that implement audio decoding @@ -155,6 +155,21 @@ void *audio_decoder_loop (void *this_gen) { } } + else { + /* No audio driver loaded */ + pthread_mutex_lock (&this->xine_lock); + + this->audio_finished = 1; + + if (this->video_finished) { + pthread_mutex_unlock (&this->xine_lock); + xine_notify_stream_finished (this); + } else + pthread_mutex_unlock (&this->xine_lock); + + pthread_exit(NULL); + } + buf->free_buffer (buf); } diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 6dd68199c..f7d6557cb 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.18 2001/05/28 01:28:11 f1rmb Exp $ + * $Id: xine.c,v 1.19 2001/05/28 12:08:20 f1rmb Exp $ * * top-level xine functions * @@ -211,7 +211,8 @@ static void xine_play_internal (xine_t *this, char *MRL, return; } - printf ("xine: using input plugin >%s< for this MRL.\n", this->cur_input_plugin->get_identifier(this->cur_input_plugin)); + printf ("xine: using input plugin >%s< for this MRL.\n", + this->cur_input_plugin->get_identifier(this->cur_input_plugin)); /* * find demuxer plugin @@ -224,7 +225,8 @@ static void xine_play_internal (xine_t *this, char *MRL, return; } - printf ("xine: using demuxer plugin >%s< for this MRL.\n", this->cur_demuxer_plugin->get_identifier()); + printf ("xine: using demuxer plugin >%s< for this MRL.\n", + this->cur_demuxer_plugin->get_identifier()); /* * Init SPU decoder with colour lookup table. @@ -438,11 +440,8 @@ xine_t *xine_init (vo_driver_t *vo, if(ao) { this->audio_out = ao; this->audio_out->connect (this->audio_out, this->metronom); - audio_decoder_init (this); } - else - this->audio_out = NULL; /* Disabling audio output */ - + audio_decoder_init (this); /* * init SPU decoder -- cgit v1.2.3