git-svn-id: https://svn.eduke32.com/eduke32@637 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-03-08 07:46:30 +00:00
parent bc0f8369e6
commit 6b956dfe2a
12 changed files with 1037 additions and 1037 deletions

View file

@ -53,16 +53,12 @@ ifeq ($(PLATFORM),LINUX)
OBJ=obj OBJ=obj
EOBJ=eobj EOBJ=eobj
NASMFLAGS+= -f elf NASMFLAGS+= -f elf
ifeq ($(USE_OPENAL),1)
LIBS+= -lvorbisfile -lvorbis -logg LIBS+= -lvorbisfile -lvorbis -logg
endif
else else
ifeq ($(PLATFORM),WINDOWS) ifeq ($(PLATFORM),WINDOWS)
OBJ=obj_win OBJ=obj_win
EOBJ=eobj_win EOBJ=eobj_win
ifeq ($(USE_OPENAL),1)
LIBS+= -L$(ALROOT)/lib -lvorbisfile -lvorbis -logg LIBS+= -L$(ALROOT)/lib -lvorbisfile -lvorbis -logg
endif
else else
OBJ=obj OBJ=obj
EOBJ=eobj EOBJ=eobj

View file

@ -8720,8 +8720,10 @@ static int parsegroupfiles(scriptfile *script)
initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
break; break;
} }
#ifdef USE_OPENAL
if (AL_DefineMusic(ID,ext)) if (AL_DefineMusic(ID,ext))
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
#endif
} }
break; break;

View file

@ -88,9 +88,7 @@ typedef enum
VOC, VOC,
DemandFeed, DemandFeed,
WAV, WAV,
#ifdef USE_OPENAL
OGG OGG
#endif
} wavedata; } wavedata;
typedef enum typedef enum
@ -134,11 +132,11 @@ typedef struct VoiceNode
int priority; int priority;
void ( *DemandFeed )( char **ptr, unsigned int *length ); void ( *DemandFeed )( char **ptr, unsigned int *length );
#ifdef USE_OPENAL
struct sounddef OGGstream; struct sounddef OGGstream;
char *bufsnd; char *bufsnd;
int downsample; int downsample;
#endif
short *LeftVolume; short *LeftVolume;
short *RightVolume; short *RightVolume;

View file

@ -705,7 +705,6 @@ int FX_PlayWAV
Begin playback of sound data with the given volume and priority. Begin playback of sound data with the given volume and priority.
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
#ifdef USE_OPENAL
int FX_PlayOGG int FX_PlayOGG
( (
char *ptr, char *ptr,
@ -730,7 +729,6 @@ int FX_PlayOGG
return(handle); return(handle);
} }
#endif
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: FX_PlayWAV Function: FX_PlayWAV
@ -766,7 +764,7 @@ int FX_PlayLoopedWAV
return(handle); return(handle);
} }
#ifdef USE_OPENAL
int FX_PlayLoopedOGG int FX_PlayLoopedOGG
( (
char *ptr, char *ptr,
@ -795,7 +793,7 @@ int FX_PlayLoopedOGG
return(handle); return(handle);
} }
#endif
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: FX_PlayVOC3D Function: FX_PlayVOC3D
@ -826,7 +824,7 @@ int FX_PlayVOC3D
return(handle); return(handle);
} }
#ifdef USE_OPENAL
int FX_PlayOGG3D int FX_PlayOGG3D
( (
char *ptr, char *ptr,
@ -850,7 +848,6 @@ int FX_PlayOGG3D
return(handle); return(handle);
} }
#endif
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: FX_PlayWAV3D Function: FX_PlayWAV3D

View file

