diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 1e520b8d3..1eb861a7e 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8614,6 +8614,82 @@ static void autoloadgrps(const char *fn) while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } } +char *makename(char *destname, char *OGGname, char *origname) +{ + if (!origname) + return destname; + + if (destname) + Bfree(destname); + destname=Bcalloc(Bstrlen(OGGname)+Bstrlen(origname)+1,sizeof(char)); + if (!destname) + return NULL; + + Bstrcpy(destname,(*OGGname)?OGGname:origname); + + if (*OGGname&&OGGname[Bstrlen(OGGname)-1]=='/') + { + while (*origname=='/') + origname++; + Bstrcat(destname,origname); + } + + OGGname=Bstrchr(destname,'.'); + if (OGGname) + Bstrcpy(OGGname,".ogg"); + else Bstrcat(destname,".ogg"); + + return destname; +} + +int AL_DefineSound(int ID,char *name) +{ + if (ID>=MAXSOUNDS) + return 1; + g_sounds[ID].filename1=makename(g_sounds[ID].filename1,name,g_sounds[ID].filename); +// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename); +// loadsound(ID); + return 0; +} + +int AL_DefineMusic(char *ID,char *name) +{ + int lev,ep,sel;char b1,b2; + + if (!ID) + return 1; + if (!Bstrcmp(ID,"intro")) + { + sel=MAXVOLUMES*MAXLEVELS; ID=env_music_fn[0]; + } + else if (!Bstrcmp(ID,"briefing")) + { + sel=MAXVOLUMES*MAXLEVELS+1; + ID=env_music_fn[1]; + } + else if (!Bstrcmp(ID,"loading")) + { + sel=MAXVOLUMES*MAXLEVELS+2; + ID=env_music_fn[2]; + } + else + { + sscanf(ID,"%c%d%c%d",&b1,&ep,&b2,&lev); + lev--; + ep--; + if (toupper(b1)!='E'||toupper(b2)!='L'||lev>=MAXLEVELS||ep>=MAXVOLUMES) + return 1; + sel=(ep*MAXLEVELS)+lev; + ID=map[sel].musicfn; + } + + map[sel].musicfn1=makename(map[sel].musicfn1,name,ID); + initprintf("%-15s | ",ID); + initprintf("%3d %2d %2d | %s\n",sel,ep,lev,map[sel].musicfn1); +// playmusicMAP(ID,sel); + return 0; +} + static int parsedefinitions_game(scriptfile *script, const int preload) { int tokn; @@ -8718,16 +8794,16 @@ static int parsedefinitions_game(scriptfile *script, const int preload) } if (!preload) { - if(ID==NULL) + if (ID==NULL) { initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); break; } - #ifdef USE_OPENAL +#ifdef USE_OPENAL if (AL_DefineMusic(ID,ext)) initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); - #endif - } +#endif + } } break; @@ -8743,19 +8819,21 @@ static int parsedefinitions_game(scriptfile *script, const int preload) switch (getatoken(script,sound_musictokens,sizeof(sound_musictokens)/sizeof(tokenlist))) { case T_ID: - scriptfile_getsymbol(script,&num);break; + scriptfile_getsymbol(script,&num); + break; case T_FILE: scriptfile_getstring(script,&name); + break; } } if (!preload) { - if(num==-1) + if (num==-1) { initprintf("Error: missing ID for sound definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); break; } - if(AL_DefineSound(num,name))initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); + if (AL_DefineSound(num,name))initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); } } break; diff --git a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c index 5c3649139..d0120ec7f 100644 --- a/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c +++ b/polymer/eduke32/source/jaudiolib/audiolib_musicstub.c @@ -1,494 +1,494 @@ -//------------------------------------------------------------------------- -/* -Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment - -This file is part of Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com) -*/ -//------------------------------------------------------------------------- - -#include "music.h" - - -#define TRUE ( 1 == 1 ) -#define FALSE ( !TRUE ) - - -int MUSIC_ErrorCode = MUSIC_Ok; - - -/*--------------------------------------------------------------------- - Function: MUSIC_ErrorString - - Returns a pointer to the error message associated with an error - number. A -1 returns a pointer the current error. ----------------------------------------------------------------------*/ - -char *MUSIC_ErrorString -( - int ErrorNumber -) - -{ - char *ErrorString; - - switch (ErrorNumber) - { - case MUSIC_Warning : - case MUSIC_Error : - ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode); - break; - - case MUSIC_Ok : - ErrorString = "Music ok."; - break; - - case MUSIC_ASSVersion : - ErrorString = "Apogee Sound System Version " - "Programmed by Jim Dose\n" - "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; - break; - - case MUSIC_SoundCardError : - break; - - case MUSIC_MPU401Error : - ErrorString = "Could not detect MPU-401."; - break; - - case MUSIC_InvalidCard : - ErrorString = "Invalid Music device."; - break; - - case MUSIC_MidiError : - ErrorString = "Error playing MIDI file."; - break; - - case MUSIC_TaskManError : - ErrorString = "TaskMan error."; - break; - - case MUSIC_DPMI_Error : - ErrorString = "DPMI Error in MUSIC."; - break; - - default : - ErrorString = "Unknown Music error code."; - break; - } - - return(ErrorString); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Init - - Selects which sound device to use. ----------------------------------------------------------------------*/ - -int MUSIC_Init -( - int SoundCard, - int Address -) - -{ - int i; - int status; - - status = MUSIC_Ok; - - return(status); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Shutdown - - Terminates use of sound device. ----------------------------------------------------------------------*/ - -int MUSIC_Shutdown -( - void -) - -{ - int status; - - status = MUSIC_Ok; - - - return(status); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetMaxFMMidiChannel - - Sets the maximum MIDI channel that FM cards respond to. ----------------------------------------------------------------------*/ - -void MUSIC_SetMaxFMMidiChannel -( - int channel -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetVolume - - Sets the volume of music playback. ----------------------------------------------------------------------*/ - -void MUSIC_SetVolume -( - int volume -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetMidiChannelVolume - - Sets the volume of music playback on the specified MIDI channel. ----------------------------------------------------------------------*/ - -void MUSIC_SetMidiChannelVolume -( - int channel, - int volume -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_ResetMidiChannelVolumes - - Sets the volume of music playback on all MIDI channels to full volume. ----------------------------------------------------------------------*/ - -void MUSIC_ResetMidiChannelVolumes -( - void -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetVolume - - Returns the volume of music playback. ----------------------------------------------------------------------*/ - -int MUSIC_GetVolume -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetLoopFlag - - Set whether the music will loop or end when it reaches the end of - the song. ----------------------------------------------------------------------*/ - -void MUSIC_SetLoopFlag -( - int loopflag -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SongPlaying - - Returns whether there is a song playing. ----------------------------------------------------------------------*/ - -int MUSIC_SongPlaying -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Continue - - Continues playback of a paused song. ----------------------------------------------------------------------*/ - -void MUSIC_Continue -( - void -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_Pause - - Pauses playback of a song. ----------------------------------------------------------------------*/ - -void MUSIC_Pause -( - void -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_StopSong - - Stops playback of current song. ----------------------------------------------------------------------*/ - -int MUSIC_StopSong -( - void -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_PlaySong - - Begins playback of MIDI song. ----------------------------------------------------------------------*/ - -int MUSIC_PlaySong -( - unsigned char *song, - int loopflag -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetContext - - Sets the song context. ----------------------------------------------------------------------*/ - -void MUSIC_SetContext -( - int context -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetContext - - Returns the current song context. ----------------------------------------------------------------------*/ - -int MUSIC_GetContext -( - void -) - -{ return 0; } - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongTick - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongTick -( - unsigned int PositionInTicks -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongTime - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongTime -( - unsigned int milliseconds -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_SetSongPosition - - Sets the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_SetSongPosition -( - int measure, - int beat, - int tick -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetSongPosition - - Returns the position of the song pointer. ----------------------------------------------------------------------*/ - -void MUSIC_GetSongPosition -( - songposition *pos -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_GetSongLength - - Returns the length of the song. ----------------------------------------------------------------------*/ - -void MUSIC_GetSongLength -( - songposition *pos -) - -{} - - - - - - -/*--------------------------------------------------------------------- - Function: MUSIC_FadeVolume - - Fades music volume from current level to another over a specified - period of time. ----------------------------------------------------------------------*/ - -int MUSIC_FadeVolume -( - int tovolume, - int milliseconds -) - -{ - return(MUSIC_Ok); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_FadeActive - - Returns whether the fade routine is active. ----------------------------------------------------------------------*/ - -int MUSIC_FadeActive -( - void -) - -{ - return(0); -} - - -/*--------------------------------------------------------------------- - Function: MUSIC_StopFade - - Stops fading the music. ----------------------------------------------------------------------*/ - -void MUSIC_StopFade -( - void -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_RerouteMidiChannel - - Sets callback function to reroute MIDI commands from specified - function. ----------------------------------------------------------------------*/ - -void MUSIC_RerouteMidiChannel -( - int channel, - int(*function)(int event, int c1, int c2) -) - -{} - - -/*--------------------------------------------------------------------- - Function: MUSIC_RegisterTimbreBank - - Halts playback of all sounds. ----------------------------------------------------------------------*/ - -void MUSIC_RegisterTimbreBank -( - unsigned char *timbres -) - -{} - - -void MUSIC_Update(void) -{} - -void PlayMusic(char *_filename) +//------------------------------------------------------------------------- +/* +Duke Nukem Copyright (C) 1996, 2003 3D Realms Entertainment + +This file is part of Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + Dummy AudioLib stub implementation by Jonathon Fowler (jonof@edgenetwk.com) +*/ +//------------------------------------------------------------------------- + +#include "music.h" + + +#define TRUE ( 1 == 1 ) +#define FALSE ( !TRUE ) + + +int MUSIC_ErrorCode = MUSIC_Ok; + + +/*--------------------------------------------------------------------- + Function: MUSIC_ErrorString + + Returns a pointer to the error message associated with an error + number. A -1 returns a pointer the current error. +---------------------------------------------------------------------*/ + +char *MUSIC_ErrorString +( + int ErrorNumber +) + +{ + char *ErrorString; + + switch (ErrorNumber) + { + case MUSIC_Warning : + case MUSIC_Error : + ErrorString = MUSIC_ErrorString(MUSIC_ErrorCode); + break; + + case MUSIC_Ok : + ErrorString = "Music ok."; + break; + + case MUSIC_ASSVersion : + ErrorString = "Apogee Sound System Version " + "Programmed by Jim Dose\n" + "(c) Copyright 1996 James R. Dose. All Rights Reserved.\n"; + break; + + case MUSIC_SoundCardError : + break; + + case MUSIC_MPU401Error : + ErrorString = "Could not detect MPU-401."; + break; + + case MUSIC_InvalidCard : + ErrorString = "Invalid Music device."; + break; + + case MUSIC_MidiError : + ErrorString = "Error playing MIDI file."; + break; + + case MUSIC_TaskManError : + ErrorString = "TaskMan error."; + break; + + case MUSIC_DPMI_Error : + ErrorString = "DPMI Error in MUSIC."; + break; + + default : + ErrorString = "Unknown Music error code."; + break; + } + + return(ErrorString); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_Init + + Selects which sound device to use. +---------------------------------------------------------------------*/ + +int MUSIC_Init +( + int SoundCard, + int Address +) + +{ + int i; + int status; + + status = MUSIC_Ok; + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_Shutdown + + Terminates use of sound device. +---------------------------------------------------------------------*/ + +int MUSIC_Shutdown +( + void +) + +{ + int status; + + status = MUSIC_Ok; + + + return(status); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetMaxFMMidiChannel + + Sets the maximum MIDI channel that FM cards respond to. +---------------------------------------------------------------------*/ + +void MUSIC_SetMaxFMMidiChannel +( + int channel +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetVolume + + Sets the volume of music playback. +---------------------------------------------------------------------*/ + +void MUSIC_SetVolume +( + int volume +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetMidiChannelVolume + + Sets the volume of music playback on the specified MIDI channel. +---------------------------------------------------------------------*/ + +void MUSIC_SetMidiChannelVolume +( + int channel, + int volume +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_ResetMidiChannelVolumes + + Sets the volume of music playback on all MIDI channels to full volume. +---------------------------------------------------------------------*/ + +void MUSIC_ResetMidiChannelVolumes +( + void +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetVolume + + Returns the volume of music playback. +---------------------------------------------------------------------*/ + +int MUSIC_GetVolume +( + void +) + +{ + return(0); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetLoopFlag + + Set whether the music will loop or end when it reaches the end of + the song. +---------------------------------------------------------------------*/ + +void MUSIC_SetLoopFlag +( + int loopflag +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SongPlaying + + Returns whether there is a song playing. +---------------------------------------------------------------------*/ + +int MUSIC_SongPlaying +( + void +) + +{ + return(0); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_Continue + + Continues playback of a paused song. +---------------------------------------------------------------------*/ + +void MUSIC_Continue +( + void +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_Pause + + Pauses playback of a song. +---------------------------------------------------------------------*/ + +void MUSIC_Pause +( + void +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopSong + + Stops playback of current song. +---------------------------------------------------------------------*/ + +int MUSIC_StopSong +( + void +) + +{ + return(MUSIC_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_PlaySong + + Begins playback of MIDI song. +---------------------------------------------------------------------*/ + +int MUSIC_PlaySong +( + unsigned char *song, + int loopflag +) + +{ + return(MUSIC_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetContext + + Sets the song context. +---------------------------------------------------------------------*/ + +void MUSIC_SetContext +( + int context +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetContext + + Returns the current song context. +---------------------------------------------------------------------*/ + +int MUSIC_GetContext +( + void +) + +{ return 0; } + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTick + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTick +( + unsigned int PositionInTicks +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongTime + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongTime +( + unsigned int milliseconds +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_SetSongPosition + + Sets the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_SetSongPosition +( + int measure, + int beat, + int tick +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongPosition + + Returns the position of the song pointer. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongPosition +( + songposition *pos +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_GetSongLength + + Returns the length of the song. +---------------------------------------------------------------------*/ + +void MUSIC_GetSongLength +( + songposition *pos +) + +{} + + + + + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeVolume + + Fades music volume from current level to another over a specified + period of time. +---------------------------------------------------------------------*/ + +int MUSIC_FadeVolume +( + int tovolume, + int milliseconds +) + +{ + return(MUSIC_Ok); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_FadeActive + + Returns whether the fade routine is active. +---------------------------------------------------------------------*/ + +int MUSIC_FadeActive +( + void +) + +{ + return(0); +} + + +/*--------------------------------------------------------------------- + Function: MUSIC_StopFade + + Stops fading the music. +---------------------------------------------------------------------*/ + +void MUSIC_StopFade +( + void +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_RerouteMidiChannel + + Sets callback function to reroute MIDI commands from specified + function. +---------------------------------------------------------------------*/ + +void MUSIC_RerouteMidiChannel +( + int channel, + int(*function)(int event, int c1, int c2) +) + +{} + + +/*--------------------------------------------------------------------- + Function: MUSIC_RegisterTimbreBank + + Halts playback of all sounds. +---------------------------------------------------------------------*/ + +void MUSIC_RegisterTimbreBank +( + unsigned char *timbres +) + +{} + + +void MUSIC_Update(void) +{} + +void PlayMusic(char *_filename, int loopflag) {} diff --git a/polymer/eduke32/source/jaudiolib/dsl.c b/polymer/eduke32/source/jaudiolib/dsl.c index 2f58c5746..c09113b78 100755 --- a/polymer/eduke32/source/jaudiolib/dsl.c +++ b/polymer/eduke32/source/jaudiolib/dsl.c @@ -116,7 +116,6 @@ static void mixer_callback(int chan, void *stream, int len, void *udata) Uint8 *fxptr; int copysize; - AL_Update(); /* len should equal _BufferSize, else this is screwed up */ stptr = (Uint8 *)stream; @@ -140,6 +139,10 @@ static void mixer_callback(int chan, void *stream, int len, void *udata) { /* new buffer */ +#ifdef USE_OPENAL + AL_Update(); +#endif + _CallBackFunc(); fxptr = (Uint8 *)(&_BufferStart[MV_MixPage * diff --git a/polymer/eduke32/source/jaudiolib/fx_man.c b/polymer/eduke32/source/jaudiolib/fx_man.c index 8477cb800..936584d67 100644 --- a/polymer/eduke32/source/jaudiolib/fx_man.c +++ b/polymer/eduke32/source/jaudiolib/fx_man.c @@ -1160,110 +1160,8 @@ void FX_StopRecord extern void MUSIC_Update(void); void AudioUpdate(void) { MUSIC_Update(); } - void playmusic(const char *fn); -#if 0 -char *makename(char *destname,char *OGGname) -{ - if (!(*OGGname)) - return NULL; - if (destname) - Bfree(destname); - destname=Bcalloc(Bstrlen(OGGname)+1,sizeof(char)); - if (destname != NULL) - Bstrcpy(destname,OGGname); -/* if(*OGGname&&OGGname[Bstrlen(OGGname)-1]=='/') - { - while(*origname=='/')origname++; - Bstrcat(destname,origname); - } - OGGname=Bstrchr(destname,'.'); - if(OGGname)Bstrcpy(OGGname,".ogg");else Bstrcat(destname,".ogg"); */ - return destname; -} - -int AL_DefineSound(int ID,char *name) -{ - if(ID>=MAXSOUNDS)return 1; - g_sounds[ID].filename1=makename(g_sounds[ID].filename1,name); -// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename); -// loadsound(ID); - return 0; -} - -int AL_DefineMusic(char *ID,char *name) -{ - int lev,ep,sel;char b1,b2; - - if(!ID)return 1; - if(!Bstrcmp(ID,"intro")) {sel=MAXVOLUMES*MAXLEVELS; ID=env_music_fn[0];}else - if(!Bstrcmp(ID,"briefing")){sel=MAXVOLUMES*MAXLEVELS+1;ID=env_music_fn[1];}else - if(!Bstrcmp(ID,"loading")) {sel=MAXVOLUMES*MAXLEVELS+2;ID=env_music_fn[2];}else - { - sscanf(ID,"%c%d%c%d",&b1,&ep,&b2,&lev); - lev--;ep--; - if(toupper(b1)!='E'||toupper(b2)!='L'||lev>=MAXLEVELS||ep>=MAXVOLUMES)return 1; - sel=(ep*MAXLEVELS)+lev; -// ID=map[sel].musicfn; - } - - map[sel].musicfn1=makename(map[sel].musicfn1,name/*,ID*/); -// initprintf("%s | %3d %2d %2d | %s\n",ID,sel,ep,lev,map[sel].musicfn1); -// playmusicMAP(ID,sel); - return 0; -} -#else -char *makename(char *destname,char *OGGname,char *origname) -{ - if(!origname)return destname; - if(destname)Bfree(destname); - destname=Bcalloc(Bstrlen(OGGname)+Bstrlen(origname)+1,sizeof(char)); - if(!destname)return 0; - Bstrcpy(destname,(*OGGname)?OGGname:origname); - - if(*OGGname&&OGGname[Bstrlen(OGGname)-1]=='/') - { - while(*origname=='/')origname++; - Bstrcat(destname,origname); - } - OGGname=Bstrchr(destname,'.'); - if(OGGname)Bstrcpy(OGGname,".ogg");else Bstrcat(destname,".ogg"); - return destname; -} - -int AL_DefineSound(int ID,char *name) -{ - if(ID>=MAXSOUNDS)return 1; - g_sounds[ID].filename1=makename(g_sounds[ID].filename1,name,g_sounds[ID].filename); -// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename); -// loadsound(ID); - return 0; -} - -int AL_DefineMusic(char *ID,char *name) -{ - int lev,ep,sel;char b1,b2; - - if(!ID)return 1; - if(!Bstrcmp(ID,"intro")) {sel=MAXVOLUMES*MAXLEVELS; ID=env_music_fn[0];}else - if(!Bstrcmp(ID,"briefing")){sel=MAXVOLUMES*MAXLEVELS+1;ID=env_music_fn[1];}else - if(!Bstrcmp(ID,"loading")) {sel=MAXVOLUMES*MAXLEVELS+2;ID=env_music_fn[2];}else - { - sscanf(ID,"%c%d%c%d",&b1,&ep,&b2,&lev); - lev--;ep--; - if(toupper(b1)!='E'||toupper(b2)!='L'||lev>=MAXLEVELS||ep>=MAXVOLUMES)return 1; - sel=(ep*MAXLEVELS)+lev; - ID=map[sel].musicfn; - } - - map[sel].musicfn1=makename(map[sel].musicfn1,name,ID); - initprintf("%-15s | ",ID); - initprintf("%3d %2d %2d | %s\n",sel,ep,lev,map[sel].musicfn1); -// playmusicMAP(ID,sel); - return 0; -} -#endif void playmusicMAP(const char *fn,const int sel) { Musicsize=0; diff --git a/polymer/eduke32/source/jaudiolib/multivoc.c b/polymer/eduke32/source/jaudiolib/multivoc.c index 02af369a3..3bfa63f73 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/multivoc.c @@ -2874,12 +2874,6 @@ int MV_Init(int soundcard, int MixRate, int Voices, int numchannels, int sampleb if (map[i].musicfn1 != NULL) Bfree(map[i].musicfn1); } - -/* for (i=MAXSOUNDS-1;i>=0;i--) - { - if (g_sounds[i].filename1 != NULL) - Bfree(g_sounds[i].filename1); - } */ } #endif #if defined(_WIN32) diff --git a/polymer/eduke32/source/jaudiolib/openal.c b/polymer/eduke32/source/jaudiolib/openal.c index 854bbec9d..3aa8bb7de 100644 --- a/polymer/eduke32/source/jaudiolib/openal.c +++ b/polymer/eduke32/source/jaudiolib/openal.c @@ -42,28 +42,28 @@ static void *alhandle = NULL; char *aldriver = NULL; -void (AL_APIENTRY * balGetSourcei)( ALuint sid, ALenum param, ALint* value ); -void (AL_APIENTRY * balSourcef)( ALuint sid, ALenum param, ALfloat value ); -void (AL_APIENTRY * balSourcePlay)( ALuint sid ); -void (AL_APIENTRY * balSourcePause)( ALuint sid ); -ALCenum (ALC_APIENTRY * balcGetError)( ALCdevice *device ); -ALenum (AL_APIENTRY * balGetError)( void ); -void (AL_APIENTRY * balBufferData)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); -void (AL_APIENTRY * balGenBuffers)( ALsizei n, ALuint* buffers ); -void (AL_APIENTRY * balGenSources)( ALsizei n, ALuint* sources ); -void (AL_APIENTRY * balSourcei)( ALuint sid, ALenum param, ALint value ); -void (AL_APIENTRY * balSourceQueueBuffers)( ALuint sid, ALsizei numEntries, const ALuint *bids ); -void (AL_APIENTRY * balSourceStop)( ALuint sid ); -void (AL_APIENTRY * balSourceUnqueueBuffers)( ALuint sid, ALsizei numEntries, ALuint *bids ); -void (AL_APIENTRY * bbalDeleteSources)( ALsizei n, const ALuint* sources ); -ALCboolean (ALC_APIENTRY * balcMakeContextCurrent)( ALCcontext *context ); -void (AL_APIENTRY * balDeleteSources)( ALsizei n, const ALuint* sources ); -void (AL_APIENTRY * balDeleteBuffers)( ALsizei n, const ALuint* buffers ); -void (ALC_APIENTRY * balcDestroyContext)( ALCcontext *context ); -ALCboolean (ALC_APIENTRY * balcCloseDevice)( ALCdevice *device ); -ALCdevice *(ALC_APIENTRY * balcOpenDevice)( const ALCchar *devicename ); -ALCcontext *(ALC_APIENTRY * balcCreateContext)( ALCdevice *device, const ALCint* attrlist ); -const ALchar* (AL_APIENTRY * balGetString)( ALenum param ); +void (AL_APIENTRY * balGetSourcei)(ALuint sid, ALenum param, ALint* value); +void (AL_APIENTRY * balSourcef)(ALuint sid, ALenum param, ALfloat value); +void (AL_APIENTRY * balSourcePlay)(ALuint sid); +void (AL_APIENTRY * balSourcePause)(ALuint sid); +ALCenum(ALC_APIENTRY * balcGetError)(ALCdevice *device); +ALenum(AL_APIENTRY * balGetError)(void); +void (AL_APIENTRY * balBufferData)(ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq); +void (AL_APIENTRY * balGenBuffers)(ALsizei n, ALuint* buffers); +void (AL_APIENTRY * balGenSources)(ALsizei n, ALuint* sources); +void (AL_APIENTRY * balSourcei)(ALuint sid, ALenum param, ALint value); +void (AL_APIENTRY * balSourceQueueBuffers)(ALuint sid, ALsizei numEntries, const ALuint *bids); +void (AL_APIENTRY * balSourceStop)(ALuint sid); +void (AL_APIENTRY * balSourceUnqueueBuffers)(ALuint sid, ALsizei numEntries, ALuint *bids); +void (AL_APIENTRY * bbalDeleteSources)(ALsizei n, const ALuint* sources); +ALCboolean(ALC_APIENTRY * balcMakeContextCurrent)(ALCcontext *context); +void (AL_APIENTRY * balDeleteSources)(ALsizei n, const ALuint* sources); +void (AL_APIENTRY * balDeleteBuffers)(ALsizei n, const ALuint* buffers); +void (ALC_APIENTRY * balcDestroyContext)(ALCcontext *context); +ALCboolean(ALC_APIENTRY * balcCloseDevice)(ALCdevice *device); +ALCdevice *(ALC_APIENTRY * balcOpenDevice)(const ALCchar *devicename); +ALCcontext *(ALC_APIENTRY * balcCreateContext)(ALCdevice *device, const ALCint* attrlist); +const ALchar*(AL_APIENTRY * balGetString)(ALenum param); static void * algetproc_(const char *s, int *err, int fatal) { @@ -187,72 +187,72 @@ int loadaldriver(void) char *ALC_ErrorString(int code) { - switch(code) - { - case ALC_NO_ERROR: - return "OpenAL error: There is no current error."; - case ALC_INVALID_DEVICE: - return "OpenAL error: No device."; - case ALC_INVALID_CONTEXT: - return "OpenAL error: Invalid context ID."; - case ALC_INVALID_ENUM: - return "OpenAL error: Invalid parameter."; - case ALC_INVALID_VALUE: - return "OpenAL error: Invalid enum parameter value."; - case ALC_OUT_OF_MEMORY: - return "OpenAL error: Unable to allocate memory."; - default: - return "OpenAL error: Unknown error."; - } + switch (code) + { + case ALC_NO_ERROR: + return "OpenAL error: There is no current error."; + case ALC_INVALID_DEVICE: + return "OpenAL error: No device."; + case ALC_INVALID_CONTEXT: + return "OpenAL error: Invalid context ID."; + case ALC_INVALID_ENUM: + return "OpenAL error: Invalid parameter."; + case ALC_INVALID_VALUE: + return "OpenAL error: Invalid enum parameter value."; + case ALC_OUT_OF_MEMORY: + return "OpenAL error: Unable to allocate memory."; + default: + return "OpenAL error: Unknown error."; + } } char *AL_ErrorString(int code) { - switch(code) - { - case AL_NO_ERROR: - return "OpenAL error: There is no current error."; - case AL_INVALID_NAME: - return "OpenAL error: Invalid name parameter."; - case AL_INVALID_ENUM: - return "OpenAL error: Invalid parameter."; - case AL_INVALID_VALUE: - return "OpenAL error: Invalid enum parameter value."; - case AL_INVALID_OPERATION: - return "OpenAL error: Illegal call."; - case AL_OUT_OF_MEMORY: - return "OpenAL error: Unable to allocate memory."; - case OV_EFAULT: - return "Internal logic fault (bug or heap/stack corruption."; - case OV_EREAD: - return "Read from media."; - case OV_EIMPL: - return "The bitstream makes use of a feature not implemented in this library version."; - case OV_EINVAL: - return "Invalid argument value."; - case OV_ENOTVORBIS: - return "Not Vorbis data."; - case OV_EBADHEADER: - return "Invalid Vorbis header."; - case OV_EVERSION: - return "Vorbis version mismatch."; - case OV_ENOTAUDIO: - return "Packet data submitted to vorbis_synthesis is not audio data."; - case OV_EBADPACKET: - return "Invalid packet submitted to vorbis_synthesis."; - case OV_EBADLINK: - return "Invalid stream section supplied to libvorbis/libvorbisfile, or the requested link is corrupt."; - case OV_ENOSEEK: - return "Bitstream is not seekable."; - default: - return "Unknown OpenAL/Ogg error."; - } + switch (code) + { + case AL_NO_ERROR: + return "OpenAL error: There is no current error."; + case AL_INVALID_NAME: + return "OpenAL error: Invalid name parameter."; + case AL_INVALID_ENUM: + return "OpenAL error: Invalid parameter."; + case AL_INVALID_VALUE: + return "OpenAL error: Invalid enum parameter value."; + case AL_INVALID_OPERATION: + return "OpenAL error: Illegal call."; + case AL_OUT_OF_MEMORY: + return "OpenAL error: Unable to allocate memory."; + case OV_EFAULT: + return "Internal logic fault (bug or heap/stack corruption."; + case OV_EREAD: + return "Read from media."; + case OV_EIMPL: + return "The bitstream makes use of a feature not implemented in this library version."; + case OV_EINVAL: + return "Invalid argument value."; + case OV_ENOTVORBIS: + return "Not Vorbis data."; + case OV_EBADHEADER: + return "Invalid Vorbis header."; + case OV_EVERSION: + return "Vorbis version mismatch."; + case OV_ENOTAUDIO: + return "Packet data submitted to vorbis_synthesis is not audio data."; + case OV_EBADPACKET: + return "Invalid packet submitted to vorbis_synthesis."; + case OV_EBADLINK: + return "Invalid stream section supplied to libvorbis/libvorbisfile, or the requested link is corrupt."; + case OV_ENOSEEK: + return "Bitstream is not seekable."; + default: + return "Unknown OpenAL/Ogg error."; + } } void check(int show) { AL_Error=balcGetError(device); - if(AL_Error!=ALC_NO_ERROR&&show)initprintf("%s(%s)\n",ALC_ErrorString(AL_Error),ALdoing); + if (AL_Error!=ALC_NO_ERROR&&show)initprintf("%s(%s)\n",ALC_ErrorString(AL_Error),ALdoing); AL_Error=balGetError(); - if(AL_Error!= AL_NO_ERROR&&show)initprintf("%s(%s)\n", AL_ErrorString(AL_Error),ALdoing); + if (AL_Error!= AL_NO_ERROR&&show)initprintf("%s(%s)\n", AL_ErrorString(AL_Error),ALdoing); } extern ov_callbacks cb; @@ -271,18 +271,50 @@ int AL_Init() // device=alcOpenDevice(ud.config.HardwareAL?"Generic Hardware":"Generic Software"); device=balcOpenDevice(NULL); check(1); - if(device) + + if (device) { context=balcCreateContext(device,NULL); check(1); } - if(context) + + if (context) { - balcMakeContextCurrent(context);check(1); - initprintf("OpenAL Information:\n" - " Version: %s\n" - " Vendor: %s\n\n",balGetString(AL_VERSION),balGetString(AL_VENDOR)); - } else initprintf("OpenAL initialization failed.\n"); + char *s,*t,*u,i; + + balcMakeContextCurrent(context);check(1); + initprintf("OpenAL Information:\n" + " Version: %s\n" + " Vendor: %s\n" + " Renderer: %s\n" + " Extensions:\n" + ,balGetString(AL_VERSION),balGetString(AL_VENDOR),balGetString(AL_RENDERER)); + + s = Bstrdup(balGetString(AL_EXTENSIONS)); + if (!s) initprintf(balGetString(AL_EXTENSIONS)); + else + { + i = 0; t = u = s; + while (*t) + { + if (*t == ' ') + { + if (i&1) + { + *t = 0; + initprintf(" %s\n",u); + u = t+1; + } + i++; + } + t++; + } + if (i&1) initprintf(" %s\n",u); + Bfree(s); + } + + } + else initprintf("OpenAL initialization failed.\n"); ALdoing="Open"; balGenBuffers(16, sounds1[1].buffers); @@ -324,15 +356,15 @@ void open1(char *ptr,int sizef,char loop); -void AL_Pause() {if(music.def.size)balSourcePause(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_Pause() {if (music.def.size)balSourcePause(music.source);} +void AL_Continue() {if (music.def.size)balSourcePlay(music.source);} +void AL_Update() {if (music.def.size&&!update(0))AL_Stop();} int AL_isntALmusic() {return !music.def.size;} void AL_SetMusicVolume(int volume) { AL_MusicVolume=volume; - if(music.def.size)balSourcef(music.source,AL_GAIN,volume/(255.)); + if (music.def.size)balSourcef(music.source,AL_GAIN,volume/(255.)); } int isplaying() @@ -351,23 +383,23 @@ int update() ALdoing="update"; balGetSourcei(music.source,AL_BUFFERS_PROCESSED,&processed); check(1); - if(processed) - switch(music.type) - { + if (processed) + switch (music.type) + { case 1: - while(processed--) + while (processed--) { balSourceUnqueueBuffers(music.source,1,&buffer); check(1); active=stream(buffer); - if(active) + if (active) { balSourceQueueBuffers(music.source,1,&buffer); check(1); } } break; - } + } return active; } @@ -375,13 +407,13 @@ void AL_Stop() { int queued=0;ALuint buffer; - if(!music.def.size)return; + if (!music.def.size)return; balSourceStop(music.source); balGetSourcei(music.source,AL_BUFFERS_QUEUED,&queued); ALdoing="release"; - while(queued--) + while (queued--) { balSourceUnqueueBuffers(music.source,1,&buffer); check(1); @@ -389,7 +421,7 @@ void AL_Stop() balDeleteSources(1,&music.source);check(1); balDeleteBuffers(2, music.buffers);check(1); - if(music.type==1)ov_clear(&music.def.oggStream); + if (music.type==1)ov_clear(&music.def.oggStream); Bmemset(&music,0,sizeof(sounddef1)); } @@ -399,13 +431,13 @@ int stream(ALuint buffer) ALsizei size=0; int section,result; - while(size 0)size+=result;else break; + if (result==0&&music.loop)ov_pcm_seek(&music.def.oggStream,0);else + if (result> 0)size+=result;else break; } - if(!size)return 0; + if (!size)return 0; ALdoing="stream"; balBufferData(buffer,music.format,pcm,size,music.rate); check(1); @@ -418,35 +450,35 @@ void AL_PlaySong(char *ptr,int loop) int bf=2,i; ALenum format;ALsizei size;ALsizei freq;ALvoid* data; - if(!context)return; + if (!context)return; Bmemset(&music,0,sizeof(sounddef1)); - switch(*ptr) + switch (*ptr) { - case 'O':music.type=1;break; - default: return; + case 'O':music.type=1;break; + default: return; } music.def.size=Musicsize; music.loop=loop; music.def.ptrsnd=ptr; - switch(music.type) + switch (music.type) { - case 1: - if((i=ov_open_callbacks(&music.def,&music.def.oggStream,0,0,cb))<0) - { - Bmemset(&music,0,sizeof(sounddef1)); - initprintf("Music error: %s\n",AL_ErrorString(i)); - return; - } - vorbisInfo=ov_info(&music.def.oggStream,-1); - if(!vorbisInfo) - { - initprintf("Music error: vorbisInfo\n"); - Bmemset(&music,0,sizeof(sounddef1)); - return; - } - music.rate=vorbisInfo->rate; - music.format=(vorbisInfo->channels==1)?AL_FORMAT_MONO16:AL_FORMAT_STEREO16;break; + case 1: + if ((i=ov_open_callbacks(&music.def,&music.def.oggStream,0,0,cb))<0) + { + Bmemset(&music,0,sizeof(sounddef1)); + initprintf("Music error: %s\n",AL_ErrorString(i)); + return; + } + vorbisInfo=ov_info(&music.def.oggStream,-1); + if (!vorbisInfo) + { + initprintf("Music error: vorbisInfo\n"); + Bmemset(&music,0,sizeof(sounddef1)); + return; + } + music.rate=vorbisInfo->rate; + music.format=(vorbisInfo->channels==1)?AL_FORMAT_MONO16:AL_FORMAT_STEREO16;break; } ALdoing="Open"; @@ -454,12 +486,12 @@ void AL_PlaySong(char *ptr,int loop) balGenSources(1,&music.source);check(1); balSourcei(music.source,AL_SOURCE_RELATIVE,AL_TRUE); - switch(music.type) + switch (music.type) { - case 1: stream(music.buffers[0]); - if(!stream(music.buffers[1]))bf=1; - balSourceQueueBuffers(music.source,bf,music.buffers); - break; + case 1: stream(music.buffers[0]); + if (!stream(music.buffers[1]))bf=1; + balSourceQueueBuffers(music.source,bf,music.buffers); + break; } AL_SetMusicVolume(AL_MusicVolume); diff --git a/polymer/eduke32/source/jaudiolib/sdlmusic.c b/polymer/eduke32/source/jaudiolib/sdlmusic.c index 8121b06b0..04bd16846 100755 --- a/polymer/eduke32/source/jaudiolib/sdlmusic.c +++ b/polymer/eduke32/source/jaudiolib/sdlmusic.c @@ -54,9 +54,9 @@ Adapted to work with JonoF's port by James Bentler (bentler@cs.umn.edu) #include #include "music.h" -#ifdef USE_OPENAL -#include "openal.h" -#endif +#ifdef USE_OPENAL +#include "openal.h" +#endif #define __FX_TRUE (1 == 1) #define __FX_FALSE (!__FX_TRUE) @@ -324,7 +324,7 @@ int MUSIC_Init(int SoundCard, int Address) // Use an external MIDI player if the user has specified to do so char *command = getenv("EDUKE32_MIDI_CMD"); external_midi = (command != NULL && command[0] != 0); - if(external_midi) + if (external_midi) Mix_SetMusicCMD(command); init_debugging(); @@ -349,7 +349,7 @@ int MUSIC_Shutdown(void) musdebug("shutting down sound subsystem."); // TODO - make sure this is being called from the menu -- SA - if(external_midi) + if (external_midi) Mix_SetMusicCMD(NULL); MUSIC_StopSong(); @@ -427,7 +427,11 @@ void MUSIC_Continue(void) #endif if (Mix_PausedMusic()) Mix_ResumeMusic(); - else if (music_songdata) + else if (music_songdata +#ifdef USE_OPENAL + && (openal_disabled || AL_isntALmusic()) +#endif + ) MUSIC_PlaySong((unsigned char *)music_songdata, MUSIC_PlayOnce); } // MUSIC_Continue @@ -471,12 +475,6 @@ int MUSIC_StopSong(void) int MUSIC_PlaySong(unsigned char *song, int loopflag) { //SDL_RWops *rw; -#ifdef USE_OPENAL - if (!openal_disabled) - AL_PlaySong((char *)song,loopflag); - if(openal_disabled || AL_isntALmusic()) -#endif - { MUSIC_StopSong(); music_songdata = (char *)song; @@ -494,13 +492,12 @@ int MUSIC_PlaySong(unsigned char *song, int loopflag) music_musicchunk = Mix_LoadMUS_RW(rw); Mix_PlayMusic(music_musicchunk, (loopflag == MUSIC_PlayOnce) ? 0 : -1); */ - } return(MUSIC_Ok); } // MUSIC_PlaySong // Duke3D-specific. --ryan. -void PlayMusic(char *_filename) +void PlayMusic(char *_filename, int loopflag) { //char filename[MAX_PATH]; //strcpy(filename, _filename); @@ -512,64 +509,89 @@ void PlayMusic(char *_filename) void *song; int rc; - MUSIC_StopSong(); - - // Read from a groupfile, write it to disk so SDL_mixer can read it. - // Lame. --ryan. - handle = kopen4load(_filename, 0); - if (handle == -1) - return; - - size = kfilelength(handle); - if (size == -1) +#ifdef USE_OPENAL + if (!openal_disabled) { - kclose(handle); - return; - } // if + short fp; + int l; - song = malloc(size); - if (song == NULL) + fp = kopen4load(_filename,0); + + if (fp == -1) return; + + l = kfilelength(fp); + MUSIC_StopSong(); + Musicsize=0; + if (!MusicPtr)MusicPtr=Bcalloc(1,l); + else MusicPtr=Brealloc(MusicPtr,l); + Musicsize=l; + + kread(fp, MusicPtr, l); + kclose(fp); + AL_PlaySong((char *)MusicPtr,loopflag); + } + if (openal_disabled || AL_isntALmusic()) +#endif { - kclose(handle); - return; - } // if - - rc = kread(handle, song, size); - kclose(handle); - if (rc != size) - { - Bfree(song); - return; - } // if - - // save the file somewhere, so SDL_mixer can load it - { - char *user = getenv("USERNAME"); - - if (user) Bsprintf(tempbuf,"duke3d-%s.%d.mid",user,getpid()); - else Bsprintf(tempbuf,"duke3d.%d.mid",getpid()); - - GetUnixPathFromEnvironment(filename, BMAX_PATH, tempbuf); - - handle = SafeOpenWrite(filename, filetype_binary); + MUSIC_StopSong(); + // Read from a groupfile, write it to disk so SDL_mixer can read it. + // Lame. --ryan. + handle = kopen4load(_filename, 0); if (handle == -1) return; - midifn = Bstrdup(filename); - - SafeWrite(handle, song, size); - close(handle); - Bfree(song); - - //music_songdata = song; - - music_musicchunk = Mix_LoadMUS(filename); - if (music_musicchunk != NULL) + size = kfilelength(handle); + if (size == -1) { - // !!! FIXME: I set the music to loop. Hope that's okay. --ryan. - Mix_PlayMusic(music_musicchunk, -1); + kclose(handle); + return; } // if + + song = malloc(size); + if (song == NULL) + { + kclose(handle); + return; + } // if + + rc = kread(handle, song, size); + kclose(handle); + if (rc != size) + { + Bfree(song); + return; + } // if + + // save the file somewhere, so SDL_mixer can load it + { + char *user = getenv("USERNAME"); + + if (user) Bsprintf(tempbuf,"duke3d-%s.%d.mid",user,getpid()); + else Bsprintf(tempbuf,"duke3d.%d.mid",getpid()); + + GetUnixPathFromEnvironment(filename, BMAX_PATH, tempbuf); + + handle = SafeOpenWrite(filename, filetype_binary); + + if (handle == -1) + return; + + midifn = Bstrdup(filename); + + SafeWrite(handle, song, size); + close(handle); + Bfree(song); + + //music_songdata = song; + + music_musicchunk = Mix_LoadMUS(filename); + if (music_musicchunk != NULL) + { + // !!! FIXME: I set the music to loop. Hope that's okay. --ryan. + Mix_PlayMusic(music_musicchunk, -1); + } // if + } } } diff --git a/polymer/eduke32/source/sounds.c b/polymer/eduke32/source/sounds.c index defdc5f1d..ff9529e4e 100644 --- a/polymer/eduke32/source/sounds.c +++ b/polymer/eduke32/source/sounds.c @@ -217,7 +217,7 @@ void playmusic(const char *fn) kclose(fp); MUSIC_PlaySong((unsigned char *)MusicPtr, MUSIC_LoopSong); #else - void PlayMusic(char *_filename); + void PlayMusic(char *_filename, int loopflag); if (fn == NULL) return; @@ -226,7 +226,7 @@ void playmusic(const char *fn) // FIXME: I need this to get the music volume initialized (not sure why) -- Jim Bentler MUSIC_SetVolume(ud.config.MusicVolume); - PlayMusic((char *)fn); + PlayMusic((char *)fn, MUSIC_LoopSong); #endif }