aboutsummaryrefslogtreecommitdiffstats
path: root/examples/alhrtf.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/alhrtf.c')
-rw-r--r--examples/alhrtf.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/examples/alhrtf.c b/examples/alhrtf.c
index 96cf0255..f09f3e99 100644
--- a/examples/alhrtf.c
+++ b/examples/alhrtf.c
@@ -112,7 +112,7 @@ static ALuint LoadSound(const char *filename)
* close the file. */
buffer = 0;
alGenBuffers(1, &buffer);
- alBufferData(buffer, format, sample->buffer, slen, sample->actual.rate);
+ alBufferData(buffer, format, sample->buffer, (ALsizei)slen, (ALsizei)sample->actual.rate);
Sound_FreeSample(sample);
/* Check if an error occured, and clean up if so. */
@@ -132,6 +132,7 @@ static ALuint LoadSound(const char *filename)
int main(int argc, char **argv)
{
ALCdevice *device;
+ ALCcontext *context;
ALboolean has_angle_ext;
ALuint source, buffer;
const char *soundname;
@@ -153,7 +154,8 @@ int main(int argc, char **argv)
if(InitAL(&argv, &argc) != 0)
return 1;
- device = alcGetContextsDevice(alcGetCurrentContext());
+ context = alcGetCurrentContext();
+ device = alcGetContextsDevice(context);
if(!alcIsExtensionPresent(device, "ALC_SOFT_HRTF"))
{
fprintf(stderr, "Error: ALC_SOFT_HRTF not supported\n");
@@ -171,7 +173,7 @@ int main(int argc, char **argv)
* stereo sources.
*/
has_angle_ext = alIsExtensionPresent("AL_EXT_STEREO_ANGLES");
- printf("AL_EXT_STEREO_ANGLES%s found\n", has_angle_ext?"":" not");
+ printf("AL_EXT_STEREO_ANGLES %sfound\n", has_angle_ext?"":"not ");
/* Check for user-preferred HRTF */
if(strcmp(argv[0], "-hrtf") == 0)
@@ -255,7 +257,7 @@ int main(int argc, char **argv)
alGenSources(1, &source);
alSourcei(source, AL_SOURCE_RELATIVE, AL_TRUE);
alSource3f(source, AL_POSITION, 0.0f, 0.0f, -1.0f);
- alSourcei(source, AL_BUFFER, buffer);
+ alSourcei(source, AL_BUFFER, (ALint)buffer);
assert(alGetError()==AL_NO_ERROR && "Failed to setup sound source");
/* Play the sound until it finishes. */
@@ -264,6 +266,8 @@ int main(int argc, char **argv)
do {
al_nssleep(10000000);
+ alcSuspendContext(context);
+
/* Rotate the source around the listener by about 1/4 cycle per second,
* and keep it within -pi...+pi.
*/
@@ -282,6 +286,7 @@ int main(int argc, char **argv)
ALfloat angles[2] = { (ALfloat)(M_PI/6.0 - angle), (ALfloat)(-M_PI/6.0 - angle) };
alSourcefv(source, AL_STEREO_ANGLES, angles);
}
+ alcProcessContext(context);
alGetSourcei(source, AL_SOURCE_STATE, &state);
} while(alGetError() == AL_NO_ERROR && state == AL_PLAYING);