diff options
author | Chris Robinson <[email protected]> | 2009-11-19 18:25:29 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-11-19 18:25:29 -0800 |
commit | 9c228e76251b875b08117957daa670a94cabd163 (patch) | |
tree | 0ad26af7f7052b866ea3c302996866513be86cfb | |
parent | 6a667b36d1cbaeda96a00ef7d008ce4a19adcb08 (diff) |
Be clearer if device opening or context setup fails
-rw-r--r-- | examples/openal-info.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/examples/openal-info.c b/examples/openal-info.c index daf083b2..bd3b5060 100644 --- a/examples/openal-info.c +++ b/examples/openal-info.c @@ -155,14 +155,13 @@ static void printALCInfo (void) else printf("No device enumeration available\n"); - device = alcGetContextsDevice(alcGetCurrentContext()); - checkForErrors(); - printf("Default device: %s\n", - alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER)); - + alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)); printf("Default capture device: %s\n", - alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); + alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); + + device = alcGetContextsDevice(alcGetCurrentContext()); + checkForErrors(); alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor); @@ -276,10 +275,21 @@ static void printEFXInfo(void) int main() { - ALCdevice *device = alcOpenDevice(NULL); - ALCcontext *context = alcCreateContext(device, NULL); - alcMakeContextCurrent(context); - checkForErrors(); + ALCdevice *device; + ALCcontext *context; + + device = alcOpenDevice(NULL); + if(!device) + { + printf("Failed to open a device!\n"); + exit(EXIT_FAILURE); + } + context = alcCreateContext(device, NULL); + if(!context || alcMakeContextCurrent(context) == ALC_FALSE) + { + printf("Failed to set a context!\n"); + exit(EXIT_FAILURE); + } printALCInfo(); printALInfo(); |