Revert "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 reverts commit bb03e64539.
This commit is contained in:
waltje
2017-06-19 00:54:33 -04:00
parent bb03e64539
commit 92755dd76a
2 changed files with 139 additions and 147 deletions

View File

@@ -62,7 +62,7 @@ endif
#########################################################################
# Nothing should need changing from here on.. #
#########################################################################
VPATH = . cpu sound sound/resid-fp sound/openal video lzf network network/slirp win
VPATH = . cpu sound sound/resid-fp video lzf network network/slirp win
PLAT = win/
ifeq ($(X64), y)
CPP = g++.exe -m64
@@ -170,13 +170,12 @@ NETOBJ = network.o \
net_ne2000.o
SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o
SNDOBJ = sound.o \
openal.o \
dbopl.o nukedopl.o \
convolve.o convolve-sse.o envelope.o extfilt.o \
filter.o pot.o sid.o voice.o wave6581__ST.o \
wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \
wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \
wave8580_PST.o wave.o \
dbopl.o nukedopl.o openal.o \
snd_speaker.o snd_ps1.o snd_pssj.o \
snd_adlib.o snd_adlibgold.o snd_ad1848.o \
snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \
@@ -221,11 +220,9 @@ OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \
LZFOBJ = lzf_c.o lzf_d.o
LIBS = -mwindows \
-lopenal.dll \
-lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 \
-lcomctl32 -lkernel32 -lwsock32 -lwinmm -liphlpapi -lpsapi \
-static -lstdc++ -lgcc
LIBS = -lddraw -ldinput8 -ldxguid -ld3d9 -ld3dx9 -lopenal.dll \
-mwindows -lcomctl32 -lwinmm -lwsock32 -liphlpapi -lpsapi \
-static-libstdc++ -static -lstdc++ -static-libgcc -static -lgcc
# Build rules.

View File

@@ -3,10 +3,6 @@
#include <string.h>
#include <stdlib.h>
#ifdef USE_OPENAL
# undef AL_API
# undef ALC_API
# define AL_LIBTYPE_STATIC
# define ALC_LIBTYPE_STATIC
# include <AL/al.h>
# include <AL/alc.h>
# include <AL/alext.h>
@@ -15,220 +11,219 @@
#include "sound.h"
#define FREQ 48000
#define BUFLEN SOUNDBUFLEN
FILE *allog;
#ifdef USE_OPENAL
ALuint buffers[4]; /* front and back buffers */
ALuint buffers_cd[4]; /* front and back buffers */
static ALuint source[2]; /* audio source */
#endif
#define FREQ 48000
#define BUFLEN SOUNDBUFLEN
ALvoid alutInit(ALint *argc,ALbyte **argv)
void closeal(void);
ALvoid alutInit(ALint *argc,ALbyte **argv)
{
ALCcontext *Context;
ALCdevice *Device;
ALCcontext *Context;
ALCdevice *Device;
/* Open device */
Device = alcOpenDevice((ALCchar *)"");
if (Device != NULL) {
/* Open device */
Device=alcOpenDevice((ALCchar *)"");
/* Create context(s) */
Context = alcCreateContext(Device, NULL);
if (Context != NULL) {
/* Set active context */
alcMakeContextCurrent(Context);
}
}
Context=alcCreateContext(Device,NULL);
/* Set active context */
alcMakeContextCurrent(Context);
/* Register extensions */
}
ALvoid alutExit(ALvoid)
ALvoid alutExit(ALvoid)
{
ALCcontext *Context;
ALCdevice *Device;
ALCcontext *Context;
ALCdevice *Device;
/* Get active context */
Context = alcGetCurrentContext();
if (Context != NULL) {
/* Unregister extensions */
/* Get active context */
Context=alcGetCurrentContext();
/* Get device for active context */
Device = alcGetContextsDevice(Context);
if (Device != NULL) {
/* Disable context */
alcMakeContextCurrent(NULL);
/* Close device */
alcCloseDevice(Device);
}
Device=alcGetContextsDevice(Context);
/* Disable context */
alcMakeContextCurrent(NULL);
/* Release context(s) */
alcDestroyContext(Context);
}
/* Close device */
alcCloseDevice(Device);
}
void initalmain(int argc, char *argv[])
{
#ifdef USE_OPENAL
alutInit(0,0);
atexit(closeal);
#endif
}
void closeal(void)
{
#ifdef USE_OPENAL
alutExit();
alutExit();
#endif
}
void initalmain(int argc, char *argv[])
{
#ifdef USE_OPENAL
alutInit(0,0);
atexit(closeal);
#endif
}
void inital(ALvoid)
{
#ifdef USE_OPENAL
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;
int c;
alGenBuffers(4, buffers);
alGenBuffers(4, buffers_cd);
float buf[BUFLEN*2];
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_VELOCITY, 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 );
alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE );
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_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 );
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 );
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));
memset(cd_buf,0,BUFLEN*2*sizeof(float));
memset(buf,0,BUFLEN*2*sizeof(float));
memset(cd_buf,0,BUFLEN*2*sizeof(float));
for (c = 0; c < 4; c++)
{
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);
}
}
for (c = 0; c < 4; c++) {
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);
alSourceQueueBuffers(source[1], 4, buffers_cd);
alSourcePlay(source[0]);
alSourcePlay(source[1]);
alSourceQueueBuffers(source[0], 4, buffers);
alSourceQueueBuffers(source[1], 4, buffers_cd);
alSourcePlay(source[0]);
alSourcePlay(source[1]);
#endif
}
void givealbuffer(float *buf)
{
#ifdef USE_OPENAL
int processed;
int state;
ALuint buffer;
int processed;
int state;
ALuint buffer;
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
if (state==0x1014) {
alSourcePlay(source[0]);
}
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
if (state==0x1014)
{
alSourcePlay(source[0]);
}
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
if (processed>=1) {
alSourceUnqueueBuffers(source[0], 1, &buffer);
if (processed>=1)
{
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
}
void givealbuffer_int16(int16_t *buf)
{
#ifdef USE_OPENAL
int processed;
int state;
ALuint buffer;
int processed;
int state;
ALuint buffer;
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
alGetSourcei(source[0], AL_SOURCE_STATE, &state);
if (state==0x1014) {
alSourcePlay(source[0]);
}
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
if (state==0x1014)
{
alSourcePlay(source[0]);
}
alGetSourcei(source[0], AL_BUFFERS_PROCESSED, &processed);
if (processed>=1) {
alSourceUnqueueBuffers(source[0], 1, &buffer);
if (processed>=1)
{
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
}
void givealbuffer_cd(float *buf)
{
#ifdef USE_OPENAL
int processed;
int state;
int processed;
int state;
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
if (state==0x1014) {
alSourcePlay(source[1]);
}
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
if (state==0x1014)
{
alSourcePlay(source[1]);
}
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
if (processed>=1) {
ALuint buffer;
if (processed>=1)
{
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
}
void givealbuffer_cd_int16(int16_t *buf)
{
#ifdef USE_OPENAL
int processed;
int state;
int processed;
int state;
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
alGetSourcei(source[1], AL_SOURCE_STATE, &state);
if (state==0x1014) {
alSourcePlay(source[1]);
}
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
if (state==0x1014)
{
alSourcePlay(source[1]);
}
alGetSourcei(source[1], AL_BUFFERS_PROCESSED, &processed);
if (processed>=1) {
ALuint buffer;
if (processed>=1)
{
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
}