Changeset 536
- Timestamp:
- Apr 23, 2011, 12:48:41 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/sdlport/sound.cpp
r534 r536 69 69 }; 70 70 71 #ifndef USE_SDL_MIXER 71 72 static effect_handle * fx_list = NULL; 73 #endif 72 74 extern flags_struct flags; 73 75 static int sound_enabled = 0; … … 121 123 int sound_init( int argc, char **argv ) 122 124 { 123 SDL_AudioSpec audioWanted;124 125 char *sfxdir, *datadir; 125 126 FILE *fd = NULL; … … 129 130 { 130 131 // User requested that sound be disabled 131 printf( "Sound 132 printf( "Sound: Disabled (-nosound)\n" ); 132 133 return 0; 133 134 } … … 140 141 { 141 142 // Didn't find the directory, so disable sound. 142 printf( "Sound 143 printf( "Sound: Disabled (couldn't find the sfx directory)\n" ); 143 144 return 0; 144 145 } … … 148 149 if (Mix_OpenAudio(11025, AUDIO_U8, 2, 128) < 0) 149 150 { 150 printf( "Sound : Unable to open audio - %s\nSound: Disabled (error)\n", SDL_GetError() );151 printf( "Sound: Unable to open audio - %s\nSound: Disabled (error)\n", SDL_GetError() ); 151 152 return 0; 152 153 } … … 159 160 160 161 sound_enabled = SFX_INITIALIZED | MUSIC_INITIALIZED; 161 #else 162 163 printf( "Music: Enabled\n" ); 164 #else 165 SDL_AudioSpec audioWanted; 162 166 audioWanted.freq = 11025; 163 167 audioWanted.format = AUDIO_U8; … … 170 174 if( SDL_OpenAudio( &audioWanted, &audioObtained ) < 0 ) 171 175 { 172 printf( "Sound : Unable to open audio - %s\nSound: Disabled (error)\n", SDL_GetError() );176 printf( "Sound: Unable to open audio - %s\nSound: Disabled (error)\n", SDL_GetError() ); 173 177 return 0; 174 178 } … … 179 183 #endif 180 184 181 printf( "Sound 185 printf( "Sound: Enabled\n" ); 182 186 183 187 // It's all good … … 299 303 if( fx_list == NULL ) 300 304 { 301 printf( "Sound 305 printf( "Sound: ERROR - Failed to create new effect.\n" ); 302 306 SDL_UnlockAudio(); 303 307 return; … … 361 365 // Play music using SDL_Mixer 362 366 363 song::song( char const * filename)367 song::song(char const * filename) 364 368 { 365 369 data = NULL; … … 378 382 data = load_hmi(realname, data_size); 379 383 380 if (data) 381 { 382 rw = SDL_RWFromMem(data, data_size); 383 music = Mix_LoadMUS_RW(rw); 384 if (!data) 385 { 386 printf("Music: ERROR - could not load %s\n", realname); 387 return; 388 } 389 390 rw = SDL_RWFromMem(data, data_size); 391 music = Mix_LoadMUS_RW(rw); 392 393 if (!music) 394 { 395 printf("Music: ERROR - %s while loading %s\n", 396 Mix_GetError(), realname); 397 return; 384 398 } 385 399 #endif … … 388 402 song::~song() 389 403 { 390 if( playing() ) 391 { 404 if(playing()) 392 405 stop(); 393 } 394 if( data ) 395 { 396 free( data ); 397 } 398 free( Name ); 399 400 #ifdef USE_SDL_MIXER 401 Mix_FreeMusic(this->music); 402 SDL_FreeRW(this->rw); 406 free(data); 407 free(Name); 408 409 #ifdef USE_SDL_MIXER 410 Mix_FreeMusic(music); 411 SDL_FreeRW(rw); 403 412 #endif 404 413 }
Note: See TracChangeset
for help on using the changeset viewer.