int main (int argc, char * argv[]) { //#define CHECK_CDROM 1 #ifdef CHECK_CDROM SDL_Init(SDL_INIT_CDROM); std::cout << SDL_CDNumDrives() << " CD- / DVD-ROM drives available." << std::endl; for (int i = 0; i < SDL_CDNumDrives(); i++ ) { std::cout << i << ". " << SDL_CDName(i) << std::endl; } #else SDL_Init(0); #endif while (!app_exit) { SDL_InitSubSystem(SDL_INIT_VIDEO); SDL_Surface * screen; screen = NULL; set_context(screen, context_config[0], // w context_config[1], // h context_config[2], // fullscreen context_config[3], // framebuffer size context_config[4], // multisamples context_config[5], // multisample buffer context_config[6], // bpp context_config[7] // depthbuffer size ); Application app; app.initialize(context_config); if (argc > 1) { app.load_scene(scene_config, argv[1]); } else { app.load_scene(scene_config, "testFile.bullet"); } app.run(&app_exit); app.close_scene(); app.close(); SDL_FreeSurface(screen); screen = NULL; SDL_QuitSubSystem(SDL_INIT_VIDEO); } SDL_Quit(); std::cout << "main() quit" << std::endl; return 0; }
/* C API */ PyObject* PyCD_New (int _index) { PyCD *cd; SDL_CD *cdrom; ASSERT_CDROM_INIT(NULL); if (_index < 0 || _index > SDL_CDNumDrives ()) { PyErr_SetString (PyExc_ValueError, "invalid cdrom drive index"); return NULL; } cd = (PyCD*) PyCD_Type.tp_new (&PyCD_Type, NULL, NULL); if (!cd) return NULL; cdrom = SDL_CDOpen (_index); if (!cdrom) { Py_DECREF (cd); PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return NULL; } cd->cd = cdrom; cd->index = _index; cdrommod_add_drive (_index, cdrom); return (PyObject*) cd; }
static int _cd_init (PyObject *self, PyObject *args, PyObject *kwds) { int _index; SDL_CD *cd; ASSERT_CDROM_INIT(-1); if (!PyArg_ParseTuple (args, "i", &_index)) return -1; if (_index < 0 || _index > SDL_CDNumDrives ()) { PyErr_SetString (PyExc_ValueError, "invalid cdrom drive index"); return -1; } cd = SDL_CDOpen (_index); if (!cd) { PyErr_SetString (PyExc_PyGameError, SDL_GetError ()); return -1; } ((PyCD*)self)->cd = cd; ((PyCD*)self)->index = _index; cdrommod_add_drive (_index, cd); return 0; }
//------------------------------------------------------------------------------ void InstallRedBookDevices() { #if !defined(__FreeBSD__) Con::printf("CD Audio Init:"); if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1) { Con::printf(" Unable to initialize CD Audio: %s", SDL_GetError()); return; } S32 numDrives = SDL_CDNumDrives(); if (numDrives == 0) { Con::printf(" No drives found."); return; } for (int i = 0; i < numDrives; ++i) { const char * deviceName = SDL_CDName(i); Con::printf(" Installing CD Audio device: %s", deviceName); UnixRedBookDevice * device = new UnixRedBookDevice; device->setDeviceInfo(i, deviceName); RedBook::installDevice(device); } Con::printf(" "); #endif // !defined(__FreeBSD__) }
void SDL::printSystemInfo() { // Getting Video Driver information char namebuf[255]; SDL_VideoDriverName(namebuf, 254); Log::log("Video Driver: " + std::string(namebuf)); // Getting Joystick information int num = SDL_NumJoysticks(); Log::log("There are " + SDL::intToString(num) + " Joystick(s) currently available."); for (int i = 0; i < num; i++) Log::log("Joystick no " + SDL::intToString(i + 1) + ": " + std::string(SDL_JoystickName(i))); // Getting CD-ROM information num = SDL_CDNumDrives(); Log::log("There are " + SDL::intToString(num) + " CD-ROM Drive(s) currently available."); for (int i = 0; i < num; i++) Log::log("CD-ROM Drive no " + SDL::intToString(i + 1) + ": " + std::string(SDL_CDName(i))); }
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 CDROM_GetMountType(char* path, int forceCD) // 0 - physical CDROM // 1 - Iso file // 2 - subdirectory { // 1. Smells like a real cdrom // if ((strlen(path)<=3) && (path[2]=='\\') && (strchr(path,'\\')==strrchr(path,'\\')) && (GetDriveType(path)==DRIVE_CDROM)) return 0; const char* cdName; char buffer[512]; strcpy(buffer,path); #if defined (WIN32) || defined(OS2) upcase(buffer); #endif int num = SDL_CDNumDrives(); // If cd drive is forced then check if its in range and return 0 if ((forceCD>=0) && (forceCD<num)) { LOG(LOG_ALL,LOG_ERROR)("CDROM: Using drive %d",forceCD); return 0; } // compare names for (int i=0; i<num; i++) { cdName = SDL_CDName(i); if (strcmp(buffer,cdName)==0) return 0; }; // Detect ISO struct stat file_stat; if ((stat(path, &file_stat) == 0) && S_ISREG(file_stat.st_mode)) return 1; return 2; };
void RBAInit() { if (initialised) return; if (FindArg("-nocdrom")) return; if (SDL_Init(SDL_INIT_CDROM) < 0) { Warning("SDL library initialisation failed: %s.",SDL_GetError()); return; } if (SDL_CDNumDrives() == 0) { Warning("No cdrom drives found!\n"); return; } s_cd = SDL_CDOpen(0); if (s_cd == NULL) { Warning("Could not open cdrom for redbook audio!\n"); return; } SDL_CDStatus(s_cd); /* update the drive status */ atexit(RBAExit); 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 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; } }
bool CDROM_Interface_SDL::SetDevice (char* path, int forceCD) { char buffer[512]; strcpy(buffer,path); upcase(buffer); int num = SDL_CDNumDrives(); if ((forceCD>=0) && (forceCD<num)) { driveID = forceCD; cd = SDL_CDOpen(driveID); SDL_CDStatus(cd); return true; }; const char* cdname = 0; for (int i=0; i<num; i++) { cdname = SDL_CDName(i); if (strcmp(buffer,cdname)==0) { cd = SDL_CDOpen(i); SDL_CDStatus(cd); driveID = i; return true; }; }; return false; };
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; }
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 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(); }
int main (int argc, char *argv[]) { int i; [+IF (=(get "HaveSDL_net") "1")+] IPaddress local = {0x0100007F, 0x50}; [+ENDIF+] printf ("Initializing SDL.\n"); /* Initializes Audio and the CDROM, add SDL_INIT_VIDEO for Video */ if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_CDROM)< 0) { printf("Could not initialize SDL:%s\n", SDL_GetError()); SDL_Quit(); return 1; } printf("Audio & CDROM initialized correctly\n"); /* Trying to read number of CD devices on system */ printf("Drives available: %d\n", SDL_CDNumDrives()); for (i=0; i < SDL_CDNumDrives(); ++i) { printf("Drive %d\"%s\"\n", i, SDL_CDName(i)); } [+IF (=(get "HaveSDL_net") "1")+] if (SDLNet_Init() < 0) { printf("Could not initialize SDL_net:%s\n", SDLNet_GetError()); SDL_Quit(); return 1; } printf("\n\nNetwork initialized correctly\n"); /* Get host name */ printf("Hostname: %s\n", SDLNet_ResolveIP(&local)); SDLNet_Quit(); [+ENDIF+] SDL_Quit(); return(0); }
static int modcd_name( INSTANCE * my, int * params ) { int result; if ( params[0] < 0 || params[0] >= SDL_CDNumDrives() ) return 0; result = string_new( SDL_CDName( params[0] ) ); string_use( result ); return result; }
vector< shared_ptr<Cdrom> > Cdrom::Enumerate() { vector< shared_ptr<Cdrom> > cdroms; for (int i=0, N=SDL_CDNumDrives(); i<N; i++) { cdroms.push_back(shared_ptr<Cdrom>(new Cdrom(i))); } return cdroms; }
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 SoundManager::InitRedbook() { #if defined(USE_SDL) if (!m_cdrom) { int errcode = SDL_Init(SDL_INIT_CDROM | m_SDLInitFlags); Assert(0 == errcode); if (errcode < 0) { return; } int numDrives = SDL_CDNumDrives(); Assert(numDrives >= 0); int drive = -1; int i = 0; // Hack: We don't have the num of the SDL drive stored, // so we search for the drive with the drive letter stored MBCHAR driveLetter = toupper(c3files_GetCtpCdId()); while ((i < numDrives) && (-1 == drive)) { const char *cd_name = SDL_CDName(i); if (cd_name) { if (toupper(cd_name[0]) == driveLetter) { drive = i; } } i++; } // No drive match?! if (drive < 0) { return; } m_cdrom = SDL_CDOpen(drive); Assert(m_cdrom != 0); // No control structur? if (m_cdrom) { CDstatus status = SDL_CDStatus(m_cdrom); } } #else // !USE_SDL if (!m_redbook) { m_redbook = AIL_redbook_open_drive(c3files_GetCtpCdId()); } #endif // USE_SDL }
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; }
void RBAInit() { int d, i, j; char szDrive [FILENAME_LEN], sz [FILENAME_LEN]; if (initialised) return; if (FindArg("-nocdrom")) return; if (SDL_Init(SDL_INIT_CDROM) < 0) { Warning(TXT_SDL_INIT_LIB,SDL_GetError()); return; } if ((j = SDL_CDNumDrives()) == 0) { Warning(TXT_CDROM_NONE); return; } d = 0; if ((i = FindArg ("-cdrom")) && *Args [++i]) { #ifdef _WIN32 sprintf (szDrive, "%c:\\", *Args [i]); #else strncpy (szDrive, Args [i], sizeof (szDrive)); #endif strlwr (szDrive); for (i = 0; i < j; i++) { strcpy (sz, SDL_CDName (i)); strlwr (sz); if (!strcmp (szDrive, sz)) { d = i; break; } } } if (!(s_cd = SDL_CDOpen(d))) { Warning(TXT_CDROM_OPEN); return; } atexit(RBAExit); initialised = 1; }
static PyObject* PyCD_New (int id) { PyCDObject* cd; 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; } cd->id = id; return (PyObject*)cd; }
bool CDROM_Interface_SDL::SetDevice(char* path, int forceCD) { char buffer[512]; strcpy(buffer,path); upcase(buffer); int num = SDL_CDNumDrives(); if ((forceCD>=0) && (forceCD<num)) { driveID = forceCD; //--Added 2009-12-31 by Alun Bestor: shut down and restart the CDROM subsystem to reset SDL's //cached file information about the CD-ROM volumes //This is needed otherwise SDL persists invalid file pointers to the CD-ROM and its tracks, //way to go guys SDL_QuitSubSystem(SDL_INIT_CDROM); SDL_Init(SDL_INIT_CDROM); //--End of modifications cd = SDL_CDOpen(driveID); SDL_CDStatus(cd); return true; }; const char* cdname = 0; for (int i=0; i<num; i++) { cdname = SDL_CDName(i); if (strcmp(buffer,cdname)==0) { //--Added 2009-12-31 by Alun Bestor: shut down and restart the CDROM subsystem to reset SDL's //cached file information about the CD-ROM volumes //This is needed otherwise SDL persists invalid file pointers to the CD-ROM and its tracks, //way to go guys SDL_QuitSubSystem(SDL_INIT_CDROM); SDL_Init(SDL_INIT_CDROM); //--End of modifications cd = SDL_CDOpen(i); SDL_CDStatus(cd); driveID = i; return true; }; }; return false; }
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); }
static int modcd_drives( INSTANCE * my, int * params ) { return SDL_CDNumDrives(); }
int CDAudio_Init(void) { int i, x, sdl_num_drives; if (safemode || COM_CheckParm("-nocdaudio")) return -1; if (SDL_InitSubSystem(SDL_INIT_CDROM) < 0) { Con_Printf("Couldn't init SDL cdrom: %s\n", SDL_GetError()); return -1; } sdl_num_drives = SDL_CDNumDrives (); Con_Printf ("SDL detected %d CD-ROM drive%c\n", sdl_num_drives, sdl_num_drives == 1 ? ' ' : 's'); if (sdl_num_drives < 1) return -1; if ((i = COM_CheckParm("-cddev")) != 0 && i < com_argc - 1) { for (x = 0; x < sdl_num_drives; x++) { if (!q_strcasecmp(SDL_CDName(x), com_argv[i+1])) { cd_dev = x; break; } } if (cd_dev == -1) { Con_Printf("SDL couldn't find cdrom device %s\n", com_argv[i+1]); return -1; } } if (cd_dev == -1) cd_dev = 0; // default drive cd_handle = SDL_CDOpen(cd_dev); if (!cd_handle) { Con_Printf ("%s: Unable to open CD-ROM drive %s (%s)\n", __thisfunc__, SDL_CDName(cd_dev), SDL_GetError()); return -1; } for (i = 0; i < 100; i++) remap[i] = i; enabled = true; old_cdvolume = bgmvolume.value; Con_Printf("CDAudio initialized (SDL, using %s)\n", SDL_CDName(cd_dev)); if (CDAudio_GetAudioDiskInfo()) { Con_Printf("%s: No CD in drive\n", __thisfunc__); cdValid = false; } Cmd_AddCommand ("cd", CD_f); // cd hardware volume: no SDL support at present. hw_vol_works = CD_GetVolume (NULL); if (hw_vol_works) hw_vol_works = CDAudio_SetVolume (&bgmvolume); return 0; }
static PyObject* get_count (PyObject* self) { CDROM_INIT_CHECK (); return PyInt_FromLong (SDL_CDNumDrives ()); }