[MPlayer-dev-eng] [PATCH] detecting audio cd

j.a.l j.a.l at free.Fr
Mon Oct 21 23:42:32 CEST 2002


-I'm vorking on vcd and while making some test i found something funny :
have you already tried vcd with an audio cd on tray ??? mplayer scan for
tracks, all right, and start reading audio data...

here a little patch that check media type on vcd stream.

i will apply this check on an higher level ( into frontend ), but could
interest you. 

A+
-------------- next part --------------
--- ./libmpdemux/open.c.old	Mon Oct 21 23:18:50 2002
+++ ./libmpdemux/open.c	Mon Oct 21 23:19:23 2002
@@ -19,6 +19,19 @@
 #include "demuxer.h"
 #include "mf.h"
 
+#ifdef HAVE_VCD
+
+#if	defined(linux)
+#include <linux/cdrom.h>
+#elif	defined(sun)
+#include <sys/cdio.h>
+#elif	defined(__bsdi__)
+#include <dvd.h>
+#endif
+
+#endif
+
+
 #ifdef STREAMING
 #include "url.h"
 #include "network.h"
@@ -105,6 +118,33 @@
   if(!cdrom_device) cdrom_device=DEFAULT_CDROM_DEVICE;
   f=open(cdrom_device,O_RDONLY);
   if(f<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,cdrom_device);return NULL; }
+  
+  // check if media in cdrom could be a vcd ( != no media, audio... )
+  {
+		int media_type = CDS_NO_INFO;
+		switch( ( media_type = ioctl(f, CDROM_DISC_STATUS) ) )
+		{
+			case CDS_NO_INFO :
+				mp_msg(MSGT_OPEN,MSGL_WARN,"VCD : cannot get media type info\n");
+				break;
+			
+			case CDS_NO_DISC :
+				mp_msg(MSGT_OPEN,MSGL_ERR, "VCD : No disc in cdrom\n");
+				return NULL;
+			
+			case CDS_AUDIO : 
+				mp_msg(MSGT_OPEN,MSGL_ERR, "VCD : Detected audio cd, data cd expected\n");
+				return( -1 );
+			
+			case CDS_MIXED :		// could have vcd track among ???
+			case CDS_DATA_1 :		// ???
+			case CDS_DATA_2 :		// ???
+			case CDS_XA_2_1 :		// could have
+			case CDS_XA_2_2 :		//could have
+				break;
+		}	
+	}
+  
   vcd_read_toc(f);
   ret2=vcd_get_track_end(f,vcd_track);
   if(ret2<0){ mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");return NULL;}


More information about the MPlayer-dev-eng mailing list