]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.cxx
Remove dead code.
[simgear.git] / simgear / sound / soundmgr_openal.cxx
index 6fd7ce15302b6360ac37a25d6c125180ed2c034e..55647200f1679b56fdd5bc030762caebe80e0fd1 100644 (file)
@@ -111,7 +111,7 @@ SGSoundMgr::~SGSoundMgr() {
 // initialize the sound manager
 void SGSoundMgr::init(const char *devname) {
 
-    SG_LOG( SG_GENERAL, SG_INFO, "Initializing OpenAL sound manager" );
+    SG_LOG( SG_SOUND, SG_INFO, "Initializing OpenAL sound manager" );
 
     ALCdevice *device = alcOpenDevice(devname);
     if ( testForError(device, "Audio device not available, trying default") ) {
@@ -137,7 +137,7 @@ void SGSoundMgr::init(const char *devname) {
     }
 
     if (_context != NULL)
-        SG_LOG(SG_GENERAL, SG_ALERT, "context is already assigned");
+        SG_LOG(SG_SOUND, SG_ALERT, "context is already assigned");
     _context = context;
     _working = true;
 
@@ -184,7 +184,7 @@ void SGSoundMgr::init(const char *devname) {
     }
 
     if (_free_sources.size() == 0) {
-        SG_LOG(SG_GENERAL, SG_ALERT, "Unable to grab any OpenAL sources!");
+        SG_LOG(SG_SOUND, SG_ALERT, "Unable to grab any OpenAL sources!");
     }
 }
 
@@ -427,7 +427,7 @@ unsigned int SGSoundMgr::request_source()
        _sources_in_use.push_back(source);
     }
     else
-       SG_LOG( SG_GENERAL, SG_ALERT, "Sound manager: No more free sources available!\n");
+       SG_LOG( SG_SOUND, SG_BULK, "Sound manager: No more free sources available!\n");
 
     return source;
 }
@@ -480,9 +480,10 @@ unsigned int SGSoundMgr::request_buffer(SGSoundSample *sample)
               bool res = load(sample_name, &sample_data, &format, &size, &freq);
               if (res == false) return NO_BUFFER;
             } catch (sg_exception& e) {
-              SG_LOG(SG_GENERAL, SG_ALERT,
-                     "failed to load sound buffer:" << e.getFormattedMessage());
-              return NO_BUFFER;
+              SG_LOG(SG_SOUND, SG_ALERT,
+                    "failed to load sound buffer: " << e.getFormattedMessage());
+              sample->set_buffer( SGSoundMgr::FAILED_BUFFER );
+              return FAILED_BUFFER;
             }
             
             sample->set_frequency( freq );
@@ -618,6 +619,7 @@ bool SGSoundMgr::load(string &samplepath, void **dbuf, int *fmt,
 #endif
 
     if (format == AL_FORMAT_STEREO8 || format == AL_FORMAT_STEREO16) {
+        free(data);
         throw sg_io_exception("Warning: STEREO files are not supported for 3D audio effects: " + samplepath);
     }
 
@@ -659,7 +661,7 @@ vector<const char*> SGSoundMgr::get_available_devices()
 bool SGSoundMgr::testForError(void *p, string s)
 {
    if (p == NULL) {
-      SG_LOG( SG_GENERAL, SG_ALERT, "Error: " << s);
+      SG_LOG( SG_SOUND, SG_ALERT, "Error: " << s);
       return true;
    }
    return false;
@@ -670,7 +672,7 @@ bool SGSoundMgr::testForALError(string s)
 {
     ALenum error = alGetError();
     if (error != AL_NO_ERROR)  {
-       SG_LOG( SG_GENERAL, SG_ALERT, "AL Error (sound manager): "
+       SG_LOG( SG_SOUND, SG_ALERT, "AL Error (sound manager): "
                                       << alGetString(error) << " at " << s);
        return true;
     }
@@ -682,7 +684,7 @@ bool SGSoundMgr::testForALCError(string s)
     ALCenum error;
     error = alcGetError(_device);
     if (error != ALC_NO_ERROR) {
-        SG_LOG( SG_GENERAL, SG_ALERT, "ALC Error (sound manager): "
+        SG_LOG( SG_SOUND, SG_ALERT, "ALC Error (sound manager): "
                                        << alcGetString(_device, error) << " at "
                                        << s);
         return true;
@@ -696,7 +698,7 @@ bool SGSoundMgr::testForALUTError(string s)
     ALenum error;
     error =  alutGetError ();
     if (error != ALUT_ERROR_NO_ERROR) {
-        SG_LOG( SG_GENERAL, SG_ALERT, "ALUT Error (sound manager): "
+        SG_LOG( SG_SOUND, SG_ALERT, "ALUT Error (sound manager): "
                                        << alutGetErrorString(error) << " at "
                                        << s);
         return true;