Changeset 3889 in orxonox.OLD for orxonox/branches/sound_engine/src/lib
- Timestamp:
- Apr 19, 2005, 1:21:14 AM (20 years ago)
- Location:
- orxonox/branches/sound_engine/src/lib/sound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/sound_engine/src/lib/sound/sound_engine.cc
r3887 r3889 19 19 20 20 #include "sound_engine.h" 21 #include <SDL_mixer.h> 21 22 22 23 using namespace std; … … 28 29 { 29 30 this->setClassName ("SoundEngine"); 31 32 // preInit 30 33 this->isInit = false; 34 this->frequency = SOUND_DEFAULT_FREQUENCY; 35 this->format = MIX_DEFAULT_FORMAT; 36 this->channels = SOUND_DEFAULT_CHANNELS; 37 this->buffers = SOUND_DEFAULT_BUFIZE; 38 31 39 this->enableSound(); 32 40 } 33 41 34 //! brief the singleton reference to this class 42 /** 43 \brief the singleton reference to this class 44 */ 35 45 SoundEngine* SoundEngine::singletonRef = NULL; 36 46 … … 63 73 { 64 74 if (!this->isInit) 65 if (SDL_Init(SDL_INIT_AUDIO)) 66 { 67 PRINTF(1)("SDL-sound could not be initialized\n"); 68 return; 69 } 70 this->isInit = true; 75 { 76 if (SDL_Init(SDL_INIT_AUDIO) == -1) 77 { 78 PRINTF(1)("SDL-sound could not be initialized\nSDL_Init: %s\n", SDL_GetError()); 79 return; 80 } 81 else 82 { 83 this->isInit = true; 84 85 // checking if the mode is supported 86 Mix_QuerySpec(&this->frequency, &this->format, &this->channels); 87 88 this->bits = this->format & 0xFF; 89 PRINTF(3)("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", 90 this->frequency, this->bits, this->channels > 1 ? "stereo" : "mono", this->buffers); 91 Mix_VolumeMusic(this->volume); 92 93 if(Mix_OpenAudio(this->frequency, this->format, this->channels, this->buffers) == -1) 94 PRINTF(1)("Mix_OpenAudio: %s\n", Mix_GetError()); 95 } 96 97 98 } 71 99 } 72 100 … … 78 106 if (this->isInit) 79 107 { 80 SDL_QuitSubSystem(SDL_INIT_AUDIO);108 Mix_CloseAudio(); 81 109 } 82 110 else -
orxonox/branches/sound_engine/src/lib/sound/sound_engine.h
r3887 r3889 25 25 #include <SDL_mixer.h> 26 26 27 #define SOUND_DEFAULT_FREQUENCY 44100 28 #define SOUND_DEFAULT_CHANNELS 2 29 #define SOUND_DEFAULT_BUFIZE 16384 30 27 31 // FORWARD DEFINITION 28 32 … … 44 48 static bool checkVersion(void); 45 49 50 51 // settings 52 int volume; 53 54 // audio specifications 55 int frequency; 56 Uint16 format; 57 int channels; 58 int bits; 59 int buffers; 60 46 61 bool isInit; 47 62 };
Note: See TracChangeset
for help on using the changeset viewer.