@ -206,11 +206,9 @@ char *MV_ErrorString(int ErrorNumber)
case MV_InvalidWAVFile : case MV_InvalidWAVFile :
ErrorString = "Invalid WAV file passed in to Multivoc."; ErrorString = "Invalid WAV file passed in to Multivoc.";
break; break;
#ifdef USE_OPENAL
case MV_InvalidOGGFile : case MV_InvalidOGGFile :
ErrorString = "Invalid OGG file passed in to Multivoc."; ErrorString = "Invalid OGG file passed in to Multivoc.";
break; break;
#endif
case MV_InvalidMixMode : case MV_InvalidMixMode :
ErrorString = "Invalid mix mode request in Multivoc."; ErrorString = "Invalid mix mode request in Multivoc.";
break; break;
@ -918,7 +916,7 @@ playbackstatus MV_GetNextWAVBlock(VoiceNode *voice)
Controls playback of demand fed data. Controls playback of demand fed data.
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
#ifdef USE_OPENAL
void downsample(char *ptr,int size,int factor) void downsample(char *ptr,int size,int factor)
{ {
short *pti=(short *)ptr;int i,j,sum; short *pti=(short *)ptr;int i,j,sum;
@ -982,7 +980,7 @@ playbackstatus MV_GetNextOGGBlock(VoiceNode *voice)
return(KeepPlaying); return(KeepPlaying);
} }
#endif
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: MV_ServiceRecord Function: MV_ServiceRecord
@ -2406,7 +2404,7 @@ int MV_PlayLoopedVOC(char *ptr, int loopstart, int loopend, int pitchoffset, int
priority. priority.
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
VoiceNode *voice; VoiceNode *voice;
#ifdef USE_OPENAL
int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval) int MV_PlayLoopedOGG(char *ptr, int loopstart, int loopend, int pitchoffset, int vol, int left, int right, int priority, unsigned int callbackval)
{ {
vorbis_info *vorbisInfo; vorbis_info *vorbisInfo;
@ -2546,7 +2544,7 @@ int MV_PlayOGG3D(char *ptr, int pitchoffset, int angle, int distance, int priori
return(status); return(status);
} }
#endif
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
Function: MV_CreateVolumeTable Function: MV_CreateVolumeTable
@ -2886,11 +2884,11 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb
Bfree(map[i].musicfn1); Bfree(map[i].musicfn1);
} }
for (i=MAXSOUNDS-1;i>=0;i--) /* for (i=MAXSOUNDS-1;i>=0;i--)
{ {
if (g_sounds[i].filename1 != NULL) if (g_sounds[i].filename1 != NULL)
Bfree(g_sounds[i].filename1); Bfree(g_sounds[i].filename1);
} } */
} }
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)

View file

@ -50,9 +50,7 @@ enum MV_Errors
MV_DPMI_Error, MV_DPMI_Error,
MV_InvalidVOCFile, MV_InvalidVOCFile,
MV_InvalidWAVFile, MV_InvalidWAVFile,
#ifdef USE_OPENAL
MV_InvalidOGGFile, MV_InvalidOGGFile,
#endif
MV_InvalidMixMode, MV_InvalidMixMode,
MV_IrqFailure, MV_IrqFailure,
MV_DMAFailure, MV_DMAFailure,

View file

