bool SDL::ejectCDTray() { SDL_CD* cdrom; if (SDL_CDNumDrives() <= 0) { Log::warning("SDL_CDNumDrives: No CD-ROM drives available"); return false; } // The system's default CD-ROM is always drive 0 cdrom = SDL_CDOpen(0); if (!cdrom) { Log::warning("SDL_CDOpen: Couldn't open default CD-ROM: " + std::string(SDL_GetError())); return false; } if (SDL_CDEject(cdrom) == -1) { SDL_CDClose(cdrom); return false; } else { SDL_CDClose(cdrom); return true; } }
void RBAInit() { int num_cds; int i,j; if (initialised) return; if (SDL_Init(SDL_INIT_CDROM) < 0) { Warning("SDL library initialisation failed: %s.",SDL_GetError()); return; } num_cds = SDL_CDNumDrives(); if (num_cds < 1) { con_printf(CON_NORMAL, "No cdrom drives found!\n"); #if defined(__APPLE__) || defined(macintosh) SDL_QuitSubSystem(SDL_INIT_CDROM); // necessary for rescanning CDROMs #endif return; } for (i = 0; i < num_cds; i++) { if (s_cd) SDL_CDClose(s_cd); s_cd = SDL_CDOpen(i); if (s_cd && CD_INDRIVE(SDL_CDStatus(s_cd))) { for (j = 0; j < s_cd->numtracks; j++) { if (s_cd->track[j].type == SDL_AUDIO_TRACK) break; } if (j != s_cd->numtracks) break; // we've found an audio CD } else if (s_cd == NULL) Warning("Could not open cdrom %i for redbook audio:%s\n", i, SDL_GetError()); } if (i == num_cds) { con_printf(CON_NORMAL, "No audio CDs found\n"); if (s_cd) // if there's no audio CD, say that there's no redbook and hence play MIDI instead { SDL_CDClose(s_cd); s_cd = NULL; } #if defined(__APPLE__) || defined(macintosh) SDL_QuitSubSystem(SDL_INIT_CDROM); // necessary for rescanning CDROMs #endif return; } initialised = 1; }
int CDAudio_SysStartup (void) { int i; int numdrives; numdrives = SDL_CDNumDrives(); if( numdrives == -1 ) // was the CDROM system initialized correctly? return -1; Con_Printf( "Found %i cdrom drives.\n", numdrives ); for( i = 0 ; i < numdrives ; i++, cd = NULL ) { cd = SDL_CDOpen( i ); if( !cd ) { Con_Printf( "CD drive %i is invalid.\n", i ); continue; } if( CD_INDRIVE( SDL_CDStatus( cd ) ) ) if( IsAudioCD() ) break; else Con_Printf( "The CD in drive %i is not an audio cd.\n", i ); else Con_Printf( "No CD in drive %i.\n", i ); SDL_CDClose( cd ); } if( i == numdrives && !cd ) return -1; return 0; }
bool CDROM_Interface_SDL::StopAudio(void) { // Has to be there, otherwise wrong cd status report (dunno why, sdl bug ?) SDL_CDClose(cd); cd = SDL_CDOpen(driveID); bool success = (SDL_CDStop(cd)==0); return success; }
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_SDL_CDDrive_f( void ) { int i; int numdrives = SDL_CDNumDrives(); if( Cmd_Argc() != 2 ) { Con_Print( "cddrive <drivenr>\n" ); return; } i = atoi( Cmd_Argv( 1 ) ); if( i >= numdrives ) { Con_Printf("Only %i drives!\n", numdrives ); return; } if( cd ) SDL_CDClose( cd ); cd = SDL_CDOpen( i ); if( !cd ) { Con_Printf( "Couldn't open drive %i.\n", i ); return; } if( !CD_INDRIVE( SDL_CDStatus( cd ) ) ) Con_Printf( "No cd in drive %i.\n", i ); else if( !IsAudioCD() ) Con_Printf( "The CD in drive %i is not an audio CD.\n", i ); ValidateDrive(); }
static int modcd_getinfo( INSTANCE * my, int * params ) { int i, total = 0; char * trackinfo; if ( params[0] < 0 || params[0] >= SDL_CDNumDrives() ) return 0; if ( sdl_cd == NULL || sdl_cdnum != params[0] ) { if ( sdl_cd ) SDL_CDClose( sdl_cd ); sdl_cd = SDL_CDOpen( params[0] ); if ( sdl_cd == NULL ) return 0; sdl_cdnum = params[0]; } GLODWORD( mod_cd, CD_TRACKS ) = sdl_cd->numtracks; GLODWORD( mod_cd, CD_TRACK ) = sdl_cd->cur_track; FRAMES_TO_MSF( sdl_cd->cur_frame, &GLODWORD( mod_cd, CD_MINUTE ), &GLODWORD( mod_cd, CD_SECOND ), &GLODWORD( mod_cd, CD_SUBFRAME ) ); trackinfo = ( char * ) & GLODWORD( mod_cd, CD_TRACKINFO ); for ( i = 0; i < sdl_cd->numtracks ; i++, trackinfo += 16 ) { total += sdl_cd->track[i].length; *( Uint32 * ) trackinfo = ( sdl_cd->track[i].type == SDL_AUDIO_TRACK ); FRAMES_TO_MSF( sdl_cd->track[i].length, trackinfo + 4, trackinfo + 8, trackinfo + 12 ); } FRAMES_TO_MSF( total, &GLODWORD( mod_cd, CD_MINUTES ), &GLODWORD( mod_cd, CD_SECONDS ), &GLODWORD( mod_cd, CD_FRAMES ) ); return 1; }
void CDAudio_Shutdown() { if(!cd_id) return; CDAudio_Stop(); SDL_CDClose(cd_id); cd_id = NULL; }
int main(int argc, char **argv) { SDL_Init(SDL_INIT_CDROM); atexit(SDL_Quit); int ndrives = SDL_CDNumDrives(); if (ndrives == 0) { printf("Alas, no CD drives.\n"); } int drive_no; for (drive_no = 0; drive_no < ndrives; drive_no++) { SDL_CD *drive = SDL_CDOpen(drive_no); if (drive == NULL) { printf("Couldn't get drive %d.\n", drive_no); continue; } if (SDL_CDEject(drive)) { printf("Couldn't eject drive %d.\n", drive_no); } else { printf("Ping! (%d of %d)\n", drive_no + 1, ndrives); } SDL_CDClose(drive); } printf("Ejected everything.\n"); return 0; }
void RBAExit() { if (s_cd) { SDL_CDStop(s_cd); SDL_CDClose(s_cd); } }
void RBAExit() { if (initialised) { SDL_CDStop(s_cd); SDL_CDClose(s_cd); } }
void _CDECL_ RBAExit(void) { LogErr ("shutting down SDL CD service\n"); if (initialised) { SDL_CDStop(s_cd); SDL_CDClose(s_cd); } }
void vultures_exit_graphics_mode(void) { SDL_ShowCursor(SDL_ENABLE); vultures_stop_music(); if (vultures_cdrom) SDL_CDClose(vultures_cdrom); vultures_cdrom = NULL; SDL_Quit(); }
void SdlAudioCDManager::close() { DefaultAudioCDManager::close(); if (_cdrom) { SDL_CDStop(_cdrom); SDL_CDClose(_cdrom); _cdrom = 0; } }
static void _cd_dealloc (PyCD *self) { if (self->cd) { SDL_CDClose (self->cd); cdrommod_remove_drive (self->index); } ((PyObject*)self)->ob_type->tp_free ((PyObject *) self); }
static PyObject* cd_quit (PyObject* self) { int cd_id = PyCD_AsID (self); CDROM_INIT_CHECK (); if (cdrom_drivedata[cd_id]) { SDL_CDClose (cdrom_drivedata[cd_id]); cdrom_drivedata[cd_id] = NULL; } Py_RETURN_NONE; }
void CDAudio_Shutdown(void) { if (!cd_handle) return; CDAudio_Stop(); // cd hardware volume: no SDL support at present. // if (hw_vol_works) // CD_SetVolume (NULL); SDL_CDClose(cd_handle); cd_handle = NULL; cd_dev = -1; SDL_QuitSubSystem(SDL_INIT_CDROM); }
void I_ShutdownCD() { if (!initialized) return; I_StopCD(); SDL_CDClose(cdrom); cdrom = NULL; initialized = false; enabled = false; }
static int modcd_status( INSTANCE * my, int * params ) { if ( params[0] < 0 || params[0] >= SDL_CDNumDrives() ) return 0; if ( sdl_cd == NULL || sdl_cdnum != params[0] ) { if ( sdl_cd ) SDL_CDClose( sdl_cd ); sdl_cd = SDL_CDOpen( params[0] ); if ( sdl_cd == NULL ) return 0; sdl_cdnum = params[0]; } return SDL_CDStatus( sdl_cd ); }
void CDAudio_Shutdown() { if(!cd_id) return; CDAudio_Stop(); SDL_CDClose(cd_id); cd_id = NULL; if (SDL_WasInit(SDL_INIT_EVERYTHING) == SDL_INIT_CDROM) SDL_Quit(); else SDL_QuitSubSystem(SDL_INIT_CDROM); initialized = false; }
void SoundManager::CleanupRedbook() { #if defined(USE_SDL) if (m_cdrom) { SDL_CDClose(m_cdrom); m_cdrom = 0; } #else if (m_redbook) { AIL_redbook_stop(m_redbook); AIL_redbook_close(m_redbook); m_redbook = NULL; } #endif }
static void cdrom_autoquit (void) { int loop; for (loop = 0; loop < CDROM_MAXDRIVES; ++loop) { if (cdrom_drivedata[loop]) { SDL_CDClose (cdrom_drivedata[loop]); cdrom_drivedata[loop] = NULL; } } if (SDL_WasInit (SDL_INIT_CDROM)) { SDL_QuitSubSystem (SDL_INIT_CDROM); } }
static int modcd_playtracks( INSTANCE * my, int * params ) { if ( params[0] < 0 || params[0] >= SDL_CDNumDrives() ) return 0; if ( sdl_cd == NULL || sdl_cdnum != params[0] ) { if ( sdl_cd ) SDL_CDClose( sdl_cd ); sdl_cd = SDL_CDOpen( params[0] ); if ( sdl_cd == NULL ) return 0; sdl_cdnum = params[0]; } if ( CD_INDRIVE( SDL_CDStatus( sdl_cd ) ) ) return !SDL_CDPlayTracks( sdl_cd, params[1], 0, params[2], 0 ); return 0; }
/************************************************************************** * * function: ShutdownCD * * description: * * **************************************************************************/ void I_ShutdownCD (void) { #ifndef NOSDLCD if (!cdaudio_started) return; I_StopCD(); CONS_Printf("I_ShutdownCD: "); SDL_CDClose(cdrom); cdrom = NULL; cdaudio_started = false; CONS_Printf("%s", M_GetText("shut down\n")); SDL_QuitSubSystem(SDL_INIT_CDROM); cdEnabled = SDL_FALSE; #endif }
static PyObject* _cd_close (PyObject *self) { PyCD *cdrom = (PyCD*)self; SDL_CD* cd; ASSERT_CDROM_INIT(NULL); cd = cdrommod_get_drive (cdrom->index); if (!cd) Py_RETURN_NONE; /* Already closed */ SDL_CDClose (cdrom->cd); cdrom->cd = NULL; cdrommod_remove_drive (cdrom->index); Py_RETURN_NONE; }
//------------------------------------------------------------------------------ bool UnixRedBookDevice::close() { #if !defined(__FreeBSD__) if(!mAcquired) { setLastError("Device has not been acquired"); return(false); } stop(); closeVolume(); if (mCD != NULL) { SDL_CDClose(mCD); mCD = NULL; } mAcquired = false; setLastError(""); return(true); #endif // !defined(__FreeBSD__) }
int main(int argc, char *argv[]) { int drive; int i; SDL_CD *cdrom; /* Initialize SDL first */ if ( SDL_Init(SDL_INIT_CDROM) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); return(1); } /* Find out how many CD-ROM drives are connected to the system */ if ( SDL_CDNumDrives() == 0 ) { printf("No CD-ROM devices detected\n"); quit(0); } printf("Drives available: %d\n", SDL_CDNumDrives()); for ( i=0; i<SDL_CDNumDrives(); ++i ) { printf("Drive %d: \"%s\"\n", i, SDL_CDName(i)); } /* Open the CD-ROM */ drive = 0; i=1; if ( argv[i] && isdigit(argv[i][0]) ) { drive = atoi(argv[i++]); } cdrom = SDL_CDOpen(drive); if ( cdrom == NULL ) { fprintf(stderr, "Couldn't open drive %d: %s\n", drive, SDL_GetError()); quit(2); } #ifdef TEST_NULLCD cdrom = NULL; #endif /* Find out which function to perform */ for ( ; argv[i]; ++i ) { if ( strcmp(argv[i], "-status") == 0 ) { /* PrintStatus(drive, cdrom); */ } else if ( strcmp(argv[i], "-list") == 0 ) { ListTracks(cdrom); } else if ( strcmp(argv[i], "-play") == 0 ) { int strack, sframe; int ntrack, nframe; strack = 0; if ( argv[i+1] && isdigit(argv[i+1][0]) ) { strack = atoi(argv[++i]); } sframe = 0; if ( argv[i+1] && isdigit(argv[i+1][0]) ) { sframe = atoi(argv[++i]); } ntrack = 0; if ( argv[i+1] && isdigit(argv[i+1][0]) ) { ntrack = atoi(argv[++i]); } nframe = 0; if ( argv[i+1] && isdigit(argv[i+1][0]) ) { nframe = atoi(argv[++i]); } if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { if ( SDL_CDPlayTracks(cdrom, strack, sframe, ntrack, nframe) < 0 ) { fprintf(stderr, "Couldn't play tracks %d/%d for %d/%d: %s\n", strack, sframe, ntrack, nframe, SDL_GetError()); } } else { fprintf(stderr, "No CD in drive!\n"); } } else if ( strcmp(argv[i], "-pause") == 0 ) { if ( SDL_CDPause(cdrom) < 0 ) { fprintf(stderr, "Couldn't pause CD: %s\n", SDL_GetError()); } } else if ( strcmp(argv[i], "-resume") == 0 ) { if ( SDL_CDResume(cdrom) < 0 ) { fprintf(stderr, "Couldn't resume CD: %s\n", SDL_GetError()); } } else if ( strcmp(argv[i], "-stop") == 0 ) { if ( SDL_CDStop(cdrom) < 0 ) { fprintf(stderr, "Couldn't eject CD: %s\n", SDL_GetError()); } } else if ( strcmp(argv[i], "-eject") == 0 ) { if ( SDL_CDEject(cdrom) < 0 ) { fprintf(stderr, "Couldn't eject CD: %s\n", SDL_GetError()); } } else if ( (strcmp(argv[i], "-sleep") == 0) && (argv[i+1] && isdigit(argv[i+1][0])) ) { SDL_Delay(atoi(argv[++i])); printf("Delayed %d milliseconds\n", atoi(argv[i])); } else { PrintUsage(argv[0]); SDL_CDClose(cdrom); quit(1); } } PrintStatus(drive, cdrom); SDL_CDClose(cdrom); SDL_Quit(); return(0); }
void CDAudio_SysShutdown (void) { if( cd ) SDL_CDClose( cd ); }
SdlAudioCDManager::~SdlAudioCDManager() { if (_cdrom) { SDL_CDStop(_cdrom); SDL_CDClose(_cdrom); } }
CDROM_Interface_SDL::~CDROM_Interface_SDL(void) { StopAudio(); SDL_CDClose(cd); cd = 0; };