void free_level( void ) { gem_points = game_state = 0; game_time = 0.0f; unsigned int i = 0; /* Pause the thread, because we donÕt want the process to * continue to decompress while we are trying to free the background music. * That would make the app to crash for sure. */ THREAD_pause( thread ); /* Free the background sound source. */ background_sound = SOUND_free( background_sound ); /* Because the background music was streamed, free the sound buffer from the local memory structure. */ background_soundbuffer->memory = mclose( background_soundbuffer->memory ); /* It is now okay to free the sound buffer. */ background_soundbuffer = SOUNDBUFFER_free( background_soundbuffer ); while( i != 4 ) { /* Free the sound source and the associated buffer. */ gems_sound[ i ] = SOUND_free( gems_sound[ i ] ); gems_soundbuffer[ i ] = SOUNDBUFFER_free( gems_soundbuffer[ i ] ); ++i; } /* Now deal with the water, lava, and toxic stuff sound sources and buffers. */ water_sound = SOUND_free( water_sound ); water_soundbuffer = SOUNDBUFFER_free( water_soundbuffer ); lava_sound = SOUND_free( lava_sound ); lava_soundbuffer = SOUNDBUFFER_free( lava_soundbuffer ); toxic_sound = SOUND_free( toxic_sound ); toxic_soundbuffer = SOUNDBUFFER_free( toxic_soundbuffer ); player = NULL; THREAD_pause( thread ); font_small = FONT_free( font_small ); font_big = FONT_free( font_big ); free_physic_world(); obj = OBJ_free( obj ); }
void free_level( void ) { gem_points = game_state = 0; game_time = 0.0f; unsigned int i = 0; THREAD_pause( thread ); background_sound = SOUND_free( background_sound ); background_soundbuffer->memory = mclose( background_soundbuffer->memory ); background_soundbuffer = SOUNDBUFFER_free( background_soundbuffer ); while( i != 4 ) { gems_sound[ i ] = SOUND_free( gems_sound[ i ] ); gems_soundbuffer[ i ] = SOUNDBUFFER_free( gems_soundbuffer[ i ] ); ++i; } water_sound = SOUND_free( water_sound ); water_soundbuffer = SOUNDBUFFER_free( water_soundbuffer ); lava_sound = SOUND_free( lava_sound ); lava_soundbuffer = SOUNDBUFFER_free( lava_soundbuffer ); toxic_sound = SOUND_free( toxic_sound ); toxic_soundbuffer = SOUNDBUFFER_free( toxic_soundbuffer ); player = NULL; THREAD_pause( thread ); font_small = FONT_free( font_small ); font_big = FONT_free( font_big ); free_physic_world(); obj = OBJ_free( obj ); }