@ -341,7 +341,7 @@ int MUSIC_StopSong
{ {
#ifdef USE_OPENAL #ifdef USE_OPENAL
if (!openal_disabled) if (!openal_disabled)
AL_stop(); AL_Stop();
#endif #endif
MUSIC_StopFade(); MUSIC_StopFade();
MIDI_StopSong(); MIDI_StopSong();

View file

@ -261,7 +261,7 @@ int AL_Init()
{ {
if (loadaldriver()) if (loadaldriver())
{ {
initprintf("Failed loading OpenAL driver.\n"); initprintf("Failed loading OpenAL driver.\nDownload OpenAL 1.1 or greater from http://www.openal.org/downloads.html.");
openal_disabled = 1; openal_disabled = 1;
return 1; return 1;
@ -282,7 +282,7 @@ int AL_Init()
initprintf("OpenAL Information:\n" initprintf("OpenAL Information:\n"
" Version: %s\n" " Version: %s\n"
" Vendor: %s\n\n",balGetString(AL_VERSION),balGetString(AL_VENDOR)); " Vendor: %s\n\n",balGetString(AL_VERSION),balGetString(AL_VENDOR));
} else initprintf("OpenAL initialisation failed. Try http://www.openal.org/\n"); } else initprintf("OpenAL initialization failed.\n");
ALdoing="Open"; ALdoing="Open";
balGenBuffers(16, sounds1[1].buffers); balGenBuffers(16, sounds1[1].buffers);
@ -317,7 +317,7 @@ sounddef1 music;
extern int Musicsize; extern int Musicsize;
void AL_stop(); void AL_Stop();
int update(); int update();
int stream(ALuint buffer); int stream(ALuint buffer);
void open1(char *ptr,int sizef,char loop); void open1(char *ptr,int sizef,char loop);
@ -326,7 +326,7 @@ void open1(char *ptr,int sizef,char loop);
void AL_Pause() {if(music.def.size)balSourcePause(music.source);} void AL_Pause() {if(music.def.size)balSourcePause(music.source);}
void AL_Continue() {if(music.def.size)balSourcePlay(music.source);} void AL_Continue() {if(music.def.size)balSourcePlay(music.source);}
void AL_Update() {if(music.def.size&&!update(0))AL_stop();} void AL_Update() {if(music.def.size&&!update(0))AL_Stop();}
int AL_isntALmusic() {return !music.def.size;} int AL_isntALmusic() {return !music.def.size;}
void AL_SetMusicVolume(int volume) void AL_SetMusicVolume(int volume)
@ -371,7 +371,7 @@ int update()
return active; return active;
} }
void AL_stop() void AL_Stop()
{ {
int queued=0;ALuint buffer; int queued=0;ALuint buffer;

View file

@ -9,7 +9,7 @@ void AL_Update();
char *AL_ErrorString(int code); char *AL_ErrorString(int code);
char *ALC_ErrorString(int code); char *ALC_ErrorString(int code);
void AL_stop(); void AL_Stop();
int AL_isntALmusic(); int AL_isntALmusic();
void AL_PlaySong(char *song,int loopflag); void AL_PlaySong(char *song,int loopflag);
void AL_Pause(); void AL_Pause();

View file

@ -54,6 +54,10 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu)
#include <SDL_mixer.h> #include <SDL_mixer.h>
#include "music.h" #include "music.h"
#ifdef USE_OPENAL
#include "openal.h"
#endif
#define __FX_TRUE (1 == 1) #define __FX_TRUE (1 == 1)
#define __FX_FALSE (!__FX_TRUE) #define __FX_FALSE (!__FX_TRUE)
@ -376,6 +380,11 @@ void MUSIC_SetVolume(int volume)
volume = max(0, volume); volume = max(0, volume);
volume = min(volume, 255); volume = min(volume, 255);
#ifdef USE_OPENAL
if (!openal_disabled)
AL_SetMusicVolume(volume);
#endif
Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128. Mix_VolumeMusic(volume >> 1); // convert 0-255 to 0-128.
} // MUSIC_SetVolume } // MUSIC_SetVolume
@ -412,6 +421,10 @@ int MUSIC_SongPlaying(void)
void MUSIC_Continue(void) void MUSIC_Continue(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Continue();
#endif
if (Mix_PausedMusic()) if (Mix_PausedMusic())
Mix_ResumeMusic(); Mix_ResumeMusic();
else if (music_songdata) else if (music_songdata)
@ -421,12 +434,20 @@ void MUSIC_Continue(void)
void MUSIC_Pause(void) void MUSIC_Pause(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Pause();
#endif
Mix_PauseMusic(); Mix_PauseMusic();
} // MUSIC_Pause } // MUSIC_Pause
int MUSIC_StopSong(void) int MUSIC_StopSong(void)
{ {
#ifdef USE_OPENAL
if (!openal_disabled)
AL_Stop();
#endif
//if (!fx_initialized) //if (!fx_initialized)
if (!Mix_QuerySpec(NULL, NULL, NULL)) if (!Mix_QuerySpec(NULL, NULL, NULL))
{ {
@ -450,7 +471,12 @@ int MUSIC_StopSong(void)
int MUSIC_PlaySong(unsigned char *song, int loopflag) int MUSIC_PlaySong(unsigned char *song, int loopflag)
{ {
//SDL_RWops *rw; //SDL_RWops *rw;
#ifdef USE_OPENAL
if (!openal_disabled)
AL_PlaySong((char *)song,loopflag);
if(openal_disabled || AL_isntALmusic())
#endif
{
MUSIC_StopSong(); MUSIC_StopSong();
music_songdata = (char *)song; music_songdata = (char *)song;
@ -468,7 +494,7 @@ int MUSIC_PlaySong(unsigned char *song, int loopflag)
music_musicchunk = Mix_LoadMUS_RW(rw); music_musicchunk = Mix_LoadMUS_RW(rw);
Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1); Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1);
*/ */
}
return(MUSIC_Ok); return(MUSIC_Ok);
} // MUSIC_PlaySong } // MUSIC_PlaySong

View file

@ -1605,7 +1605,8 @@ int enterlevel(int g)
FX_StopAllSounds(); FX_StopAllSounds();
clearsoundlocks(); clearsoundlocks();
FX_SetReverb(0); FX_SetReverb(0);
playmusicMAP(&env_music_fn[1][0],MAXVOLUMES*MAXLEVELS+2); // loadmus MUSIC_StopSong();
playmusicMAP(&env_music_fn[2][0],MAXVOLUMES*MAXLEVELS+2); // loadmus
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
{ {

View file

@ -392,14 +392,10 @@ int xyzsound(int num,int i,int x,int y,int z)
if (*g_sounds[num].ptr == 'C') if (*g_sounds[num].ptr == 'C')
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
#ifdef USE_OPENAL else
else if (!openal_disabled)
{
if (*g_sounds[num].ptr == 'O') if (*g_sounds[num].ptr == 'O')
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
}
#endif
else else
voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, voice = FX_PlayLoopedWAV(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num); pitch,sndist>>6,sndist>>6,0,g_sounds[num].pr,num);
@ -408,13 +404,9 @@ int xyzsound(int num,int i,int x,int y,int z)
{ {
if (*g_sounds[num].ptr == 'C') if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); voice = FX_PlayVOC3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
#ifdef USE_OPENAL else
else if (!openal_disabled)
{
if (*g_sounds[num].ptr == 'O') if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); voice = FX_PlayOGG3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
}
#endif
else else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num); voice = FX_PlayWAV3D(g_sounds[ num ].ptr,pitch,sndang>>6,sndist>>6, g_sounds[num].pr, num);
} }
@ -477,17 +469,13 @@ void sound(int num)
voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, voice = FX_PlayLoopedVOC(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num); pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
} }
#ifdef USE_OPENAL else
else if (!openal_disabled)
{
if (*g_sounds[num].ptr == 'O') if (*g_sounds[num].ptr == 'O')
{ {
start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14); start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14);
voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz, voice = FX_PlayLoopedOGG(g_sounds[num].ptr, start, start + g_sounds[num].soundsiz,
pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num); pitch,LOUDESTVOLUME,LOUDESTVOLUME,LOUDESTVOLUME,g_sounds[num].pr,num);
} }
}
#endif
else else
{ {
start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14); start = (int)*(unsigned short *)(g_sounds[num].ptr + 0x14);
@ -499,13 +487,9 @@ void sound(int num)
{ {
if (*g_sounds[num].ptr == 'C') if (*g_sounds[num].ptr == 'C')
voice = FX_PlayVOC3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); voice = FX_PlayVOC3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
#ifdef USE_OPENAL else
else if (!openal_disabled)
{
if (*g_sounds[num].ptr == 'O') if (*g_sounds[num].ptr == 'O')
voice = FX_PlayOGG3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); voice = FX_PlayOGG3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
}
#endif
else else
voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num); voice = FX_PlayWAV3D(g_sounds[ num ].ptr, pitch,0,255-LOUDESTVOLUME,g_sounds[num].pr, num);
} }