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

Anders Johansson ajh at watri.uwa.edu.au
Fri Feb 21 03:15:57 CET 2003


Anyone objects if I apply this patch?

//Anders

> 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

> 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	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);

> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> http://mplayerhq.hu/mailman/listinfo/mplayer-dev-eng


-- 
______________________________________________________________________
Anders Johansson   Room G09B      WATRI University of          .-_|\
Visiting  Research Associate      Western Australia           /     \
telephone:   +61 8 9380 8125      39 Stirling Highway         P_.-._/
e-mail: ajh at watri.uwa.edu.au      Crawley WA 6009                  o
______________________________________________________________________






More information about the MPlayer-dev-eng mailing list