changeset 4700:30131db5dfbb

Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore) Added resync_audio call
author albeu
date Thu, 14 Feb 2002 18:37:33 +0000
parents 406d7fc6be4e
children 53c5b0fe1894
files libmpdemux/demux_audio.c
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_audio.c	Thu Feb 14 18:17:14 2002 +0000
+++ b/libmpdemux/demux_audio.c	Thu Feb 14 18:37:33 2002 +0000
@@ -25,6 +25,7 @@
 
 extern int mp_decode_mp3_header(unsigned char* hbuf);
 extern void free_sh_audio(sh_audio_t* sh);
+extern void resync_audio_stream(sh_audio_t *sh_audio);
 
 
 int demux_audio_open(demuxer_t* demuxer) {
@@ -82,8 +83,18 @@
   switch(frmt) {
   case MP3:
     sh_audio->format = 0x55;
-    stream_seek(s,st_pos);
     demuxer->movi_start = st_pos;
+    for(n = 0; n < 5 ; n++) {
+      pos = mp_decode_mp3_header(hdr);
+      if(pos < 0)
+	return 0;
+      stream_skip(s,pos-4);
+      if(s->eof)
+	return 0;
+      stream_read(s,hdr,4);
+      if(s->eof)
+	return 0;
+    }
     if(s->end_pos) {
       char tag[4];
       stream_seek(s,s->end_pos-128);
@@ -197,7 +208,7 @@
 	ds_add_packet(ds,dp);
 	return 1;
       }
-    }
+    } break;
   case WAV : {
     int l = sh_audio->wf->nAvgBytesPerSec;
     demux_packet_t*  dp = new_demux_packet(l);
@@ -246,4 +257,6 @@
 
   stream_seek(s,pos);
 
+  resync_audio_stream(sh_audio);
+
 }