From 6164a66f89ad267257b39c21cb6b8c5f450195f6 Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Thu, 28 Aug 2003 16:42:07 +0000 Subject: Fix bug in demux_mpeg_pes.c Make sure it waits for a "program_stream_pack_header" before demuxing anything else. CVS patchset: 5315 CVS date: 2003/08/28 16:42:07 --- src/audio_out/audio_alsa_out.c | 4 ++-- src/demuxers/demux_mpeg_pes.c | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 934314618..4f43ff793 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton * * - * $Id: audio_alsa_out.c,v 1.102 2003/08/26 02:37:21 jcdutton Exp $ + * $Id: audio_alsa_out.c,v 1.103 2003/08/28 16:42:07 jcdutton Exp $ */ #ifdef HAVE_CONFIG_H @@ -376,7 +376,7 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int */ err=snd_pcm_open(&this->audio_fd, pcm_device, direction, open_mode); if(err <0 ) { - printf ("audio_alsa_out: snd_pcm_open() failed: %s\n", snd_strerror(err)); + printf ("audio_alsa_out: snd_pcm_open() of %s failed: %s\n", pcm_device, snd_strerror(err)); printf ("audio_alsa_out: >>> check if another program don't already use PCM <<<\n"); return 0; } diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 5f305d2e5..1a0a4af93 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.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_pes.c,v 1.6 2003/07/25 21:02:05 miguelfreitas Exp $ + * $Id: demux_mpeg_pes.c,v 1.7 2003/08/28 16:42:09 jcdutton Exp $ * * demultiplexer for mpeg 2 PES (Packetized Elementary Streams) * reads streams of variable blocksizes @@ -91,6 +91,7 @@ typedef struct demux_mpeg_pes_s { int64_t dts; uint32_t stream_id; int32_t mpeg1; + int32_t wait_for_program_stream_pack_header; /* stream index for get_audio/video_frame */ int have_index; @@ -218,7 +219,8 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) this->stream_id = p[3]; if (this->stream_id == 0xBA) { - /* This just fills this->scr, and this->rate */ + this->wait_for_program_stream_pack_header=0; + /* This just fills this->scr, this->rate and this->mpeg1 */ result = parse_program_stream_pack_header(this, p, buf); return; } else if (this->stream_id == 0xB9) { @@ -230,6 +232,12 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) buf->free_buffer (buf); return; } + if (this->wait_for_program_stream_pack_header==1) { + /* Wait until this->mpeg1 has been initialised. */ + buf->free_buffer (buf); + return; + } + this->packet_len = p[4] << 8 | p[5]; #ifdef LOG printf("demux_pes: stream_id=0x%x, packet_len=%d\n",this->stream_id, this->packet_len); @@ -306,6 +314,8 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) return; } if (result < 0) { + xine_log (this->stream->xine, XINE_LOG_MSG, + _("demux_mpeg_pes: warning: PACK stream id=0x%x decode failed.\n"), this->stream_id); /* What to do here? */ assert(0); } @@ -1350,6 +1360,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->scratch = xine_xmalloc_aligned (512, 4096, (void**) &this->scratch_base); this->status = DEMUX_FINISHED; this->have_index = 0; + /* Don't start demuxing stream until we see a program_stream_pack_header */ + /* We need to system header in order to identify is the stream is mpeg1 or mpeg2. */ + this->wait_for_program_stream_pack_header=1; #ifdef LOG printf ("demux_mpeg_pes:open_plugin:detection_method=%d\n", -- cgit v1.2.3