D:/Programmation/Cpp/SFML/src/SFML/Audio/OpenAL.hpp

00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_OPENAL_HPP
00026 #define SFML_OPENAL_HPP
00027 
00029 // Headers
00031 #include <al.h>
00032 #include <alc.h>
00033 #include <iostream>
00034 #include <string>
00035 
00036 
00037 namespace sf_private
00038 {
00044 #ifdef SFML_DEBUG
00045 
00046     // If in debug mode, perform a test on every call
00047     #define sfALCheck(Func) ((Func), sf_private::sfALCheckError())
00048 
00049 #else
00050 
00051     // Else, we don't add any overhead
00052     #define sfALCheck(Func) (Func)
00053 
00054 #endif
00055 
00056 
00061 inline void sfALCheckError()
00062 {
00063     // Get the last error
00064     ALenum ErrorCode = alGetError();
00065 
00066     if (ErrorCode != AL_NO_ERROR)
00067     {
00068         std::string Error, Desc;
00069 
00070         // Decode the error code
00071         switch (ErrorCode)
00072         {
00073             case AL_INVALID_NAME :
00074             {
00075                 Error = "AL_INVALID_NAME";
00076                 Desc  = "an unacceptable name has been specified";
00077                 break;
00078             }
00079 
00080             case AL_INVALID_ENUM :
00081             {
00082                 Error = "AL_INVALID_ENUM";
00083                 Desc  = "an unacceptable value has been specified for an enumerated argument";
00084                 break;
00085             }
00086 
00087             case AL_INVALID_VALUE :
00088             {
00089                 Error = "AL_INVALID_VALUE";
00090                 Desc  = "a numeric argument is out of range";
00091                 break;
00092             }
00093 
00094             case AL_INVALID_OPERATION :
00095             {
00096                 Error = "AL_INVALID_OPERATION";
00097                 Desc  = "the specified operation is not allowed in the current state";
00098                 break;
00099             }
00100 
00101             case AL_OUT_OF_MEMORY :
00102             {
00103                 Error = "AL_OUT_OF_MEMORY";
00104                 Desc  = "there is not enough memory left to execute the command";
00105                 break;
00106             }
00107         }
00108 
00109         // Log the error
00110         std::cerr << "An internal OpenAL call failed "
00111                   << "("  << Error << " : " << Desc << ")"
00112                   << std::endl;
00113     }
00114 }
00115 
00116 } // namespace sf_private
00117 
00118 #endif // SFML_OPENAL_HPP

Generated for SFML by  doxygen 1.5.2