bool CDROM_Interface_SDL::PlayAudioSector(unsigned long start,unsigned long len) { // Has to be there, otherwise wrong cd status report (dunno why, sdl bug ?) SDL_CDClose(cd); cd = SDL_CDOpen(driveID); bool success = (SDL_CDPlay(cd,start+150,len)==0); return success; }
void CDAudio_Play(byte track, qboolean looping) { CDstatus cd_stat; if(!cd_id || !enabled) return; if(!cdValid) { if(!CD_INDRIVE(cd_stat=SDL_CDStatus(cd_id)) ||(!cd_id->numtracks)) return; cdValid = true; } if((track < 1) || (track >= cd_id->numtracks)) { Con_DPrintf("CDAudio: Bad track number: %d\n",track); return; } track--; /* Convert track from person to SDL value */ if(cd_stat == CD_PLAYING) { if(cd_id->cur_track == track) return; CDAudio_Stop(); } if(SDL_CDPlay(cd_id,cd_id->track[track].offset, cd_id->track[track].length)) { Con_DPrintf("CDAudio_Play: Unable to play track: %d\n",track+1); return; } playLooping = looping; }
bool CDROM_Interface_SDL::PlayAudioSector(unsigned long start,unsigned long len) { // Has to be there, otherwise wrong cd status report (dunno why, sdl bug ?) //--Disabled 2009-12-30 by Alun Bestor: no it doesn't, in fact disabling and reenabling the CD like this //kills the track listing in OS X owing to another SDL bug. /* SDL_CDClose(cd); cd = SDL_CDOpen(driveID); */ //--End of modifications bool success = (SDL_CDPlay(cd,start+150,len)==0); return success; }
void CDAudio_Play ( int track, qboolean looping ) { CDstatus cd_stat; lastTrack = track + 1; if ( !cd_id || !enabled ) { return; } cd_stat = SDL_CDStatus( cd_id ); if ( !cdValid ) { if ( !CD_INDRIVE( cd_stat ) || ( !cd_id->numtracks ) ) { return; } cdValid = true; } if ( ( track < 1 ) || ( track >= cd_id->numtracks ) ) { Com_DPrintf( "CDAudio: Bad track number: %d\n", track ); return; } track--; if ( cd_stat == CD_PLAYING ) { if ( cd_id->cur_track == track ) { return; } CDAudio_Stop(); } if ( SDL_CDPlay( cd_id, cd_id->track [ track ].offset, cd_id->track [ track ].length ) ) { Com_DPrintf( "CDAudio_Play: Unable to play track: %d (%s)\n", track + 1, SDL_GetError() ); return; } playLooping = looping; }
static PyObject* _cd_play (PyObject *self, PyObject *args) { int start, length; PyObject *asfps = Py_False; int istrue; SDL_CD *cd = ((PyCD*)self)->cd; ASSERT_CDROM_OPEN(self, NULL); if (!PyArg_ParseTuple (args, "ii|O:play", &start, &length, &asfps)) return NULL; if (start < 0 || length < 0) { PyErr_SetString (PyExc_ValueError, "start and length must not be negative"); return NULL; } istrue = PyObject_IsTrue (asfps); if (istrue == -1) return NULL; if (istrue == 0) { /* Start and length are in seconds */ start *= CD_FPS; length *= CD_FPS; } SDL_CDStatus (cd); if (SDL_CDPlay (cd, start, length) == -1) { PyErr_SetString (PyExc_ValueError, SDL_GetError ()); return NULL; } Py_RETURN_NONE; }
void CDAudio_Play(byte track, qboolean looping) { int len_m, len_s, len_f; if (!cd_handle || !enabled) return; if (!cdValid) { CDAudio_GetAudioDiskInfo(); if (!cdValid) return; } track = remap[track]; if (track < 1 || track > cd_handle->numtracks) { Con_Printf ("%s: Bad track number %d.\n", __thisfunc__, track); return; } if (cd_handle->track[track-1].type == SDL_DATA_TRACK) { Con_Printf ("%s: track %d is not audio\n", __thisfunc__, track); return; } if (playing) { if (playTrack == track) return; CDAudio_Stop (); } if (SDL_CDPlay(cd_handle, cd_handle->track[track-1].offset, cd_handle->track[track-1].length) < 0) { // ok, check for status now int cd_status = SDL_CDStatus(cd_handle); if (cd_status > 0) Con_Printf ("%s: Unable to play %d: %s\n", __thisfunc__, track, SDL_GetError ()); return; } playLooping = looping; playTrack = track; playing = true; FRAMES_TO_MSF(cd_handle->track[track-1].length, &len_m, &len_s, &len_f); endOfTrack = realtime + ((double)len_m * 60.0) + (double)len_s + (double)len_f / (double)CD_FPS; /* * Add the pregap for the next track. This means that disc-at-once CDs * won't loop smoothly, but they wouldn't anyway so it doesn't really * matter. SDL doesn't give us pregap information anyway, so you'll * just have to live with it. */ endOfTrack += 2.0; pausetime = -1.0; if (!hw_vol_works && bgmvolume.value == 0.0) CDAudio_Pause (); }
void CDAudio_RandomPlay(void) { int track, i = 0, free_tracks = 0; float f; CDstatus cd_stat; byte* track_bools; if (!cd_id || !enabled) return; track_bools = (byte*)malloc(cd_id->numtracks* sizeof(byte)); if (track_bools == 0) return; //create array of available audio tracknumbers for (; i < cd_id->numtracks; i++) { track_bools[i] = cd_id->track[i].type == SDL_AUDIO_TRACK; free_tracks += track_bools[i]; } if (!free_tracks) { Com_DPrintf("CDAudio_RandomPlay: Unable to find and play a random audio track, insert an audio cd please"); goto free_end; } //choose random audio track do { do { f = ((float)rand()) / ((float)RAND_MAX + 1.0); track = (int)(cd_id->numtracks * f); } while(!track_bools[track]); lastTrack = track+1; cd_stat=SDL_CDStatus(cd_id); if(!cdValid) { if(!CD_INDRIVE(cd_stat) ||(!cd_id->numtracks)) { goto free_end; } cdValid = true; } if(cd_stat == CD_PLAYING) { if(cd_id->cur_track == track + 1) { goto free_end; } CDAudio_Stop(); } if (SDL_CDPlay(cd_id,cd_id->track[track].offset, cd_id->track[track].length)) { track_bools[track] = 0; free_tracks--; } else { playLooping = true; break; } } while (free_tracks > 0); free_end: free((void*)track_bools); }