File: test_openal_extensions.c

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 121,872 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,365; asm: 2,415; lisp: 1,869
file content (61 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright 2024 The Emscripten Authors.  All rights reserved.
 * Emscripten is available under two separate licenses, the MIT license and the
 * University of Illinois/NCSA Open Source License.  Both these licenses can be
 * found in the LICENSE file.
 */

// So far just does some sanity checks for the available extensions.
//
// In the future, could also try to enable different extensions and test for
// output correctness.

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alext.h>

#define NUM_ALC_EXTENSIONS 2
static const ALCchar *alc_extensions[NUM_ALC_EXTENSIONS] = {
  "ALC_SOFT_pause_device",
  "ALC_SOFT_HRTF",
};

#define NUM_AL_EXTENSIONS 5
static const ALCchar *al_extensions[NUM_AL_EXTENSIONS] = {
  "AL_EXT_float32",
  "AL_SOFT_loop_points",
  "AL_SOFT_source_length",
  "AL_EXT_source_distance_model",
  "AL_SOFT_source_spatialize",
};

static void check_alc_extension(const ALCchar *extension) {
  printf("checking: %s\n", extension);
  ALCdevice *device = alcOpenDevice(NULL);

  assert(device);
  assert(alcIsExtensionPresent(device, extension) == ALC_TRUE);
}

static void check_al_extension(const ALchar *extension) {
  printf("checking: %s\n", extension);
  assert(alIsExtensionPresent(extension) == ALC_TRUE);
}

int main() {
  printf("AL_EXTENSIONS: %s\n", alGetString(AL_EXTENSIONS));

  for (int i = 0; i < NUM_ALC_EXTENSIONS; i++) {
    check_alc_extension(alc_extensions[i]);
  }

  for (int i = 0; i < NUM_AL_EXTENSIONS; i++) {
    check_al_extension(al_extensions[i]);
  }

  printf("done\n");
  return 0;
}