Small fixes for openal and some dynamic linking stuff. Bug in libopenal.a makes this not work, so we're still on openall.dll ...
This commit is contained in:
@@ -62,7 +62,7 @@ endif
|
|||||||
#########################################################################
|
#########################################################################
|
||||||
# Nothing should need changing from here on.. #
|
# Nothing should need changing from here on.. #
|
||||||
#########################################################################
|
#########################################################################
|
||||||
VPATH = . cpu sound sound/resid-fp video lzf network network/slirp win
|
VPATH = . cpu sound sound/resid-fp sound/openal video lzf network network/slirp win
|
||||||
PLAT = win/
|
PLAT = win/
|
||||||
ifeq ($(X64), y)
|
ifeq ($(X64), y)
|
||||||
CPP = g++.exe -m64
|
CPP = g++.exe -m64
|
||||||
@@ -170,12 +170,13 @@ NETOBJ = network.o \
|
|||||||
net_ne2000.o
|
net_ne2000.o
|
||||||
SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o
|
SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o
|
||||||
SNDOBJ = sound.o \
|
SNDOBJ = sound.o \
|
||||||
|
openal.o \
|
||||||
|
dbopl.o nukedopl.o \
|
||||||
convolve.o convolve-sse.o envelope.o extfilt.o \
|
convolve.o convolve-sse.o envelope.o extfilt.o \
|
||||||
filter.o pot.o sid.o voice.o wave6581__ST.o \
|
filter.o pot.o sid.o voice.o wave6581__ST.o \
|
||||||
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
|
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
|
||||||
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
|
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
|
||||||
wave8580_PST.o wave.o \
|
wave8580_PST.o wave.o \
|
||||||
dbopl.o nukedopl.o openal.o \
|
|
||||||
snd_speaker.o snd_ps1.o snd_pssj.o \
|
snd_speaker.o snd_ps1.o snd_pssj.o \
|
||||||
snd_adlib.o snd_adlibgold.o snd_ad1848.o \
|
snd_adlib.o snd_adlibgold.o snd_ad1848.o \
|
||||||
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
|
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
|
||||||
@@ -220,9 +221,11 @@ OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \
|
|||||||
|
|
||||||
LZFOBJ = lzf_c.o lzf_d.o
|
LZFOBJ = lzf_c.o lzf_d.o
|
||||||
|
|
||||||
LIBS = -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 -lopenal.dll \
|
LIBS = -mwindows \
|
||||||
-mwindows -lcomctl32 -lwinmm -lwsock32 -liphlpapi -lpsapi \
|
-lopenal.dll \
|
||||||
-static-libstdc++ -static -lstdc++ -static-libgcc -static -lgcc
|
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
|
||||||
|
-lcomctl32 -lkernel32 -lwsock32 -lwinmm -liphlpapi -lpsapi \
|
||||||
|
-static -lstdc++ -lgcc
|
||||||
|
|
||||||
|
|
||||||
# Build rules.
|
# Build rules.
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
|
# undef AL_API
|
||||||
|
# undef ALC_API
|
||||||
|
# define AL_LIBTYPE_STATIC
|
||||||
|
# define ALC_LIBTYPE_STATIC
|
||||||
# include <AL/al.h>
|
# include <AL/al.h>
|
||||||
# include <AL/alc.h>
|
# include <AL/alc.h>
|
||||||
# include <AL/alext.h>
|
# include <AL/alext.h>
|
||||||
@@ -11,219 +15,220 @@
|
|||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
|
|
||||||
FILE *allog;
|
#define FREQ 48000
|
||||||
|
#define BUFLEN SOUNDBUFLEN
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
ALuint buffers[4]; /* front and back buffers */
|
ALuint buffers[4]; /* front and back buffers */
|
||||||
ALuint buffers_cd[4]; /* front and back buffers */
|
ALuint buffers_cd[4]; /* front and back buffers */
|
||||||
static ALuint source[2]; /* audio source */
|
static ALuint source[2]; /* audio source */
|
||||||
#endif
|
#endif
|
||||||
#define FREQ 48000
|
|
||||||
#define BUFLEN SOUNDBUFLEN
|
|
||||||
|
|
||||||
|
|
||||||
void closeal(void);
|
ALvoid alutInit(ALint *argc,ALbyte **argv)
|
||||||
ALvoid alutInit(ALint *argc,ALbyte **argv)
|
|
||||||
{
|
{
|
||||||
ALCcontext *Context;
|
ALCcontext *Context;
|
||||||
ALCdevice *Device;
|
ALCdevice *Device;
|
||||||
|
|
||||||
/* Open device */
|
/* Open device */
|
||||||
Device=alcOpenDevice((ALCchar *)"");
|
Device = alcOpenDevice((ALCchar *)"");
|
||||||
|
if (Device != NULL) {
|
||||||
/* Create context(s) */
|
/* Create context(s) */
|
||||||
Context=alcCreateContext(Device,NULL);
|
Context = alcCreateContext(Device, NULL);
|
||||||
/* Set active context */
|
if (Context != NULL) {
|
||||||
alcMakeContextCurrent(Context);
|
/* Set active context */
|
||||||
/* Register extensions */
|
alcMakeContextCurrent(Context);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ALvoid alutExit(ALvoid)
|
|
||||||
|
ALvoid alutExit(ALvoid)
|
||||||
{
|
{
|
||||||
ALCcontext *Context;
|
ALCcontext *Context;
|
||||||
ALCdevice *Device;
|
ALCdevice *Device;
|
||||||
|
|
||||||
/* Unregister extensions */
|
/* Get active context */
|
||||||
|
Context = alcGetCurrentContext();
|
||||||
/* Get active context */
|
if (Context != NULL) {
|
||||||
Context=alcGetCurrentContext();
|
|
||||||
/* Get device for active context */
|
/* Get device for active context */
|
||||||
Device=alcGetContextsDevice(Context);
|
Device = alcGetContextsDevice(Context);
|
||||||
/* Disable context */
|
if (Device != NULL) {
|
||||||
alcMakeContextCurrent(NULL);
|
/* Disable context */
|
||||||
|
alcMakeContextCurrent(NULL);
|
||||||
|
|
||||||
|
/* Close device */
|
||||||
|
alcCloseDevice(Device);
|
||||||
|
}
|
||||||
|
|
||||||
/* Release context(s) */
|
/* Release context(s) */
|
||||||
alcDestroyContext(Context);
|
alcDestroyContext(Context);
|
||||||
/* Close device */
|
}
|
||||||
alcCloseDevice(Device);
|
|
||||||
}
|
|
||||||
void initalmain(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
#ifdef USE_OPENAL
|
|
||||||
alutInit(0,0);
|
|
||||||
atexit(closeal);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void closeal(void)
|
void closeal(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
alutExit();
|
alutExit();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initalmain(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#ifdef USE_OPENAL
|
||||||
|
alutInit(0,0);
|
||||||
|
atexit(closeal);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void inital(ALvoid)
|
void inital(ALvoid)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
int c;
|
float buf[BUFLEN*2];
|
||||||
|
float cd_buf[CD_BUFLEN*2];
|
||||||
|
int16_t buf_int16[BUFLEN*2];
|
||||||
|
int16_t cd_buf_int16[CD_BUFLEN*2];
|
||||||
|
int c;
|
||||||
|
|
||||||
float buf[BUFLEN*2];
|
alGenBuffers(4, buffers);
|
||||||
|
alGenBuffers(4, buffers_cd);
|
||||||
float cd_buf[CD_BUFLEN*2];
|
|
||||||
|
|
||||||
int16_t buf_int16[BUFLEN*2];
|
|
||||||
|
|
||||||
int16_t cd_buf_int16[CD_BUFLEN*2];
|
|
||||||
|
|
||||||
alGenBuffers(4, buffers);
|
|
||||||
alGenBuffers(4, buffers_cd);
|
|
||||||
|
|
||||||
alGenSources(2, source);
|
alGenSources(2, source);
|
||||||
|
|
||||||
alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0);
|
alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0);
|
||||||
alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0);
|
alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||||
alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0);
|
alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||||
alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 );
|
alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 );
|
||||||
alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE );
|
alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE );
|
||||||
alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0);
|
|
||||||
alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0);
|
|
||||||
alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0);
|
|
||||||
alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 );
|
|
||||||
alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE );
|
|
||||||
|
|
||||||
memset(buf,0,BUFLEN*2*sizeof(float));
|
alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0);
|
||||||
memset(cd_buf,0,BUFLEN*2*sizeof(float));
|
alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0);
|
||||||
|
alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0);
|
||||||
|
alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 );
|
||||||
|
alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE );
|
||||||
|
|
||||||
for (c = 0; c < 4; c++)
|
memset(buf,0,BUFLEN*2*sizeof(float));
|
||||||
{
|
memset(cd_buf,0,BUFLEN*2*sizeof(float));
|
||||||
if (sound_is_float)
|
|
||||||
{
|
|
||||||
alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
|
|
||||||
alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ);
|
|
||||||
alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
alSourceQueueBuffers(source[0], 4, buffers);
|
for (c = 0; c < 4; c++) {
|
||||||
alSourceQueueBuffers(source[1], 4, buffers_cd);
|
if (sound_is_float) {
|
||||||
alSourcePlay(source[0]);
|
alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
|
||||||
alSourcePlay(source[1]);
|
alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
|
||||||
|
} else {
|
||||||
|
alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ);
|
||||||
|
alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alSourceQueueBuffers(source[0], 4, buffers);
|
||||||
|
alSourceQueueBuffers(source[1], 4, buffers_cd);
|
||||||
|
alSourcePlay(source[0]);
|
||||||
|
alSourcePlay(source[1]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void givealbuffer(float *buf)
|
void givealbuffer(float *buf)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
int processed;
|
int processed;
|
||||||
int state;
|
int state;
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
|
|
||||||
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
|
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
|
||||||
|
|
||||||
if (state==0x1014)
|
if (state==0x1014) {
|
||||||
{
|
alSourcePlay(source[0]);
|
||||||
alSourcePlay(source[0]);
|
}
|
||||||
}
|
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
|
||||||
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
|
|
||||||
|
|
||||||
if (processed>=1)
|
if (processed>=1) {
|
||||||
{
|
alSourceUnqueueBuffers(source[0], 1, &buffer);
|
||||||
alSourceUnqueueBuffers(source[0], 1, &buffer);
|
|
||||||
|
|
||||||
alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
|
alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ);
|
||||||
|
|
||||||
alSourceQueueBuffers(source[0], 1, &buffer);
|
alSourceQueueBuffers(source[0], 1, &buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void givealbuffer_int16(int16_t *buf)
|
void givealbuffer_int16(int16_t *buf)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
int processed;
|
int processed;
|
||||||
int state;
|
int state;
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
|
|
||||||
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
|
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
|
||||||
|
|
||||||
if (state==0x1014)
|
if (state==0x1014) {
|
||||||
{
|
alSourcePlay(source[0]);
|
||||||
alSourcePlay(source[0]);
|
}
|
||||||
}
|
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
|
||||||
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
|
|
||||||
|
|
||||||
if (processed>=1)
|
if (processed>=1) {
|
||||||
{
|
alSourceUnqueueBuffers(source[0], 1, &buffer);
|
||||||
alSourceUnqueueBuffers(source[0], 1, &buffer);
|
|
||||||
|
|
||||||
alBufferData(buffer, AL_FORMAT_STEREO16, buf, BUFLEN*2*sizeof(int16_t), FREQ);
|
alBufferData(buffer, AL_FORMAT_STEREO16, buf, BUFLEN*2*sizeof(int16_t), FREQ);
|
||||||
|
|
||||||
alSourceQueueBuffers(source[0], 1, &buffer);
|
alSourceQueueBuffers(source[0], 1, &buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void givealbuffer_cd(float *buf)
|
void givealbuffer_cd(float *buf)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
int processed;
|
int processed;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
|
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
|
||||||
|
|
||||||
if (state==0x1014)
|
if (state==0x1014) {
|
||||||
{
|
alSourcePlay(source[1]);
|
||||||
alSourcePlay(source[1]);
|
}
|
||||||
}
|
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
|
||||||
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
|
|
||||||
|
|
||||||
if (processed>=1)
|
if (processed>=1) {
|
||||||
{
|
ALuint buffer;
|
||||||
ALuint buffer;
|
|
||||||
|
|
||||||
alSourceUnqueueBuffers(source[1], 1, &buffer);
|
alSourceUnqueueBuffers(source[1], 1, &buffer);
|
||||||
|
|
||||||
alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
|
alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, CD_BUFLEN*2*sizeof(float), CD_FREQ);
|
||||||
|
|
||||||
alSourceQueueBuffers(source[1], 1, &buffer);
|
alSourceQueueBuffers(source[1], 1, &buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void givealbuffer_cd_int16(int16_t *buf)
|
void givealbuffer_cd_int16(int16_t *buf)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENAL
|
#ifdef USE_OPENAL
|
||||||
int processed;
|
int processed;
|
||||||
int state;
|
int state;
|
||||||
|
|
||||||
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
|
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
|
||||||
|
|
||||||
if (state==0x1014)
|
if (state==0x1014) {
|
||||||
{
|
alSourcePlay(source[1]);
|
||||||
alSourcePlay(source[1]);
|
}
|
||||||
}
|
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
|
||||||
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
|
|
||||||
|
|
||||||
if (processed>=1)
|
if (processed>=1) {
|
||||||
{
|
ALuint buffer;
|
||||||
ALuint buffer;
|
|
||||||
|
|
||||||
alSourceUnqueueBuffers(source[1], 1, &buffer);
|
alSourceUnqueueBuffers(source[1], 1, &buffer);
|
||||||
|
|
||||||
alBufferData(buffer, AL_FORMAT_STEREO16, buf, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
|
alBufferData(buffer, AL_FORMAT_STEREO16, buf, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ);
|
||||||
|
|
||||||
alSourceQueueBuffers(source[1], 1, &buffer);
|
alSourceQueueBuffers(source[1], 1, &buffer);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user