|
| 1 | +// So far just does some sanity checks for the available extensions. |
| 2 | +// |
| 3 | +// In the future, could also try to enable different extensions and test for |
| 4 | +// output correctness. |
| 5 | + |
| 6 | +#include <stdio.h> |
| 7 | +#include <stdlib.h> |
| 8 | +#ifdef __EMSCRIPTEN__ |
| 9 | +#include <emscripten.h> |
| 10 | +#define ASSUME_AL_FLOAT32 |
| 11 | +#endif |
| 12 | +#include <AL/al.h> |
| 13 | +#include <AL/alc.h> |
| 14 | +#include <AL/alext.h> |
| 15 | + |
| 16 | +static int result = EXIT_SUCCESS; |
| 17 | + |
| 18 | +static void end_test() { |
| 19 | +#ifdef __EMSCRIPTEN__ |
| 20 | + REPORT_RESULT(result); |
| 21 | +#endif |
| 22 | + exit(result); |
| 23 | +} |
| 24 | + |
| 25 | +#define NUM_ALC_EXTENSIONS 2 |
| 26 | +static const ALCchar *alc_extensions[NUM_ALC_EXTENSIONS] = { |
| 27 | + "ALC_SOFT_pause_device", |
| 28 | + "ALC_SOFT_HRTF", |
| 29 | +}; |
| 30 | + |
| 31 | +#define NUM_AL_EXTENSIONS 5 |
| 32 | +static const ALCchar *al_extensions[NUM_AL_EXTENSIONS] = { |
| 33 | + "AL_EXT_float32", |
| 34 | + "AL_SOFT_loop_points", |
| 35 | + "AL_SOFT_source_length", |
| 36 | + "AL_EXT_source_distance_model", |
| 37 | + "AL_SOFT_source_spatialize", |
| 38 | +}; |
| 39 | + |
| 40 | +static void check_alc_extension(const ALCchar *extension) { |
| 41 | + ALCdevice *device = alcOpenDevice(NULL); |
| 42 | + if (!device) { |
| 43 | + fprintf(stderr, "Failed to open default device."); |
| 44 | + result = EXIT_FAILURE; |
| 45 | + return; |
| 46 | + } |
| 47 | + |
| 48 | + if (alcIsExtensionPresent(device, extension) != ALC_TRUE) { |
| 49 | + fprintf(stderr, "Extension %s was not present.", extension); |
| 50 | + result = EXIT_FAILURE; |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +static void check_al_extension(const ALchar *extension) { |
| 55 | + if (alIsExtensionPresent(extension) != ALC_TRUE) { |
| 56 | + fprintf(stderr, "Extension %s was not present.", extension); |
| 57 | + result = EXIT_FAILURE; |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +int main() { |
| 62 | + |
| 63 | + for(int i = 0; i < NUM_ALC_EXTENSIONS; i++) { |
| 64 | + check_alc_extension(alc_extensions[i]); |
| 65 | + } |
| 66 | + |
| 67 | + for(int i = 0; i < NUM_AL_EXTENSIONS; i++) { |
| 68 | + check_al_extension(al_extensions[i]); |
| 69 | + } |
| 70 | + |
| 71 | + end_test(); |
| 72 | +} |
0 commit comments