diff options
Diffstat (limited to 'tests/freealut/src/alutError.c')
-rw-r--r-- | tests/freealut/src/alutError.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/tests/freealut/src/alutError.c b/tests/freealut/src/alutError.c new file mode 100644 index 00000000..57e29575 --- /dev/null +++ b/tests/freealut/src/alutError.c @@ -0,0 +1,92 @@ +#include "alutInternal.h" +#include <stdio.h> + +static ALenum lastError = ALUT_ERROR_NO_ERROR; + +void _alutSetError(ALenum err) +{ + /* print a message to stderr if ALUT_DEBUG environment variable is defined */ + if (getenv("ALUT_DEBUG")) + { + fprintf(stderr, "ALUT error: %s\n", alutGetErrorString(err)); + } + + if (lastError == ALUT_ERROR_NO_ERROR) + { + lastError = err; + } +} + +ALenum alutGetError(void) +{ + ALint ret = lastError; + + lastError = ALUT_ERROR_NO_ERROR; + return ret; +} + +const char *alutGetErrorString(ALenum error) +{ + switch (error) + { + case ALUT_ERROR_NO_ERROR: + return "No ALUT error found"; + + case ALUT_ERROR_OUT_OF_MEMORY: + return "ALUT ran out of memory"; + + case ALUT_ERROR_INVALID_ENUM: + return "ALUT was given an invalid enumeration token"; + + case ALUT_ERROR_INVALID_VALUE: + return "ALUT was given an invalid value"; + + case ALUT_ERROR_INVALID_OPERATION: + return "The operation was invalid in the current ALUT state"; + + case ALUT_ERROR_NO_CURRENT_CONTEXT: + return "There is no current AL context"; + + case ALUT_ERROR_AL_ERROR_ON_ENTRY: + return "There was already an AL error on entry to an ALUT function"; + + case ALUT_ERROR_ALC_ERROR_ON_ENTRY: + return "There was already an ALC error on entry to an ALUT function"; + + case ALUT_ERROR_OPEN_DEVICE: + return "There was an error opening the ALC device"; + + case ALUT_ERROR_CLOSE_DEVICE: + return "There was an error closing the ALC device"; + + case ALUT_ERROR_CREATE_CONTEXT: + return "There was an error creating an ALC context"; + + case ALUT_ERROR_MAKE_CONTEXT_CURRENT: + return "Could not change the current ALC context"; + + case ALUT_ERROR_DESTROY_CONTEXT: + return "There was an error destroying the ALC context"; + + case ALUT_ERROR_GEN_BUFFERS: + return "There was an error generating an AL buffer"; + + case ALUT_ERROR_BUFFER_DATA: + return "There was an error passing buffer data to AL"; + + case ALUT_ERROR_IO_ERROR: + return "I/O error"; + + case ALUT_ERROR_UNSUPPORTED_FILE_TYPE: + return "Unsupported file type"; + + case ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE: + return "Unsupported mode within an otherwise usable file type"; + + case ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA: + return "The sound data was corrupt or truncated"; + + default: + return "An impossible ALUT error condition was reported?!?"; + } +} |