2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
|
|
|
Copyright (C) 2005-2007 Warzone Resurrection Project
|
|
|
|
|
|
|
|
Warzone 2100 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.
|
|
|
|
|
|
|
|
Warzone 2100 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 Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-04-11 07:21:45 -07:00
|
|
|
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2007-04-11 07:21:45 -07:00
|
|
|
|
2006-09-23 11:38:12 -07:00
|
|
|
#include "lib/framework/frameresource.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "tracklib.h"
|
2007-07-13 16:25:29 -07:00
|
|
|
#include "audio_id.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//*
|
|
|
|
//
|
|
|
|
// defines
|
|
|
|
#define MAX_TRACKS ( 600 )
|
|
|
|
|
|
|
|
//*
|
|
|
|
//
|
|
|
|
// static global variables
|
|
|
|
// array of pointers to sound effects
|
|
|
|
static TRACK **g_apTrack;
|
|
|
|
|
|
|
|
// number of tracks loaded
|
|
|
|
static SDWORD g_iCurTracks = 0;
|
|
|
|
|
|
|
|
// flag set when system is active (for callbacks etc)
|
|
|
|
static BOOL g_bSystemActive = FALSE;
|
|
|
|
static AUDIO_CALLBACK g_pStopTrackCallback = NULL;
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
2007-07-13 16:15:24 -07:00
|
|
|
BOOL sound_Init()
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
g_iCurTracks = 0;
|
2007-06-21 06:03:52 -07:00
|
|
|
if (!sound_InitLibrary())
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-06-21 06:03:52 -07:00
|
|
|
debug(LOG_ERROR, "Cannot init sound library");
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-07-13 15:11:04 -07:00
|
|
|
// init audio array (with NULL pointers; which calloc ensures by setting all allocated memory to zero)
|
|
|
|
g_apTrack = calloc(MAX_TRACKS, sizeof(TRACK*));
|
|
|
|
if (!g_apTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-13 15:11:04 -07:00
|
|
|
debug(LOG_ERROR, "sound_Init: Out of memory");
|
|
|
|
abort();
|
|
|
|
return FALSE;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// set system active flag for callbacks
|
|
|
|
g_bSystemActive = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_Shutdown( void )
|
|
|
|
{
|
2007-04-08 12:01:19 -07:00
|
|
|
free( g_apTrack );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// set inactive flag to prevent callbacks coming after shutdown
|
|
|
|
g_bSystemActive = FALSE;
|
|
|
|
sound_ShutdownLibrary();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_GetSystemActive( void )
|
|
|
|
{
|
|
|
|
return g_bSystemActive;
|
|
|
|
}
|
|
|
|
|
2007-07-13 16:39:40 -07:00
|
|
|
/** Retrieves loaded audio files and retrieves a TRACK from them on which some values are set and returns their respective ID numbers
|
|
|
|
* \param fileName the filename of the track
|
|
|
|
* \param loop whether the track should be looped until explicitly stopped
|
|
|
|
* \param volume the volume this track should be played on (range is 0-100)
|
|
|
|
* \param audibleRadius the radius from the source of sound where it can be heard
|
2007-09-23 14:43:57 -07:00
|
|
|
* \return a non-zero value representing the track id number when succesfull, zero when the file is not found or no more tracks can be loaded (i.e. the limit is reached)
|
2007-07-13 16:39:40 -07:00
|
|
|
*/
|
|
|
|
unsigned int sound_SetTrackVals(const char* fileName, BOOL loop, unsigned int volume, unsigned int audibleRadius)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-09-23 14:43:57 -07:00
|
|
|
unsigned int trackID;
|
2007-11-22 10:35:03 -08:00
|
|
|
TRACK* psTrack;
|
|
|
|
|
2007-11-26 07:57:56 -08:00
|
|
|
if (fileName == NULL || strlen(fileName) == 0) // check for empty filename. This is a non fatal error.
|
2007-11-22 10:35:03 -08:00
|
|
|
{
|
2007-11-26 07:57:56 -08:00
|
|
|
debug(LOG_ERROR, "sound_SetTrackVals: fileName is %s", (fileName == NULL) ? "a NULL pointer" : "empty");
|
2007-11-22 10:35:03 -08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
psTrack = resGetData( "WAV", fileName );
|
2007-07-13 16:39:40 -07:00
|
|
|
if (psTrack == NULL)
|
2007-04-05 12:42:00 -07:00
|
|
|
{
|
2007-07-13 16:39:40 -07:00
|
|
|
debug(LOG_ERROR, "sound_SetTrackVals: track %s resource not found", fileName);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get pre-assigned ID or produce one
|
|
|
|
trackID = audio_GetIDFromStr(fileName);
|
|
|
|
if (trackID == NO_SOUND)
|
|
|
|
{
|
|
|
|
// No pre-assigned ID available, produce one
|
|
|
|
trackID = sound_GetAvailableID();
|
2007-04-05 12:42:00 -07:00
|
|
|
}
|
2007-04-05 11:43:42 -07:00
|
|
|
|
2007-07-13 16:39:40 -07:00
|
|
|
if (g_apTrack[trackID] != NULL)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-10-24 14:11:29 -07:00
|
|
|
debug(LOG_ERROR, "sound_SetTrackVals: track %i already set (filename: \"%s\"\n", trackID, g_apTrack[trackID]->fileName);
|
2007-04-05 11:43:42 -07:00
|
|
|
abort();
|
2007-07-13 16:39:40 -07:00
|
|
|
|
|
|
|
return 0;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-04-05 11:43:42 -07:00
|
|
|
// set track members
|
2007-07-13 16:39:40 -07:00
|
|
|
psTrack->bLoop = loop;
|
|
|
|
psTrack->iVol = volume;
|
|
|
|
psTrack->iAudibleRadius = audibleRadius;
|
|
|
|
|
|
|
|
// RAII: Make sure to initialize all values (we don't want undefined values)!
|
|
|
|
psTrack->iTime = 0;
|
2007-04-05 11:43:42 -07:00
|
|
|
psTrack->iTimeLastFinished = 0;
|
|
|
|
psTrack->iNumPlaying = 0;
|
|
|
|
|
|
|
|
// set global
|
2007-07-13 16:39:40 -07:00
|
|
|
g_apTrack[trackID] = psTrack;
|
2007-04-05 11:43:42 -07:00
|
|
|
|
2007-07-13 16:39:40 -07:00
|
|
|
// increment counter for amount of loaded tracks
|
|
|
|
++g_iCurTracks;
|
2007-04-05 11:43:42 -07:00
|
|
|
|
2007-07-13 16:39:40 -07:00
|
|
|
return trackID;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
2007-02-19 13:52:27 -08:00
|
|
|
void sound_ReleaseTrack( TRACK *psTrack )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-06-21 06:03:52 -07:00
|
|
|
TRACK** currTrack;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-06-21 06:03:52 -07:00
|
|
|
// This is here to save CPU wasted by the loop below;
|
|
|
|
// Calling this function with psTrack = NULL is perfectly legal,
|
|
|
|
// with or without this check
|
2007-04-08 14:39:24 -07:00
|
|
|
if (!psTrack)
|
|
|
|
return;
|
|
|
|
|
2007-06-21 06:03:52 -07:00
|
|
|
// Run through the list of tracks and set the pointer to the track which is to be released to NULL
|
2007-07-13 15:11:04 -07:00
|
|
|
for (currTrack = &g_apTrack[0]; currTrack != &g_apTrack[MAX_TRACKS]; ++currTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-06-21 06:03:52 -07:00
|
|
|
if (*currTrack == psTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-06-21 06:03:52 -07:00
|
|
|
*currTrack = NULL;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sound_FreeTrack( psTrack );
|
2007-04-08 12:01:19 -07:00
|
|
|
free( psTrack );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_CheckAllUnloaded( void )
|
|
|
|
{
|
2007-06-21 06:03:52 -07:00
|
|
|
TRACK** currTrack;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-06-21 06:03:52 -07:00
|
|
|
for (currTrack = &g_apTrack[0]; currTrack != &g_apTrack[MAX_TRACKS]; ++currTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-10-24 14:11:29 -07:00
|
|
|
ASSERT(*currTrack == NULL, "sound_CheckAllUnloaded: a track is not unloaded yet (%s); check audio.cfg for duplicate IDs", (*currTrack)->fileName);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_TrackLooped( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
return g_apTrack[iTrack]->bLoop;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
SDWORD sound_GetNumPlaying( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
return g_apTrack[iTrack]->iNumPlaying;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_CheckTrack( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
if ( iTrack < 0 || iTrack > g_iCurTracks - 1 )
|
|
|
|
{
|
2006-11-04 13:05:31 -08:00
|
|
|
debug( LOG_SOUND, "sound_CheckTrack: track number %i outside max %i\n", iTrack, g_iCurTracks );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( g_apTrack[iTrack] == NULL )
|
|
|
|
{
|
2006-11-04 13:05:31 -08:00
|
|
|
debug( LOG_SOUND, "sound_CheckTrack: track %i NULL\n", iTrack );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
SDWORD sound_GetTrackTime( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
return g_apTrack[iTrack]->iTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
SDWORD sound_GetTrackVolume( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
return g_apTrack[iTrack]->iVol;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
SDWORD sound_GetTrackAudibleRadius( SDWORD iTrack )
|
|
|
|
{
|
2007-07-14 12:56:10 -07:00
|
|
|
sound_CheckTrack(iTrack);
|
2007-06-28 10:47:08 -07:00
|
|
|
return g_apTrack[iTrack]->iAudibleRadius;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
2006-09-17 13:39:25 -07:00
|
|
|
const char *sound_GetTrackName( SDWORD iTrack )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-14 07:19:14 -07:00
|
|
|
// If we get an invalid track ID or there are
|
|
|
|
// currently no tracks loaded then return NULL
|
2007-08-08 04:23:21 -07:00
|
|
|
if (iTrack <= 0
|
|
|
|
|| iTrack >= MAX_TRACKS
|
|
|
|
|| iTrack == SAMPLE_NOT_FOUND
|
2007-07-14 07:19:14 -07:00
|
|
|
|| g_apTrack == NULL)
|
2007-04-05 12:42:00 -07:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-05 13:19:58 -07:00
|
|
|
|
2007-07-14 07:19:14 -07:00
|
|
|
ASSERT(g_apTrack[iTrack] != NULL, "sound_GetTrackName: unallocated track (id number: %u)", iTrack);
|
2007-10-24 14:11:29 -07:00
|
|
|
return g_apTrack[iTrack] ? g_apTrack[iTrack]->fileName : "unallocated";
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_Play2DTrack( AUDIO_SAMPLE *psSample, BOOL bQueued )
|
|
|
|
{
|
|
|
|
TRACK *psTrack;
|
|
|
|
|
2007-07-14 12:12:46 -07:00
|
|
|
// Check to make sure the requested track is loaded
|
2006-11-04 13:05:31 -08:00
|
|
|
if (!sound_CheckTrack(psSample->iTrack))
|
2007-04-05 12:42:00 -07:00
|
|
|
{
|
2007-04-05 13:19:58 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-04 13:05:31 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
psTrack = g_apTrack[psSample->iTrack];
|
|
|
|
return sound_Play2DSample( psTrack, psSample, bQueued );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
BOOL sound_Play3DTrack( AUDIO_SAMPLE *psSample )
|
|
|
|
{
|
|
|
|
TRACK *psTrack;
|
|
|
|
|
2007-07-14 12:12:46 -07:00
|
|
|
// Check to make sure the requested track is loaded
|
2006-11-04 13:05:31 -08:00
|
|
|
if (!sound_CheckTrack(psSample->iTrack))
|
2007-04-05 12:42:00 -07:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2006-11-04 13:05:31 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
psTrack = g_apTrack[psSample->iTrack];
|
|
|
|
return sound_Play3DSample( psTrack, psSample );
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_StopTrack( AUDIO_SAMPLE *psSample )
|
|
|
|
{
|
2007-04-09 05:50:48 -07:00
|
|
|
ASSERT( psSample != NULL, "sound_StopTrack: sample pointer invalid\n" );
|
|
|
|
|
2007-06-06 10:09:23 -07:00
|
|
|
#ifndef WZ_NOSOUND
|
2007-12-13 15:16:03 -08:00
|
|
|
sound_StopSample(psSample);
|
2007-06-06 10:09:23 -07:00
|
|
|
#endif
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// do stopped callback
|
|
|
|
if ( g_pStopTrackCallback != NULL && psSample->psObj != NULL )
|
|
|
|
{
|
2007-04-12 03:31:11 -07:00
|
|
|
g_pStopTrackCallback( psSample->psObj );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_PauseTrack( AUDIO_SAMPLE *psSample )
|
|
|
|
{
|
2007-06-06 10:09:23 -07:00
|
|
|
#ifndef WZ_NOSOUND
|
2007-12-13 15:16:03 -08:00
|
|
|
sound_StopSample(psSample);
|
2007-06-06 10:09:23 -07:00
|
|
|
#endif
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_FinishedCallback( AUDIO_SAMPLE *psSample )
|
|
|
|
{
|
2007-04-09 05:50:48 -07:00
|
|
|
ASSERT( psSample != NULL, "sound_FinishedCallback: sample pointer invalid\n" );
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
if ( g_apTrack[psSample->iTrack] != NULL )
|
|
|
|
{
|
|
|
|
g_apTrack[psSample->iTrack]->iTimeLastFinished = sound_GetGameTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
// call user callback if specified
|
|
|
|
if ( psSample->pCallback != NULL )
|
|
|
|
{
|
2007-04-12 03:31:11 -07:00
|
|
|
psSample->pCallback(psSample->psObj);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2007-04-12 10:42:15 -07:00
|
|
|
// set finished flag
|
|
|
|
psSample->bFinishedPlaying = TRUE;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
2007-07-14 12:12:46 -07:00
|
|
|
SDWORD sound_GetTrackID(TRACK* psTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-14 12:12:46 -07:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (psTrack == NULL)
|
|
|
|
{
|
|
|
|
return SAMPLE_NOT_FOUND;
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
// find matching track
|
2007-07-14 12:12:46 -07:00
|
|
|
for (i = 0; i < MAX_TRACKS; ++i)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-14 12:12:46 -07:00
|
|
|
if (g_apTrack[i] == psTrack)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if matching track found return it else find empty track
|
2007-07-14 12:12:46 -07:00
|
|
|
if (i >= MAX_TRACKS)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
return SAMPLE_NOT_FOUND;
|
|
|
|
}
|
2007-04-05 13:19:58 -07:00
|
|
|
|
|
|
|
return i;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
2007-07-13 16:25:29 -07:00
|
|
|
SDWORD sound_GetAvailableID()
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-13 16:39:40 -07:00
|
|
|
unsigned int i;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2007-07-13 16:25:29 -07:00
|
|
|
// Iterate through the list of tracks until we find an unused ID slot
|
|
|
|
for (i = ID_SOUND_NEXT; i < MAX_TRACKS; ++i)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2007-07-13 16:25:29 -07:00
|
|
|
if (g_apTrack[i] == NULL)
|
2007-06-28 10:47:08 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-07-13 16:25:29 -07:00
|
|
|
ASSERT(i < MAX_TRACKS, "sound_GetTrackID: unused track not found!");
|
2007-07-13 16:39:40 -07:00
|
|
|
if ( i >= MAX_TRACKS )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
return SAMPLE_NOT_ALLOCATED;
|
|
|
|
}
|
2007-04-05 13:19:58 -07:00
|
|
|
|
|
|
|
return i;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_SetStoppedCallback( AUDIO_CALLBACK pStopTrackCallback )
|
|
|
|
{
|
|
|
|
g_pStopTrackCallback = pStopTrackCallback;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
UDWORD sound_GetTrackTimeLastFinished( SDWORD iTrack )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
return g_apTrack[iTrack]->iTimeLastFinished;
|
|
|
|
}
|
|
|
|
|
|
|
|
//*
|
|
|
|
// =======================================================================================================================
|
|
|
|
// =======================================================================================================================
|
|
|
|
//
|
|
|
|
void sound_SetTrackTimeLastFinished( SDWORD iTrack, UDWORD iTime )
|
|
|
|
{
|
|
|
|
sound_CheckTrack( iTrack );
|
|
|
|
g_apTrack[iTrack]->iTimeLastFinished = iTime;
|
|
|
|
}
|