Change current_queue_sample to a pointer to an AUDIO_SAMPLE instead of
an integer value. This fixes the problem of AL_INVALID being used for invalid values, while it is really a perfectly valid ID for a sample. git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5426 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
4d1d5b4c11
commit
74aeca0093
|
@ -50,7 +50,7 @@
|
|||
#define ATTENUATION_FACTOR 0.0003f
|
||||
|
||||
#ifndef WZ_NOSOUND
|
||||
ALuint current_queue_sample = -1;
|
||||
static AUDIO_SAMPLE *current_queue_sample = NULL;
|
||||
#endif
|
||||
|
||||
static BOOL openal_initialized = false;
|
||||
|
@ -346,12 +346,12 @@ BOOL sound_QueueSamplePlaying( void )
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if ( current_queue_sample == (ALuint)AL_INVALID )
|
||||
if (!current_queue_sample)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
alGetSourcei(current_queue_sample, AL_SOURCE_STATE, &state);
|
||||
alGetSourcei(current_queue_sample->iSample, AL_SOURCE_STATE, &state);
|
||||
|
||||
// Check whether an error occurred while retrieving the state.
|
||||
// If one did, the state returned is useless. So instead of
|
||||
|
@ -364,29 +364,26 @@ BOOL sound_QueueSamplePlaying( void )
|
|||
return true;
|
||||
}
|
||||
|
||||
if (current_queue_sample != (ALuint)AL_INVALID)
|
||||
{
|
||||
SAMPLE_LIST* node = active_samples;
|
||||
SAMPLE_LIST* previous = NULL;
|
||||
SAMPLE_LIST* node = active_samples;
|
||||
SAMPLE_LIST* previous = NULL;
|
||||
|
||||
// We need to remove it from the queue of actively played samples
|
||||
while (node != NULL)
|
||||
// We need to remove it from the queue of actively played samples
|
||||
while (node != NULL)
|
||||
{
|
||||
if (node->curr == current_queue_sample)
|
||||
{
|
||||
if (node->curr->iSample == current_queue_sample)
|
||||
{
|
||||
sound_DestroyIteratedSample(&previous, &node);
|
||||
current_queue_sample = AL_INVALID;
|
||||
return false;
|
||||
}
|
||||
previous = node;
|
||||
if (node)
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
sound_DestroyIteratedSample(&previous, &node);
|
||||
current_queue_sample = NULL;
|
||||
return false;
|
||||
}
|
||||
previous = node;
|
||||
if (node)
|
||||
{
|
||||
node = node->next;
|
||||
}
|
||||
debug(LOG_ERROR, "Sample %u not deleted because it wasn't in the active queue!", current_queue_sample);
|
||||
current_queue_sample = AL_INVALID;
|
||||
}
|
||||
debug(LOG_ERROR, "Sample %u not deleted because it wasn't in the active queue!", current_queue_sample->iSample);
|
||||
current_queue_sample = NULL;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -600,11 +597,11 @@ BOOL sound_Play2DSample( TRACK *psTrack, AUDIO_SAMPLE *psSample, BOOL bQueued )
|
|||
sound_GetError();
|
||||
if ( bQueued )
|
||||
{
|
||||
current_queue_sample = psSample->iSample;
|
||||
current_queue_sample = psSample;
|
||||
}
|
||||
else if ( current_queue_sample == psSample->iSample )
|
||||
else if ( current_queue_sample == psSample )
|
||||
{
|
||||
current_queue_sample = -1;
|
||||
current_queue_sample = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue