[MPlayer-dev-eng] [PATCH] CDDA seeking problems

Krister Lagerstrom krister at kmlager.com
Wed Feb 19 06:55:12 CET 2003


I'm using MPlayer as a backend for Freevo to play CD discs. I want
MPlayer to play one track at a time(for instance "cdda://7"), and exit
when the track has ended, and not continue playing the next track. This
works today as long as the user doesn't seek backwards/forwards.

There are two problems with seeking in libmpdemux/cdda.c:

1) Seeking before/after the current track will start previous/next
song, even if only one track was given on the commandline.

Original code:
  if(p->sector == p->end_sector)
    s->eof = 1;
    return;
  }

This only stops when the sector numbers match, but not during seeking.

Proposed change:

  if((p->sector < p->start_sector) || (p->sector >= p->end_sector)) {
    s->eof = 1;
    return;
  }


2) Seeking backwards before the start of track 1 hangs on my machine
(Linux, x86 C500, HITACHI DVD-ROM GD-2500). This is because there is no
checking for pos<0 in seek_cdda(). Is there any reason to seek to pos<0?

Proposed change, start of seek_cdda():

  if(s->pos < 0) {
    s->eof = 1;
    return;
  }


The patch is attached.

		/ Krister
-------------- next part --------------
Index: libmpdemux/cdda.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cdda.c,v
retrieving revision 1.8
diff -u -r1.8 cdda.c
--- libmpdemux/cdda.c	15 Jan 2003 17:50:21 -0000	1.8
+++ libmpdemux/cdda.c	19 Feb 2003 05:55:21 -0000
@@ -182,8 +182,10 @@
   s->pos = p->sector*CD_FRAMESIZE_RAW;
   memcpy(s->buffer,buf,CD_FRAMESIZE_RAW);
 
-  if(p->sector == p->end_sector)
+  if((p->sector < p->start_sector) || (p->sector >= p->end_sector)) {
     s->eof = 1;
+    return;
+  }
 
   for(i=0;i<p->cd->tracks;i++){
 	  if(p->cd->disc_toc[i].dwStartSector==p->sector-1) {
@@ -206,6 +208,12 @@
   int sec;
   int current_track=0, seeked_track=0;
   int i;
+
+  
+  if(s->pos < 0) {
+    s->eof = 1;
+    return;
+  }
 
   sec = s->pos/CD_FRAMESIZE_RAW;
 //printf("pos: %d, sec: %d ## %d\n", (int)s->pos, (int)sec, CD_FRAMESIZE_RAW);


More information about the MPlayer-dev-eng mailing list