[MPlayer-cvslog] r37469 - trunk/stream/stream_cue.c

ib subversion at mplayerhq.hu
Mon Aug 31 10:31:27 CEST 2015


Author: ib
Date: Mon Aug 31 10:31:27 2015
New Revision: 37469

Log:
Automatically detect the first media data track in the cue driver.

The first track of a Video CD usually stores metadata inside an ISO 9660
filesystem and media data start from track 2. However, the ISO 9660
filesystem can be absent and media data may start from track 1. (Audio
CD images always start with track 1.)

To figure out which track to start playback with (if no track has been
given), check for an ISO 9660 filesystem in track 1 instead of using
track 1 unconditionally as the first one.

Modified:
   trunk/stream/stream_cue.c

Modified: trunk/stream/stream_cue.c
==============================================================================
--- trunk/stream/stream_cue.c	Mon Aug 31 10:14:54 2015	(r37468)
+++ trunk/stream/stream_cue.c	Mon Aug 31 10:31:27 2015	(r37469)
@@ -274,6 +274,19 @@ static int cue_find_bin (const char *fir
   return fd_bin;
 }
 
+static int cue_get_first_track(int fd_bin) {
+  char vol_descriptor[5];
+
+  if (lseek(fd_bin, 16 * VCD_SECTOR_SIZE + VCD_SECTOR_OFFS + 1, SEEK_SET) != -1)
+    if (read(fd_bin, vol_descriptor, 5) == 5)
+      if (strncmp(vol_descriptor, "CD001", 5) == 0)
+        /* ISO 9660 filesystem, so data starting in track 2 */
+        return 2;
+
+  /* data starting in track 1 */
+  return 1;
+}
+
 static inline int cue_msf_2_sector(int minute, int second, int frame) {
  return frame + (second + minute * 60 ) * 75;
 }
@@ -605,12 +618,12 @@ static int open_s(stream_t *stream,int m
       track = atoi(colon+1);
     *colon = 0;
   }
-  if(!track)
-    track = 1;
-
   f = cue_read_cue(filename);
   if(f < 0)
     goto err_out;
+  if(!track)
+    track = cue_get_first_track(f);
+
   cue_read_toc();
   ret=cue_seek_to_track(stream, track);
   if(ret<0){


More information about the MPlayer-cvslog mailing list