]> git.mxchange.org Git - flightgear.git/commitdiff
Add a gl-info equivalent for OpenAL.
authorehofman <ehofman>
Tue, 31 Jan 2006 18:20:49 +0000 (18:20 +0000)
committerehofman <ehofman>
Tue, 31 Jan 2006 18:20:49 +0000 (18:20 +0000)
tests/Makefile.am
tests/al-info.c [new file with mode: 0644]

index 42a4c4756e93500d40c612cd68f73980a9d2c042..69612dbef9f3e9b5af0db2099fb34b6489d0a595 100644 (file)
@@ -1,4 +1,4 @@
-bin_PROGRAMS = est-epsilon gl-info
+bin_PROGRAMS = est-epsilon gl-info al-info
 
 noinst_PROGRAMS = test-gethostname test-mktime test-text test-up test-env-map
 
@@ -8,6 +8,9 @@ est_epsilon_LDADD =  $(opengl_LIBS)
 gl_info_SOURCES = gl-info.c
 gl_info_LDADD = $(opengl_LIBS)
 
+al_info_SOURCES = al-info.c
+al_info_LDADD = $(openal_LIBS)
+
 test_env_map_SOURCES = test-env-map.cxx
 test_env_map_LDADD = $(opengl_LIBS)
 
diff --git a/tests/al-info.c b/tests/al-info.c
new file mode 100644 (file)
index 0000000..db41145
--- /dev/null
@@ -0,0 +1,99 @@
+
+#include <stdio.h>
+
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <AL/alext.h>
+
+#define MAX_DATA       16
+
+int main()
+{
+   ALCint i,j;
+   ALCint data[MAX_DATA];
+   ALCdevice *device = NULL;
+   ALCcontext *context = NULL;
+   const ALCchar *s;
+   ALCenum error;
+   ALCboolean ret;
+
+   device = alcOpenDevice(NULL);
+   if (device == NULL)
+   {
+      printf("No default audio device available.\n");
+      return -1;
+   }
+   context = alcCreateContext(device, NULL);
+   if (context == NULL)
+   {
+      printf("Could not create a valid context.\n");
+      return -2;
+   }
+   alcMakeContextCurrent(context);
+
+   s = alGetString(AL_VENDOR);
+   printf("AL_VENDOR = \"%s\"\n", s);
+
+   s = alGetString(AL_RENDERER);
+   printf("AL_RENDERER = \"%s\"\n", s);
+
+   s = alGetString(AL_VERSION);
+   printf("AL_VERSION = \"%s\"\n", s);
+
+   s = alGetString(AL_EXTENSIONS);
+   printf("AL_EXTENSIONS = \"%s\"\n", s);
+
+   alcGetError(device);
+
+   printf("\n");
+   if (alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT") == AL_TRUE)
+   {
+      s = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
+      printf("ALC_DEVICE_SPECIFIER = \"%s\"\n", s);
+   }
+
+   alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, data);
+   printf("ALC_MAJOR_VERSION = %i\n", *data);
+   alcGetIntegerv(device, ALC_MINOR_VERSION, 1, data);
+   printf("ALC_MINOR_VERSION = %i\n", *data);
+
+   s = alcGetString(device, ALC_EXTENSIONS);
+   printf("ALC_EXTENSIONS = \"%s\"\n", s);
+
+   if ((error = alcGetError(device)))
+   {
+      printf("Error #%i occured\n", error);
+      return error;
+   }
+
+   s = alcGetString(device, ALC_DEFAULT_DEVICE_SPECIFIER);
+   printf("ALC_DEFAULT_DEVICE_SPECIFIER = \"%s\"\n", s);
+
+   if ((error = alcGetError(device)))
+   {
+      printf("Error #%i occured\n", error);
+      return error;
+   }
+
+#if 0
+   alcGetIntegerv(device, ALC_ATTRIBUTES_SIZE, 1, &i);
+   printf("ALC attributes(%i): ", i);
+
+   alcGetIntegerv(device, ALC_ALL_ATTRIBUTES, i, data);
+   for (j=0; j<i; j++)
+   {
+      printf("%i ", data[j]);
+   }
+   printf("\n");
+
+   if ((error = alcGetError(device)))
+   {
+      printf("Error #%i occured\n", error);
+      return error;
+   }
+#endif
+
+   ret = alcCloseDevice(device);
+
+   return ret;
+}