diff stream/stream_cue.c @ 30763:08a3814981a2

Avoid fd_bin and fd_cue global variables.
author reimar
date Mon, 01 Mar 2010 19:35:18 +0000
parents e5c32d429e3a
children 0987402cd276
line wrap: on
line diff
--- a/stream/stream_cue.c	Mon Mar 01 19:25:52 2010 +0000
+++ b/stream/stream_cue.c	Mon Mar 01 19:35:18 2010 +0000
@@ -72,9 +72,6 @@
   stream_opts_fields
 };
 
-static FILE* fd_cue;
-static int fd_bin = 0;
-
 static char cue_filename[256];
 static char bincue_path[256];
 
@@ -120,7 +117,7 @@
 }
 
 /* presumes Line is preloaded with the "current" line of the file */
-static int cue_getTrackinfo(char *Line, tTrack *track)
+static int cue_getTrackinfo(FILE *fd_cue, char *Line, tTrack *track)
 {
   int already_set = 0;
 
@@ -181,6 +178,7 @@
   char bin_filename[256];
   char s[256];
   char t[256];
+  int fd_bin;
 
   /* get the filename out of that */
   /*                      12345 6  */
@@ -268,7 +266,7 @@
 
   mp_msg(MSGT_OPEN,MSGL_INFO,
          MSGTR_MPDEMUX_CUEREAD_UsingBinFile, cur_name);
-  return 0;
+  return fd_bin;
 }
 
 static inline int cue_msf_2_sector(int minute, int second, int frame) {
@@ -315,12 +313,12 @@
   unsigned int sect;
   char *s,*t;
   int i;
+  int fd_bin;
+  FILE *fd_cue;
 
   /* we have no tracks at the beginning */
   nTracks = 0;
 
-  fd_bin = 0;
-
   /* split the filename into a path and filename part */
   s = strdup(in_cue_filename);
   t = strrchr(s, '/');
@@ -367,7 +365,8 @@
     return -1;
   }
 
-  if (cue_find_bin(sLine)) {
+  fd_bin = cue_find_bin(sLine);
+  if (fd_bin == -1) {
     fclose (fd_cue);
     return -1;
   }
@@ -385,7 +384,7 @@
 
   while(!feof(fd_cue))
   {
-    if (cue_getTrackinfo(sLine, &tracks[nTracks++]) != 0)
+    if (cue_getTrackinfo(fd_cue, sLine, &tracks[nTracks++]) != 0)
     {
       mp_msg(MSGT_OPEN,MSGL_ERR,
              MSGTR_MPDEMUX_CUEREAD_ErrReadingFromCueFile, in_cue_filename);
@@ -504,6 +503,7 @@
 
 static int cue_vcd_read(stream_t *stream, char *mem, int size) {
   unsigned long position;
+  int fd_bin = stream->fd;
   int track = cue_current_pos.track - 1;
 
   position = tracks[track].start_offset +