aboutsummaryrefslogtreecommitdiffstats
path: root/examples/alhrtf.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2016-09-08 12:05:08 -0700
committerChris Robinson <[email protected]>2016-09-08 12:14:28 -0700
commit0f24f49a44a12d139692d0846b2722de2213f1a8 (patch)
treeed7a9c9954e56082a27bebfa07fc4c6fbce18c43 /examples/alhrtf.c
parentb21e481827b660e7439fcebb505cdb0349517a54 (diff)
Allow specifying the device to open for the examples
Diffstat (limited to 'examples/alhrtf.c')
-rw-r--r--examples/alhrtf.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/examples/alhrtf.c b/examples/alhrtf.c
index 23d60a74..3964a7c6 100644
--- a/examples/alhrtf.c
+++ b/examples/alhrtf.c
@@ -122,28 +122,18 @@ int main(int argc, char **argv)
ALdouble angle;
ALenum state;
- /* Print out usage if no file was specified */
- if(argc < 2 || (strcmp(argv[1], "-hrtf") == 0 && argc < 4))
+ /* Print out usage if no arguments were specified */
+ if(argc < 2)
{
- fprintf(stderr, "Usage: %s [-hrtf <name>] <soundfile>\n", argv[0]);
+ fprintf(stderr, "Usage: %s [-device <name>] [-hrtf <name>] <soundfile>\n", argv[0]);
return 1;
}
- /* Initialize OpenAL with the default device, and check for HRTF support. */
- if(InitAL() != 0)
+ /* Initialize OpenAL, and check for HRTF support. */
+ argv++; argc--;
+ if(InitAL(&argv, &argc) != 0)
return 1;
- if(strcmp(argv[1], "-hrtf") == 0)
- {
- hrtfname = argv[2];
- soundname = argv[3];
- }
- else
- {
- hrtfname = NULL;
- soundname = argv[1];
- }
-
device = alcGetContextsDevice(alcGetCurrentContext());
if(!alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
{
@@ -164,6 +154,18 @@ int main(int argc, char **argv)
has_angle_ext = alIsExtensionPresent("AL_EXT_STEREO_ANGLES");
printf("AL_EXT_STEREO_ANGLES%s found\n", has_angle_ext?"":" not");
+ /* Check for user-preferred HRTF */
+ if(strcmp(argv[0], "-hrtf") == 0)
+ {
+ hrtfname = argv[1];
+ soundname = argv[2];
+ }
+ else
+ {
+ hrtfname = NULL;
+ soundname = argv[0];
+ }
+
/* Enumerate available HRTFs, and reset the device using one. */
alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf);
if(!num_hrtf)