* removed some redundant code from src/data.c:
- the function dataAudioLoad first checked whether the audio system is disabled and if it is sets return buffer (*ppData) to NULL, even though this functionality is already performed by the function it calls (audio_LoadTrackFromBuffer) - this is similar for dataAudioRelease, additionally I moved the (low-level) call FREE(psTrack) to lib/sound/track.c which is also the file in which it gets malloc'ed * while at it I directly changed sound_ReleaseTrack from returning BOOL to void since its return value was meaningless anyway (would always be TRUE no matter what), not to mention it was completely ignored by its only caller (dataAudioRelease) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1150 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
bbc588699d
commit
c07332714b
|
@ -262,7 +262,7 @@ BOOL sound_LoadTrackFromFile(char szFileName[])
|
||||||
// =======================================================================================================================
|
// =======================================================================================================================
|
||||||
// =======================================================================================================================
|
// =======================================================================================================================
|
||||||
//
|
//
|
||||||
BOOL sound_ReleaseTrack( TRACK *psTrack )
|
void sound_ReleaseTrack( TRACK *psTrack )
|
||||||
{
|
{
|
||||||
//~~~~~~~~~~~
|
//~~~~~~~~~~~
|
||||||
SDWORD iTrack;
|
SDWORD iTrack;
|
||||||
|
@ -282,7 +282,7 @@ BOOL sound_ReleaseTrack( TRACK *psTrack )
|
||||||
}
|
}
|
||||||
|
|
||||||
sound_FreeTrack( psTrack );
|
sound_FreeTrack( psTrack );
|
||||||
return TRUE;
|
FREE( psTrack );
|
||||||
}
|
}
|
||||||
|
|
||||||
//*
|
//*
|
||||||
|
|
|
@ -117,7 +117,7 @@ BOOL sound_LoadTrackFromFile(char szFileName[]);
|
||||||
TRACK * sound_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize);
|
TRACK * sound_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize);
|
||||||
BOOL sound_SetTrackVals( TRACK *psTrack, BOOL bLoop, SDWORD iTrack,
|
BOOL sound_SetTrackVals( TRACK *psTrack, BOOL bLoop, SDWORD iTrack,
|
||||||
SDWORD iVol, SDWORD iPriority, SDWORD iAudibleRadius);
|
SDWORD iVol, SDWORD iPriority, SDWORD iAudibleRadius);
|
||||||
BOOL sound_ReleaseTrack( TRACK * psTrack );
|
void sound_ReleaseTrack( TRACK * psTrack );
|
||||||
|
|
||||||
void sound_StopTrack( AUDIO_SAMPLE *psSample );
|
void sound_StopTrack( AUDIO_SAMPLE *psSample );
|
||||||
void sound_PauseTrack( AUDIO_SAMPLE *psSample );
|
void sound_PauseTrack( AUDIO_SAMPLE *psSample );
|
||||||
|
|
30
src/data.c
30
src/data.c
|
@ -989,36 +989,23 @@ void dataTexPageRelease(void *pData)
|
||||||
/* Load an audio file */
|
/* Load an audio file */
|
||||||
BOOL dataAudioLoad(char *pBuffer, UDWORD size, void **ppData)
|
BOOL dataAudioLoad(char *pBuffer, UDWORD size, void **ppData)
|
||||||
{
|
{
|
||||||
TRACK *psTrack;
|
// If audio is disabled or a track can't be constructed the return value will be NULL
|
||||||
|
*ppData = audio_LoadTrackFromBuffer( pBuffer, size );
|
||||||
|
|
||||||
if ( audio_Disabled() == TRUE )
|
if (*ppData == NULL)
|
||||||
{
|
|
||||||
*ppData = NULL;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else if ( (psTrack = audio_LoadTrackFromBuffer( pBuffer, size )) == NULL )
|
|
||||||
{
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
/* save track data */
|
|
||||||
*ppData = psTrack;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dataAudioRelease( void *pData )
|
void dataAudioRelease( void *pData )
|
||||||
{
|
{
|
||||||
if (audio_Disabled() == FALSE)
|
TRACK *psTrack = (TRACK *) pData;
|
||||||
{
|
|
||||||
TRACK *psTrack = (TRACK *) pData;
|
|
||||||
|
|
||||||
ASSERT( PTRVALID(psTrack, sizeof(TRACK)),
|
ASSERT( PTRVALID(psTrack, sizeof(TRACK)),
|
||||||
"dataAudioRelease: invalid track pointer" );
|
"dataAudioRelease: invalid track pointer" );
|
||||||
|
|
||||||
audio_ReleaseTrack( psTrack );
|
audio_ReleaseTrack( psTrack );
|
||||||
FREE( psTrack );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1294,6 +1281,3 @@ BOOL dataInitLoadFuncs(void)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue