int main(void) { char * audioFile = "inmysong.wav"; PlayAudioFile(audioFile); getchar(); return 0; }
/* * Removes the last planet from planetsList */ void RemoveLastPlanet() { if(numberOfPlanets > 0) { deletePlanet(planetsList[numberOfPlanets-1]); numberOfPlanets--; if(numberOfPlanets != 0) //Because segfault if realloced to 0 planetsList = realloc(planetsList, sizeof(struct PlanetStruct)*numberOfPlanets); PlayAudioFile(deletePlanetNoise); } }
static void * TimerThread( /*@unused@*/ void *arg ) { int new_messages = 0; int counter = -1; bool animation_running = false; /* For catching the signal SIGUSR1. This signal is sent by the main program thread when the * user is issuing a single-click to manually check for new mails. */ (void) signal( SIGUSR1, CatchTimerSignal ); /* For catching the signal SIGUSR2. This signal is sent by the main program thread when the * user is issuing a double-click to start ther external mail client. */ (void) signal( SIGUSR2, CatchTimerSignal ); while( quit == false ) { if( wmnotify_infos.debug ) { printf( "%s: Timer thread iteration.\n", PACKAGE ); } if( ( manual_check == true ) || ( counter == 0 ) ) { new_messages = CheckForNewMail( manual_check ); manual_check = false; if( wmnotify_infos.debug ) { printf( "%s: new messages = %d.\n", PACKAGE, new_messages ); } if( new_messages > 0 ) { /* Checking if audio notification was already produced. */ if( animation_running == false ) { /* Audible notification, if requested in configuration file. */ if( wmnotify_infos.audible_notification != false ) { if( strlen( wmnotify_infos.audiofile ) != 0 ) { #if defined(HAVE_SNDFILE) PlayAudioFile( wmnotify_infos.audiofile, wmnotify_infos.volume ); #endif } else { AudibleBeep(); } } animation_running = true; } /* Number of times to execute timer loop before checking again for new mails when the * animation is running (when the animation is running, we sleep for * NEW_MAIL_ANIMATION_DURATION instead of wmnotify_infos.mail_check_interval). We set * the check interval to 30 seconds because we want the new mail condition to be * removed as soon as possible when the new messages are checked. */ counter = 30 * 1000000 / NEW_MAIL_ANIMATION_DURATION; } } if( ( animation_stop == true ) || ( new_messages <= 0 ) ) { if( wmnotify_infos.debug ) { if( animation_stop != false ) { printf( "%s: animation_stop is true\n", PACKAGE ); } } animation_running = false; animation_stop = false; if( double_click_notif == false ) { /* Before exiting, be sure to put NO MAIL image back in place... */ DisplayClosedMailbox(); } } /* If sleep() returns because the requested time has elapsed, the value returned will be * 0. If sleep() returns because of premature arousal due to delivery of a signal, the * return value will be the "unslept" amount (the requested time minus the time actually * slept) in seconds. */ if( animation_running == false ) { (void) sleep( wmnotify_infos.mail_check_interval ); counter = 0; } else { NewMailAnimation(); (void) usleep( NEW_MAIL_ANIMATION_DURATION ); counter--; } if( wmnotify_infos.debug ) { printf( "%s: counter = %d\n", PACKAGE, counter ); } } /* end while */ if( wmnotify_infos.debug ) { printf( "%s: Error, TimerThread() exited abnormally\n", PACKAGE ); } /* This code is never reached for now, because quit is always false. */ pthread_exit( NULL ); }
/* * Creates a new planet and appends it to planetsList */ void CreatePlanet(struct PlanetStruct planet, GLuint playSound) { if(numberOfPlanets < maxNumberOfPlanets || maxNumberOfPlanets == 0) { numberOfPlanets++; planetsList = realloc(planetsList, sizeof(struct PlanetStruct)*numberOfPlanets); planet.startingPosition = planet.center; planet.timeOfCreation = glutGet(GLUT_ELAPSED_TIME); planet.upVec = SetVector(0,1,0); planet.frontVec = SetVector(0,0,1); mat4 terrainTransformationMatrix[6]; TextureData* terrainTextures[6]; CreateCubeHeightMaps(terrainTextures, terrainTransformationMatrix, &planet); //Generate terrain /* TextureData* tex = chkmalloc(sizeof(TextureData)); GenerateProceduralTerrainTexture(256, tex); terrainTextures[0] = tex;*/ GLuint i; for(i = 0; i < 6; i++) { planet.terrainModels[i] = GenerateTerrainModelSimple(terrainTextures[i], planet.textureScale); switch(planet.type) { case SMOOTH_PLANET: planet.terrainModels[i] = MapToFlatSphere(planet, terrainTransformationMatrix, terrainTextures[i], i); break; case ROUGH_PLANET: planet.terrainModels[i] = MapToSphere(planet, terrainTransformationMatrix, terrainTextures[i], i); break; case CUBE_PLANET: planet.terrainModels[i] = MapToCube(planet, terrainTransformationMatrix, terrainTextures[i], i); break; default: fprintf(stderr, "Unknown planet type"); } deleteTexture(terrainTextures[i]); //Dont need them in memory anymore, free properly } planet.ModelToWorldMatrix = T(planet.center.x, planet.center.y, planet.center.z); planetsList[numberOfPlanets-1] = planet; //Decide if/what sound to play if(playSound != NO_SOUND) PlayAudioFile(createPlanetNoise); printf("Let there be light!\n"); } else { //Play fail noise? fprintf(stderr, "Max number of planets reached\n"); } }