[14] | 1 | #include "alutInternal.h" |
---|
| 2 | #include <stdio.h> |
---|
| 3 | |
---|
| 4 | static ALenum lastError = ALUT_ERROR_NO_ERROR; |
---|
| 5 | |
---|
| 6 | void |
---|
| 7 | _alutSetError (ALenum err) |
---|
| 8 | { |
---|
| 9 | /* print a message to stderr if ALUT_DEBUG environment variable is defined */ |
---|
| 10 | if (getenv ("ALUT_DEBUG")) |
---|
| 11 | { |
---|
| 12 | fprintf (stderr, "ALUT error: %s\n", alutGetErrorString (err)); |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | if (lastError == ALUT_ERROR_NO_ERROR) |
---|
| 16 | { |
---|
| 17 | lastError = err; |
---|
| 18 | } |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | ALenum |
---|
| 22 | alutGetError (void) |
---|
| 23 | { |
---|
| 24 | ALint ret = lastError; |
---|
| 25 | lastError = ALUT_ERROR_NO_ERROR; |
---|
| 26 | return ret; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | const char * |
---|
| 30 | alutGetErrorString (ALenum error) |
---|
| 31 | { |
---|
| 32 | switch (error) |
---|
| 33 | { |
---|
| 34 | case ALUT_ERROR_NO_ERROR: |
---|
| 35 | return "No ALUT error found"; |
---|
| 36 | |
---|
| 37 | case ALUT_ERROR_OUT_OF_MEMORY: |
---|
| 38 | return "ALUT ran out of memory"; |
---|
| 39 | |
---|
| 40 | case ALUT_ERROR_INVALID_ENUM: |
---|
| 41 | return "ALUT was given an invalid enumeration token"; |
---|
| 42 | |
---|
| 43 | case ALUT_ERROR_INVALID_VALUE: |
---|
| 44 | return "ALUT was given an invalid value"; |
---|
| 45 | |
---|
| 46 | case ALUT_ERROR_INVALID_OPERATION: |
---|
| 47 | return "The operation was invalid in the current ALUT state"; |
---|
| 48 | |
---|
| 49 | case ALUT_ERROR_NO_CURRENT_CONTEXT: |
---|
| 50 | return "There is no current AL context"; |
---|
| 51 | |
---|
| 52 | case ALUT_ERROR_AL_ERROR_ON_ENTRY: |
---|
| 53 | return "There was already an AL error on entry to an ALUT function"; |
---|
| 54 | |
---|
| 55 | case ALUT_ERROR_ALC_ERROR_ON_ENTRY: |
---|
| 56 | return "There was already an ALC error on entry to an ALUT function"; |
---|
| 57 | |
---|
| 58 | case ALUT_ERROR_OPEN_DEVICE: |
---|
| 59 | return "There was an error opening the ALC device"; |
---|
| 60 | |
---|
| 61 | case ALUT_ERROR_CLOSE_DEVICE: |
---|
| 62 | return "There was an error closing the ALC device"; |
---|
| 63 | |
---|
| 64 | case ALUT_ERROR_CREATE_CONTEXT: |
---|
| 65 | return "There was an error creating an ALC context"; |
---|
| 66 | |
---|
| 67 | case ALUT_ERROR_MAKE_CONTEXT_CURRENT: |
---|
| 68 | return "Could not change the current ALC context"; |
---|
| 69 | |
---|
| 70 | case ALUT_ERROR_DESTROY_CONTEXT: |
---|
| 71 | return "There was an error destroying the ALC context"; |
---|
| 72 | |
---|
| 73 | case ALUT_ERROR_GEN_BUFFERS: |
---|
| 74 | return "There was an error generating an AL buffer"; |
---|
| 75 | |
---|
| 76 | case ALUT_ERROR_BUFFER_DATA: |
---|
| 77 | return "There was an error passing buffer data to AL"; |
---|
| 78 | |
---|
| 79 | case ALUT_ERROR_IO_ERROR: |
---|
| 80 | return "I/O error"; |
---|
| 81 | |
---|
| 82 | case ALUT_ERROR_UNSUPPORTED_FILE_TYPE: |
---|
| 83 | return "Unsupported file type"; |
---|
| 84 | |
---|
| 85 | case ALUT_ERROR_UNSUPPORTED_FILE_SUBTYPE: |
---|
| 86 | return "Unsupported mode within an otherwise usable file type"; |
---|
| 87 | |
---|
| 88 | case ALUT_ERROR_CORRUPT_OR_TRUNCATED_DATA: |
---|
| 89 | return "The sound data was corrupt or truncated"; |
---|
| 90 | |
---|
| 91 | default: |
---|
| 92 | return "An impossible ALUT error condition was reported?!?"; |
---|
| 93 | } |
---|
| 94 | } |
---|