[MPlayer-cvslog] CVS: main/libmpdemux cue_read.c,1.8,1.9

Nico Sabbi CVS syncmail at mplayerhq.hu
Sun May 15 09:59:32 CEST 2005


CVS change done by Nico Sabbi CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv29094

Modified Files:
	cue_read.c 
Log Message:
more efficient read() without memcpy()

Index: cue_read.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cue_read.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- cue_read.c	15 May 2005 07:38:42 -0000	1.8
+++ cue_read.c	15 May 2005 07:59:30 -0000	1.9
@@ -324,13 +324,13 @@
      if (*t == '\0')
        strcpy(t, "/");
   }
-  printf ("dirname: %s\n", t);
+  mp_msg(MSGT_OPEN,MSGL_V,"dirname: %s\n", t);
   strlcpy(bincue_path,t,sizeof( bincue_path ));
 
 
   /* no path at all? */
   if (strcmp(bincue_path, ".") == 0) {
-    printf ("bincue_path: %s\n", bincue_path);
+    mp_msg(MSGT_OPEN,MSGL_V,"bincue_path: %s\n", bincue_path);
     strlcpy(cue_filename,in_cue_filename,sizeof( cue_filename ));
   } else {
     strlcpy(cue_filename,in_cue_filename + strlen(bincue_path) + 1,
@@ -462,36 +462,6 @@
   return 0;
 }
 
-static int cue_read_raw(char *buf) {
-  unsigned long position;
-  int track = cue_current_pos.track - 1;
-
-  /* get the mode of the bin file part and calc the positon */
-  position = tracks[track].start_offset +
-             (cue_msf_2_sector(cue_current_pos.minute,
-                               cue_current_pos.second,
-                               cue_current_pos.frame) -
-              tracks[track].start_sector)
-             * cue_mode_2_sector_size(tracks[track].mode);
-
-  /* check if the track is at its end*/
-  if (position >= tracks[track+1].start_offset)
-    return -1;
-
-  if (lseek (fd_bin, position, SEEK_SET) == -1) {
-    mp_msg(MSGT_OPEN,MSGL_ERR,
-           "[bincue] unexpected end of bin file\n");
-    return -1;
-  }
-
-  if (!read (fd_bin, buf, VCD_SECTOR_SIZE))
-    return -1;
-  else
-    return VCD_SECTOR_DATA;
-}
-
-
-
 static int cue_vcd_seek_to_track (int track){
   cue_current_pos.track  = track;
 
@@ -524,14 +494,36 @@
   }
 }
 
+static int cue_vcd_read(stream_t *stream, char *mem, int size) {
+  unsigned long position;
+  int track = cue_current_pos.track - 1;
+  unsigned char tmp[VCD_SECTOR_OFFS];
+
+  position = tracks[track].start_offset +
+             (cue_msf_2_sector(cue_current_pos.minute,
+                               cue_current_pos.second,
+                               cue_current_pos.frame) -
+              tracks[track].start_sector)
+             * cue_mode_2_sector_size(tracks[track].mode);
 
-static char vcd_buf[VCD_SECTOR_SIZE];
+  
+  if(position >= tracks[track+1].start_offset)
+    return 0;
 
-static int cue_vcd_read(stream_t *stream, char *mem, int size) {
+  if(lseek(fd_bin, position, SEEK_SET) == -1) {
+    mp_msg(MSGT_OPEN,MSGL_ERR, "[bincue] unexpected end of bin file\n");
+    return 0;
+  }
 
-  if (cue_read_raw(vcd_buf)==-1) return 0; // EOF?
+  if(read(fd_bin, tmp, VCD_SECTOR_OFFS) != VCD_SECTOR_OFFS) {
+    mp_msg(MSGT_OPEN,MSGL_ERR, "[bincue] couldn't skip %d bytes before payload\n", VCD_SECTOR_OFFS);
+    return 0;
+  }
 
-  memcpy(mem,&vcd_buf[VCD_SECTOR_OFFS],VCD_SECTOR_DATA);
+  if(read(fd_bin, mem, VCD_SECTOR_DATA) != VCD_SECTOR_DATA) {
+    mp_msg(MSGT_OPEN,MSGL_ERR, "[bincue] couldn't read %d bytes of payload\n", VCD_SECTOR_DATA);
+    return 0;
+  }
 
   cue_current_pos.frame++;
   if (cue_current_pos.frame==75){




More information about the MPlayer-cvslog mailing list