[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] CD.play() with tracks > 0



I haven't heard a response, so I'm re-sending. The attached patch
fixes pygame for my needs (I'm writing a CD player app).

--gilbert

On Sat, 2003-02-08 at 15:50, Gilbert Ramirez wrote:
> Hi. I'm using pygame from CVS. Perhaps I don't understand the CD.play()
> method very well, but I couldn't get it to play anything other than the
> first track. Specifically:
> 
> cd = pygame.cdrom.CD(0)
> cd.play(0)
> 
> works -- it plays the first track.
> 
> But:
> cd.play(1) does not. Any "cd.play(N)" where N > 0 does not work.
> 
> The following patch fixes the problem. I'm not sure if "offset" is
> really needed in the case that I'm comparing "offset+startframe >
> offset+length". In other words, this patch works for me, but I'm not
> sure if it's the correct patch for the way CD.play() is supposed to
> work.    Help!
> 
> --gilbert
> ----
> 


Index: src/cdrom.c
===================================================================
RCS file: /private/hominid-cvs/pygame/src/cdrom.c,v
retrieving revision 1.2
diff -u -r1.2 cdrom.c
--- src/cdrom.c	8 Feb 2003 06:55:15 -0000	1.2
+++ src/cdrom.c	8 Feb 2003 21:43:39 -0000
@@ -288,7 +288,7 @@
 	endframe = (int)(end * CD_FPS);
 	if(startframe < 0)
 		startframe = 0;
-	if(endframe < startframe || offset+startframe > length)
+	if(endframe < startframe || offset+startframe > offset+length)
 		RETURN_NONE;
 	offset += startframe;
 	length = min(length-startframe, endframe-startframe);