00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #ifndef SFML_OPENAL_HPP
00026 #define SFML_OPENAL_HPP
00027
00029
00031 #include <SFML/Config.hpp>
00032 #include <AL/al.h>
00033 #include <AL/alc.h>
00034 #include <iostream>
00035 #include <string>
00036
00037
00038 namespace sf
00039 {
00040 namespace priv
00041 {
00047 #ifdef SFML_DEBUG
00048
00049
00050 #define ALCheck(Func) ((Func), priv::ALCheckError(__FILE__, __LINE__))
00051
00052 #else
00053
00054
00055 #define ALCheck(Func) (Func)
00056
00057 #endif
00058
00059
00064 inline void ALCheckError(const std::string File, unsigned int Line)
00065 {
00066
00067 ALenum ErrorCode = alGetError();
00068
00069 if (ErrorCode != AL_NO_ERROR)
00070 {
00071 std::string Error, Desc;
00072
00073
00074 switch (ErrorCode)
00075 {
00076 case AL_INVALID_NAME :
00077 {
00078 Error = "AL_INVALID_NAME";
00079 Desc = "an unacceptable name has been specified";
00080 break;
00081 }
00082
00083 case AL_INVALID_ENUM :
00084 {
00085 Error = "AL_INVALID_ENUM";
00086 Desc = "an unacceptable value has been specified for an enumerated argument";
00087 break;
00088 }
00089
00090 case AL_INVALID_VALUE :
00091 {
00092 Error = "AL_INVALID_VALUE";
00093 Desc = "a numeric argument is out of range";
00094 break;
00095 }
00096
00097 case AL_INVALID_OPERATION :
00098 {
00099 Error = "AL_INVALID_OPERATION";
00100 Desc = "the specified operation is not allowed in the current state";
00101 break;
00102 }
00103
00104 case AL_OUT_OF_MEMORY :
00105 {
00106 Error = "AL_OUT_OF_MEMORY";
00107 Desc = "there is not enough memory left to execute the command";
00108 break;
00109 }
00110 }
00111
00112
00113 std::cerr << "An internal OpenAL call failed in "
00114 << File.substr(File.find_last_of("\\/") + 1) << " (" << Line << ") : "
00115 << Error << ", " << Desc
00116 << std::endl;
00117 }
00118 }
00119
00120 }
00121
00122 }
00123
00124
00125 #endif // SFML_OPENAL_HPP