+#else
+ ALbyte *fname = (ALbyte *)samplepath.c_str();
+# if defined (__APPLE__)
+ alutLoadWAVFile( fname, &format, &data, &size, &freq );
+# else
+ ALboolean loop;
+ alutLoadWAVFile( fname, &format, &data, &size, &freq, &loop );
+# endif
+ ALenum error = alutGetError();
+ if ( error != ALUT_ERROR_NO_ERROR ) {
+ string msg = "Failed to load wav file: ";
+ msg.append(alutGetErrorString(error));
+ throw sg_io_exception(msg.c_str(), sg_location(samplepath));
+ return false;
+ }
+#endif
+
+ *dbuf = (void *)data;
+ *fmt = (int)format;
+ *sz = (unsigned int)size;
+ *frq = (int)freq;
+
+ return true;
+}
+
+
+bool SGSoundMgr::testForError(void *p, string s)
+{
+ if (p == NULL) {
+ SG_LOG( SG_GENERAL, SG_ALERT, "Error: " << s);
+ return true;
+ }
+ return false;
+}
+
+
+bool SGSoundMgr::testForALError(string s)
+{
+ ALenum error = alGetError();
+ if (error != AL_NO_ERROR) {
+ SG_LOG( SG_GENERAL, SG_ALERT, "AL Error (sound manager): "
+ << alGetString(error) << " at " << s);
+ return true;
+ }
+ return false;
+}
+
+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): "
+ << alcGetString(_device, error) << " at "
+ << s);
+ return true;