From 9c228e76251b875b08117957daa670a94cabd163 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 19 Nov 2009 18:25:29 -0800 Subject: [PATCH] Be clearer if device opening or context setup fails --- examples/openal-info.c | 30 ++++++++++++++++++++---------- 1 file 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,15 +155,14 @@ static void printALCInfo (void) else printf("No device enumeration available\n"); + printf("Default device: %s\n", + alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)); + printf("Default capture device: %s\n", + alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); + device = alcGetContextsDevice(alcGetCurrentContext()); checkForErrors(); - printf("Default device: %s\n", - alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER)); - - printf("Default capture device: %s\n", - alcGetString(device, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); - alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor); checkForErrors(); @@ -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();