openalbridge/openalwrap.c
author unc0rr
Wed, 24 Jun 2009 15:59:32 +0000
changeset 2191 20c62f787a4d
child 2194 1597710c6118
permissions -rw-r--r--
koda's OpenAL conversion: - Freezes program for fadein/fadeout time - Has a problem with quickplay
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2191
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     1
/*
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     2
 * OpenAL Bridge - a simple portable library for OpenAL interface
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     3
 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     4
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     8
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    12
 * GNU General Public License for more details.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    13
 *
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    17
 */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    18
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    19
#include <stdio.h>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    20
#include <stdlib.h>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    21
#include <stdint.h>
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    22
#include "al.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    23
#include "alc.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    24
#include "openalwrap.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    25
#include "loaders.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    26
#include "wrappers.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    27
#include "endianness.h"
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    28
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    29
#ifdef __CPLUSPLUS
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    30
extern "C" {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    31
#endif 
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    32
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    33
	// Sources are points emitting sound.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    34
	ALuint *Sources;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    35
	// Buffers hold sound data.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    36
	ALuint *Buffers;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    37
	//index for Sources and Buffers
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    38
	ALuint globalindex, globalsize;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    39
	// Position of the source sound.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    40
	ALfloat **SourcePos;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    41
	// Velocity of the source sound.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    42
	ALfloat **SourceVel;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    43
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    44
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    45
	ALint openal_close(void) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    46
		/* This function stops all the sounds, deallocates all memory and closes OpenAL */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    47
		int i;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    48
		ALCcontext *context;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    49
		ALCdevice  *device;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    50
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    51
		alSourceStopv	(globalsize, Sources);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    52
		alDeleteSources (globalsize, Sources);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    53
		alDeleteBuffers (globalsize, Buffers);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    54
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    55
		for (i = 0; i < globalsize; i++) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    56
			free(SourcePos[i]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    57
			free(SourceVel[i]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    58
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    59
		free(SourcePos);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    60
		free(SourceVel);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    61
		free(Sources);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    62
		free(Buffers);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    63
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    64
		context = alcGetCurrentContext();
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    65
		device  = alcGetContextsDevice(context);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    66
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    67
		alcMakeContextCurrent(NULL);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    68
		alcDestroyContext(context);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    69
		alcCloseDevice(device);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    70
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    71
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    72
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    73
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    74
	ALint openal_init(int memorysize) {	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    75
		/* This function initializes an OpenAL contex, allocates memory space for data and prepares OpenAL buffers*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    76
		ALCcontext *context;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    77
		ALCdevice *device;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    78
		ALenum error;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    79
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    80
		const ALCchar *default_device;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    81
		// Position of the listener.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    82
		ALfloat ListenerPos[] = { 0.0, 0.0, 0.0 };
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    83
		// Velocity of the listener.
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    84
		ALfloat ListenerVel[] = { 0.0, 0.0, 0.0 };
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    85
		// Orientation of the listener. (first 3 elements are "at", second 3 are "up")
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    86
		ALfloat ListenerOri[] = { 0.0, 0.0, -1.0,  0.0, 1.0, 0.0 };
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    87
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    88
		default_device = alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    89
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    90
		fprintf(stderr, "Using default device: %s\n", default_device);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    91
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    92
		if ((device = alcOpenDevice(default_device)) == NULL) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    93
			fprintf(stderr, "ERROR %d: Failed to open sound device\n", error);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    94
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    95
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    96
		context = alcCreateContext(device, NULL);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    97
		alcMakeContextCurrent(context);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    98
		alcProcessContext(context);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
    99
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   100
		if (AlGetError("ERROR %d: Creating a new contex\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   101
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   102
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   103
		//allocate memory space for buffers and sources
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   104
		globalsize = memorysize;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   105
		Buffers   = (ALuint*)   Malloc(sizeof(ALuint  )*globalsize);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   106
		Sources   = (ALuint*)   Malloc(sizeof(ALuint  )*globalsize);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   107
		SourcePos = (ALfloat**) Malloc(sizeof(ALfloat*)*globalsize);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   108
		SourceVel = (ALfloat**) Malloc(sizeof(ALfloat*)*globalsize);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   109
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   110
		//set the listener gain, position (on xyz axes), velocity (one value for each axe) and orientation
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   111
		alListenerf (AL_GAIN,		 1.0f		);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   112
		alListenerfv(AL_POSITION,    ListenerPos);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   113
		alListenerfv(AL_VELOCITY,    ListenerVel);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   114
		alListenerfv(AL_ORIENTATION, ListenerOri);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   115
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   116
		if (AlGetError("ERROR %d: Setting Listener properties\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   117
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   118
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   119
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   120
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   121
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   122
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   123
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   124
	int openal_loadfile (const char *filename){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   125
		/* This function opens a file, loads into memory and allocates the Source buffer for playing*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   126
		ALenum format;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   127
		ALsizei bitsize;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   128
		ALsizei freq;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   129
		uint8_t *data;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   130
		uint32_t fileformat;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   131
		int i, error;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   132
		FILE *fp;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   133
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   134
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   135
		/*detect the file format, as written in the first 4 bytes of the header*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   136
		fp = Fopen (filename, "rb");
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   137
		if (fp == NULL)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   138
			return -1;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   139
		error = fread (&fileformat, sizeof(uint32_t), 1, fp);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   140
		fclose (fp);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   141
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   142
		if (error < 0) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   143
			fprintf(stderr, "ERROR: file %s is too short \n", filename);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   144
			return -2;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   145
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   146
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   147
		//prepare the buffers to receive data
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   148
		alGenBuffers(1, &Buffers[globalindex]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   149
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   150
		if (AlGetError("ERROR %d: Allocating memory for buffers\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   151
			return -3;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   152
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   153
		//prepare the sources to emit sound
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   154
		alGenSources(1, &Sources[globalindex]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   155
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   156
		if (AlGetError("ERROR %d: Allocating memory for sources\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   157
			return -4;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   158
				
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   159
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   160
		if (fileformat == 0x5367674F) //check if ogg
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   161
			error = load_OggVorbis (filename, &format, &data, &bitsize, &freq);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   162
		else {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   163
			if (fileformat == 0x46464952) //check if wav
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   164
				error = load_WavPcm (filename, &format, &data, &bitsize, &freq);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   165
			else {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   166
				fprintf(stderr, "ERROR: File format (%08X) not supported!\n", invert_endianness(fileformat));
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   167
				return -5;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   168
			}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   169
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   170
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   171
		//copy pcm data in one buffer
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   172
		alBufferData(Buffers[globalindex], format, data, bitsize, freq);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   173
		free(data);		//deallocate data to save memory
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   174
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   175
		if (AlGetError("ERROR %d: Writing data to buffer\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   176
			return -5;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   177
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   178
		//memory allocation for source position and velocity
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   179
		SourcePos[globalindex] = (ALfloat*) Malloc(sizeof(ALfloat)*3);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   180
		SourceVel[globalindex] = (ALfloat*) Malloc(sizeof(ALfloat)*3);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   181
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   182
		if (SourcePos[globalindex] == NULL || SourceVel[globalindex] == NULL)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   183
			return -6;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   184
			
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   185
		//source properties that it will use when it's in playback
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   186
		for (i = 0; i < 3; i++) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   187
			SourcePos[globalindex][i] = 0.0;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   188
			SourceVel[globalindex][i] = 0.1;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   189
		}	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   190
		alSourcei (Sources[globalindex], AL_BUFFER,   Buffers[globalindex]  );
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   191
		alSourcef (Sources[globalindex], AL_PITCH,    1.0f					);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   192
		alSourcef (Sources[globalindex], AL_GAIN,     1.0f					);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   193
		alSourcefv(Sources[globalindex], AL_POSITION, SourcePos[globalindex]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   194
		alSourcefv(Sources[globalindex], AL_VELOCITY, SourceVel[globalindex]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   195
		alSourcei (Sources[globalindex], AL_LOOPING,  0						);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   196
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   197
		if (AlGetError("ERROR %d: Setting source properties\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   198
			return -7;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   199
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   200
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   201
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   202
		//returns the index of the source you just loaded, increments it and exits
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   203
		return globalindex++;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   204
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   205
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   206
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   207
	ALint openal_toggleloop (int index){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   208
		/*Set or unset looping mode*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   209
		ALint loop;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   210
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   211
		if (index >= globalsize) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   212
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   213
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   214
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   215
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   216
		alGetSourcei (Sources[index], AL_LOOPING, &loop);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   217
		alSourcei (Sources[index], AL_LOOPING, !((uint8_t) loop) & 0x00000001);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   218
		if (AlGetError("ERROR %d: Getting or setting loop property\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   219
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   220
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   221
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   222
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   223
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   224
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   225
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   226
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   227
	ALint openal_setvolume (int index, unsigned char percentage) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   228
		/*Set volume for sound number index*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   229
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   230
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   231
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   232
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   233
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   234
		if (percentage > 100)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   235
			percentage = 100;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   236
		alSourcef (Sources[index], AL_GAIN, (ALfloat) percentage/100.0f);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   237
		if (AlGetError("ERROR %d: Setting volume for last sound\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   238
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   239
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   240
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   241
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   242
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   243
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   244
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   245
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   246
	ALint openal_setglobalvolume (unsigned char percentage) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   247
		/*Set volume for all sounds*/		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   248
		if (percentage > 100)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   249
			percentage = 100;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   250
		alListenerf (AL_GAIN, (ALfloat) percentage/100.0f);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   251
		if (AlGetError("ERROR %d: Setting global volume\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   252
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   253
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   254
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   255
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   256
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   257
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   258
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   259
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   260
	ALint openal_togglemute () {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   261
		/*Mute or unmute sound*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   262
		ALfloat mute;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   263
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   264
		alGetListenerf (AL_GAIN, &mute);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   265
		if (mute > 0) 
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   266
			mute = 0;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   267
		else
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   268
			mute = 1.0;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   269
		alListenerf (AL_GAIN, mute);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   270
		if (AlGetError("ERROR %d: Setting mute property\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   271
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   272
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   273
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   274
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   275
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   276
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   277
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   278
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   279
	ALint openal_fadeout(int index, unsigned int quantity) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   280
		ALfloat gain;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   281
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   282
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   283
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   284
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   285
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   286
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   287
		alGetSourcef(Sources[index], AL_GAIN, &gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   288
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   289
		for ( ; gain >= 0.00f; gain -= (float) quantity/10000){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   290
#ifdef DEBUG
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   291
			fprintf(stderr, "Fade-out: Set gain to: %f\n", gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   292
#endif
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   293
			alSourcef(Sources[index], AL_GAIN, gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   294
			usleep(10000);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   295
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   296
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   297
		if (AlGetError("ERROR %d: Setting fade out volume\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   298
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   299
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   300
		//stop that sound and reset its gain
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   301
		alSourceStop (Sources[index]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   302
		alSourcef (Sources[index], AL_GAIN, 1.0f);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   303
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   304
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   305
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   306
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   307
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   308
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   309
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   310
	ALint openal_fadein(int index, unsigned int quantity) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   311
		ALfloat gain;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   312
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   313
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   314
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   315
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   316
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   317
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   318
		gain = 0.0f;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   319
		alSourcef(Sources[index], AL_GAIN, gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   320
		alSourcePlay(Sources[index]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   321
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   322
		for ( ; gain <= 1.00f; gain += (float) quantity/10000){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   323
#ifdef DEBUG
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   324
			fprintf(stderr, "Fade-in: Set gain to: %f\n", gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   325
#endif
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   326
			alSourcef(Sources[index], AL_GAIN, gain);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   327
			usleep(10000);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   328
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   329
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   330
		if (AlGetError("ERROR %d: Setting fade in volume\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   331
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   332
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   333
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   334
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   335
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   336
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   337
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   338
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   339
	ALint openal_playsound(int index){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   340
		/*Play sound number index*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   341
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   342
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   343
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   344
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   345
		alSourcePlay(Sources[index]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   346
		if (AlGetError("ERROR %d: Playing last sound\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   347
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   348
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   349
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   350
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   351
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   352
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   353
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   354
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   355
	ALint openal_pausesound(int index){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   356
		/*Pause sound number index*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   357
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   358
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   359
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   360
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   361
		alSourcePause(Sources[index]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   362
		if (AlGetError("ERROR %d: Pausing last sound\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   363
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   364
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   365
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   366
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   367
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   368
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   369
	ALint openal_stopsound(int index){
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   370
		/*Stop sound number index*/
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   371
		if (index >= globalindex) {
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   372
			fprintf(stderr, "ERROR: index out of bounds (got %d, max %d)", index, globalindex);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   373
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   374
		}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   375
		alSourceStop(Sources[index]);
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   376
		if (AlGetError("ERROR %d: Stopping last sound\n") != AL_TRUE)
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   377
			return AL_FALSE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   378
		
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   379
		alGetError();  /* clear any AL errors beforehand */
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   380
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   381
		return AL_TRUE;
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   382
	}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   383
	
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   384
#ifdef __CPLUSPLUS
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   385
}
20c62f787a4d koda's OpenAL conversion:
unc0rr
parents:
diff changeset
   386
#endif