changeset 30768:6032dd934340

Ensure that cue_current_pos.track is not set to an invalid value after attempting to seek to e.g. track 0.
author reimar
date Mon, 01 Mar 2010 20:20:13 +0000
parents 29588c0eafd3
children ac65c60efd86
files stream/stream_cue.c
diffstat 1 files changed, 5 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_cue.c	Mon Mar 01 20:11:11 2010 +0000
+++ b/stream/stream_cue.c	Mon Mar 01 20:20:13 2010 +0000
@@ -439,15 +439,14 @@
 
 
 
-static int cue_read_toc_entry(void) {
-
-  int track = cue_current_pos.track - 1;
-
+static int cue_read_toc_entry(int track) {
   /* check if its a valid track, if not return -1 */
-  if (track < 0 || track >= nTracks)
+  if (track <= 0 || track > nTracks)
     return -1;
 
 
+  cue_current_pos.track = track;
+  track--;
   switch (tracks[track].mode)
   {
     case AUDIO:
@@ -470,9 +469,7 @@
 }
 
 static int cue_vcd_seek_to_track (int track){
-  cue_current_pos.track  = track;
-
-  if (cue_read_toc_entry ())
+  if (cue_read_toc_entry (track))
     return -1;
 
   return VCD_SECTOR_DATA * cue_get_msf();