Anonymous avatar Anonymous committed b10db29

CD.play redone

Comments (0)

Files changed (4)

 # BREAK = change breaks existing code
 # BUG	= fixed a bug that was (or could have been) crashing
 
+May 13, 2002
+	fixed CD.play()
+
 May 8, 2002
 	music.play() start time works
 	image.save() can save TGA images
 </tt></font><ul>
 Play an audio track on a cdrom disk.
 You may also optionally pass a starting and ending
-time to play of the song. If you pass the start end
+time to play of the song. If you pass the start and
 end time in seconds, only that portion of the audio
 track will be played. If you only provide a start time
 and no end time, this will play to the end of the track.

docs/ref/Surface.html

 rectangle sizes will be ignored.
 
 <br>&nbsp;<br>
-Note that blitting surfaces with alpha onto 8bit destinations will
+Blitting surfaces with pixel alphas onto an 8bit destination will
 not use the surface alpha values.
 
 </ul><br>&nbsp;<br>
 The new subsurface will inherit the palette, colorkey, and surface alpha
 values from the base image.
 <br>&nbsp;<br>
+You cannot subsurface an image that is already a subsurface.
+<br>&nbsp;<br>
 You should not use the RLEACCEL flag for parent surfaces of subsurfaces,
 for the most part it will work, but it will cause a lot of extra work,
 every time you change the subsurface, you must decode and recode the
 
 static void cd_dealloc(PyObject* self)
 {
-	PyObject_DEL(self);	
+	PyObject_DEL(self);
 }
 
 
 
 static PyObject* CD(PyObject* self, PyObject* args)
 {
-	int id;	
+	int id;
 	if(!PyArg_ParseTuple(args, "i", &id))
 		return NULL;
 
     /*DOC*/    "\n"
     /*DOC*/    "Play an audio track on a cdrom disk.\n"
     /*DOC*/    "You may also optionally pass a starting and ending\n"
-    /*DOC*/    "time to play of the song. If you pass the start end\n"
+    /*DOC*/    "time to play of the song. If you pass the start and\n"
     /*DOC*/    "end time in seconds, only that portion of the audio\n"
     /*DOC*/    "track will be played. If you only provide a start time\n"
     /*DOC*/    "and no end time, this will play to the end of the track.\n"
 {
 	int cd_id = PyCD_AsID(self);
 	SDL_CD* cdrom = cdrom_drivedata[cd_id];
-	int result, track, offset, length;
-	float start=0.0f, end=6000000.0f;
-	int startframe, endframe;
+	int result, track, startframe, endframe;
+	float start=0.0f, end=0.0f;
 
 	if(!PyArg_ParseTuple(args, "i|ff", &track, &start, &end))
 		return NULL;
 		return RAISE(PyExc_IndexError, "Invalid track number");
 	if(cdrom->track[track].type != SDL_AUDIO_TRACK)
 		return RAISE(PyExc_SDLError, "CD track type is not audio");
-	offset = cdrom->track[track].offset;
-	length = cdrom->track[track].length * CD_FPS;
-	startframe = (int)(start * CD_FPS);
-	endframe = (int)(end * CD_FPS);
+
+        /*validate times*/
+        startframe = (int)(start * CD_FPS);
 	if(startframe < 0)
 		startframe = 0;
-	if(endframe < startframe || startframe > length)
-            RETURN_NONE;
-	offset += startframe;
-	length = min(length-startframe, endframe-startframe);
-	result = SDL_CDPlay(cdrom, offset, length);
+	if(endframe < startframe || startframe > cdrom->track[track].length * CD_FPS)
+                RETURN_NONE;
+        if(end)
+                endframe = (int)((end-start) * CD_FPS);
+        else
+                endframe = cdrom->track[track].length - startframe;
+
+        result = SDL_CDPlayTracks(cdrom, track, startframe, 0, endframe);
 	if(result == -1)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
 static PyObject* cd_get_name(PyObject* self, PyObject* args)
 {
 	int cd_id = PyCD_AsID(self);
-	
+
 	if(!PyArg_ParseTuple(args, ""))
 		return NULL;
 
 	int cd_id = PyCD_AsID(self);
 	SDL_CD* cdrom = cdrom_drivedata[cd_id];
 	int track;
-	
+
 	if(!PyArg_ParseTuple(args, "i", &track))
 		return NULL;
 
 	int cd_id = PyCD_AsID(self);
 	SDL_CD* cdrom = cdrom_drivedata[cd_id];
 	int track;
-	
+
 	if(!PyArg_ParseTuple(args, "i", &track))
 		return NULL;
 
 	int cd_id = PyCD_AsID(self);
 	SDL_CD* cdrom = cdrom_drivedata[cd_id];
 	int track;
-	
+
 	if(!PyArg_ParseTuple(args, "i", &track))
 		return NULL;
 
 	SDL_CD* cdrom = cdrom_drivedata[cd_id];
 	int track;
 	PyObject *tuple, *item;
-	
+
 	if(!PyArg_ParseTuple(args, ""))
 		return NULL;
 
 	0,
 	0,
 	NULL,
-	0, 
+	0,
 	(hashfunc)NULL,
 	(ternaryfunc)NULL,
 	(reprfunc)NULL,
 
 	if(id < 0 || id >= CDROM_MAXDRIVES || id >= SDL_CDNumDrives())
 		return RAISE(PyExc_SDLError, "Invalid cdrom device number");
-	
+
 	cd = PyObject_NEW(PyCDObject, &PyCD_Type);
 	if(!cd) return NULL;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.