@ -42,7 +42,6 @@ extern FMOD_SYSTEM *fmod_system;
FMOD_CHANNELGROUP * bgm_channelGroup = NULL ;
FMOD_CHANNELGROUP * bgm_channelGroup = NULL ;
FMOD_CHANNEL * bgm_channel = NULL ;
FMOD_CHANNEL * bgm_channel = NULL ;
FMOD_SOUND * bgm_sound = NULL ;
FMOD_SOUND * bgm_sound = NULL ;
byte * bgm_data = NULL ;
static const char * extensions [ ] =
static const char * extensions [ ] =
{
{
@ -136,9 +135,7 @@ void BGM_Shutdown (void)
static qboolean BGM_PlayStream ( const char * filename )
static qboolean BGM_PlayStream ( const char * filename )
{
{
FILE * f ;
int len ;
FMOD_CREATESOUNDEXINFO exinfo ;
char netpath [ MAX_OSPATH ] ;
FMOD_RESULT result ;
FMOD_RESULT result ;
if ( ! fmod_system | | ! bgm_channelGroup )
if ( ! fmod_system | | ! bgm_channelGroup )
@ -147,28 +144,13 @@ static qboolean BGM_PlayStream(const char *filename)
return false ;
return false ;
}
}
len = COM_FOpenFile ( filename , & f , NULL ) ;
fclose ( f ) ;
if ( len < 1 )
if ( ! COM_FullFilePath ( filename , netpath , sizeof ( netpath ) ) )
{
{
Con_Printf ( " Could not open BGM file %s, file not found \n " , filename ) ;
Con_Printf ( " Could not open BGM file %s, file not found \n " , filename ) ;
return false ;
return false ;
}
}
bgm_data = COM_LoadMallocFile ( filename , NULL ) ; / / TODO is there really no better way to pre - cache this data than with malloc ?
if ( ! bgm_data )
{
Con_Printf ( " Failed to load BGM file %s \n " , filename ) ;
return false ;
}
Con_DPrintf ( " BGM_PlayStream: Successfully loaded %s \n " , filename ) ;
memset ( & exinfo , 0 , sizeof ( FMOD_CREATESOUNDEXINFO ) ) ;
exinfo . cbsize = sizeof ( FMOD_CREATESOUNDEXINFO ) ;
exinfo . length = len ;
result = FMOD_System_CreateSound ( fmod_system , ( const char * ) bgm_data , FMOD_OPENMEMORY | FMOD_2D , & exinfo , & bgm_sound ) ;
result = FMOD_System_CreateSound ( fmod_system , netpath , FMOD_CREATESTREAM | FMOD_2D , NULL , & bgm_sound ) ;
if ( result ! = FMOD_OK | | ! bgm_sound )
if ( result ! = FMOD_OK | | ! bgm_sound )
{
{
Con_Printf ( " Failed to create FMOD sound: %s \n " , FMOD_ErrorString ( result ) ) ;
Con_Printf ( " Failed to create FMOD sound: %s \n " , FMOD_ErrorString ( result ) ) ;
@ -176,6 +158,8 @@ static qboolean BGM_PlayStream(const char *filename)
return false ;
return false ;
}
}
Con_DPrintf ( " BGM_PlayStream: Successfully loaded %s \n " , filename ) ;
result = FMOD_System_PlaySound ( fmod_system , bgm_sound , bgm_channelGroup , false , & bgm_channel ) ;
result = FMOD_System_PlaySound ( fmod_system , bgm_sound , bgm_channelGroup , false , & bgm_channel ) ;
if ( result ! = FMOD_OK | | ! bgm_channel )
if ( result ! = FMOD_OK | | ! bgm_channel )
{
{
@ -298,12 +282,6 @@ void BGM_Stop(void)
FMOD_Sound_Release ( bgm_sound ) ;
FMOD_Sound_Release ( bgm_sound ) ;
bgm_sound = NULL ;
bgm_sound = NULL ;
}
}
if ( bgm_data )
{
free ( bgm_data ) ;
bgm_data = NULL ;
}
}
}
void BGM_Pause ( void )
void BGM_Pause ( void )