Remove unnecessary "Playing" member of VoiceNode struct

git-svn-id: https://svn.eduke32.com/eduke32@7124 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2018-10-25 23:33:04 +00:00
parent 16c9a58daa
commit 51d4347e2c
7 changed files with 12 additions and 53 deletions

View File

@ -144,7 +144,6 @@ typedef struct VoiceNode
uint32_t SamplingRate;
uint32_t RateScale;
uint32_t position;
int32_t Playing;
int32_t Paused;
int32_t handle;

View File

@ -316,8 +316,6 @@ static playbackstatus MV_GetNextFLACBlock(VoiceNode *voice)
FLAC__StreamDecoderState decode_state;
// FLAC__bool decode_status;
voice->Playing = TRUE;
if ((FLAC__uint64)(uintptr_t)voice->LoopEnd > 0 && fd->sample_pos >= (FLAC__uint64)(uintptr_t)voice->LoopEnd)
if (!FLAC__stream_decoder_seek_absolute(fd->stream, (FLAC__uint64)(uintptr_t)voice->LoopStart))
MV_Printf("MV_GetNextFLACBlock FLAC__stream_decoder_seek_absolute: LOOP_START %ul, LOOP_END %ul\n",
@ -330,7 +328,6 @@ static playbackstatus MV_GetNextFLACBlock(VoiceNode *voice)
if (!decode_status)
{
MV_Printf("MV_GetNextFLACBlock: %s\n", FLAC__StreamDecoderStateString[decode_state]);
voice->Playing = FALSE;
return NoMoreData;
}
*/
@ -350,10 +347,7 @@ static playbackstatus MV_GetNextFLACBlock(VoiceNode *voice)
(FLAC__uint64)(uintptr_t)voice->LoopStart);
}
else
{
voice->Playing = FALSE;
return NoMoreData;
}
}
#if 0
@ -489,7 +483,6 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t length, int32_t loopstart, int32_t loope
voice->priority = priority;
voice->callbackval = callbackval;
voice->Playing = TRUE;
voice->Paused = FALSE;
voice->LoopStart = 0;

View File

@ -34,10 +34,7 @@ static playbackstatus MV_GetNextWAVBlock(VoiceNode *voice)
if (voice->BlockLength == 0)
{
if (voice->LoopStart == NULL)
{
voice->Playing = FALSE;
return NoMoreData;
}
voice->BlockLength = voice->LoopSize;
voice->NextBlock = voice->LoopStart;
@ -76,7 +73,6 @@ static playbackstatus MV_GetNextVOCBlock(VoiceNode *voice)
const uint8_t *ptr = (uint8_t const *)voice->NextBlock;
voice->Playing = TRUE;
voice->Paused = FALSE;
int voicemode = 0;
@ -91,8 +87,7 @@ static playbackstatus MV_GetNextVOCBlock(VoiceNode *voice)
// Stop playing if we get a NULL pointer
if (ptr == NULL)
{
voice->Playing = FALSE;
done = TRUE;
done = 2;
break;
}
@ -121,8 +116,7 @@ end_of_data:
if ((voice->LoopStart == NULL) ||
((intptr_t) voice->LoopStart >= ((intptr_t) ptr - 4)))
{
voice->Playing = FALSE;
done = TRUE;
done = 2;
}
else
{
@ -254,8 +248,7 @@ end_of_data:
default :
// Unknown data. Probably not a VOC file.
voice->Playing = FALSE;
done = TRUE;
done = 2;
break;
}
@ -263,7 +256,7 @@ end_of_data:
}
while (!done);
if (voice->Playing)
if (done != 2)
{
voice->NextBlock = (char const *)ptr + blocklength;
voice->sound = (char const *)ptr;
@ -397,7 +390,6 @@ int32_t MV_PlayWAV(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
voice->rawdataptr = (uint8_t *)ptr;
voice->ptrlength = length;
voice->Playing = TRUE;
voice->Paused = FALSE;
voice->LoopCount = 0;
voice->position = 0;
@ -464,7 +456,6 @@ int32_t MV_PlayVOC(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
voice->rawdataptr = (uint8_t *)ptr;
voice->ptrlength = length;
voice->Playing = TRUE;
voice->Paused = FALSE;
voice->wavetype = FMT_VOC;
voice->bits = 8;

View File

@ -135,12 +135,12 @@ const char *MV_ErrorString(int32_t ErrorNumber)
}
}
static void MV_Mix(VoiceNode *voice, int const buffer)
static bool MV_Mix(VoiceNode *voice, int const buffer)
{
/* cheap fix for a crash under 64-bit linux */
/* v v v v */
if (voice->length == 0 && (voice->GetSound == NULL || voice->GetSound(voice) != KeepPlaying))
return;
return false;
int32_t length = MV_MIXBUFFERSIZE;
uint32_t FixedPointBufferSize = voice->FixedPointBufferSize;
@ -169,7 +169,7 @@ static void MV_Mix(VoiceNode *voice, int const buffer)
if (position >= voice->length)
{
voice->GetSound(voice);
return;
return true;
}
voclength = (voice->length - position + rate - voice->channels) / rate;
@ -193,8 +193,8 @@ static void MV_Mix(VoiceNode *voice, int const buffer)
if (voice->position >= voice->length)
{
// Get the next block of sound
if (voice->GetSound(voice) != KeepPlaying)
return;
if (voice->GetSound(voice) == NoMoreData)
return false;
if (length > (voice->channels - 1))
{
@ -203,6 +203,8 @@ static void MV_Mix(VoiceNode *voice, int const buffer)
}
}
} while (length > 0);
return true;
}
void MV_PlayVoice(VoiceNode *voice)
@ -314,10 +316,8 @@ static void MV_ServiceVoc(void)
MV_BufferEmpty[ MV_MixPage ] = FALSE;
MV_Mix(voice, MV_MixPage);
// Is this voice done?
if (!voice->Playing)
if (!MV_Mix(voice, MV_MixPage))
{
//JBF: prevent a deadlock caused by MV_StopVoice grabbing the mutex again
//MV_StopVoice( voice );

View File

@ -226,8 +226,6 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice)
{
int bitstream;
voice->Playing = TRUE;
int32_t bytesread = 0;
vorbis_data *vd = (vorbis_data *)voice->rawdataptr;
do
@ -282,16 +280,12 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice)
else if (bytes < 0)
{
MV_Printf("MV_GetNextVorbisBlock ov_read: err %d\n", bytes);
voice->Playing = FALSE;
return NoMoreData;
}
} while (bytesread < BLOCKSIZE);
if (bytesread == 0)
{
voice->Playing = FALSE;
return NoMoreData;
}
if (bitstream != vd->lastbitstream)
{
@ -299,10 +293,7 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice)
vi = ov_info(&vd->vf, -1);
if (!vi || (vi->channels != 1 && vi->channels != 2))
{
voice->Playing = FALSE;
return NoMoreData;
}
voice->channels = vi->channels;
voice->SamplingRate = vi->rate;
@ -452,7 +443,6 @@ int32_t MV_PlayVorbis(char *ptr, uint32_t length, int32_t loopstart, int32_t loo
// load loop tags from metadata
MV_GetVorbisCommentLoops(voice, ov_comment(&vd->vf, 0));
voice->Playing = TRUE;
voice->Paused = FALSE;
MV_SetVoicePitch(voice, vi->rate, pitchoffset);

View File

@ -308,8 +308,6 @@ static playbackstatus MV_GetNextXABlock
XASector ssct;
int coding;
voice->Playing = TRUE;
do
{
size_t bytes = xad->length - xad->pos;
@ -353,10 +351,7 @@ static playbackstatus MV_GetNextXABlock
xad->t1 = xad->t2 = xad->t1_x = xad->t2_x = 0;
}
else
{
voice->Playing = FALSE;
return NoMoreData;
}
}
return KeepPlaying;
@ -467,7 +462,6 @@ int32_t MV_PlayXA(char *ptr, uint32_t length, int32_t loopstart, int32_t loopend
voice->bits = 16;
voice->Playing = TRUE;
voice->Paused = FALSE;
voice->LoopStart = 0;

View File

@ -41,16 +41,10 @@ static playbackstatus MV_GetNextXMPBlock(VoiceNode *voice)
{
xmp_restart_module(xmpd->context);
if (xmp_play_frame(xmpd->context) != 0)
{
voice->Playing = FALSE;
return NoMoreData;
}
}
else
{
voice->Playing = FALSE;
return NoMoreData;
}
}
xmp_get_frame_info(xmpd->context, &mi);
@ -62,7 +56,6 @@ static playbackstatus MV_GetNextXMPBlock(VoiceNode *voice)
// voice->length = (mi.buffer_size << 16) / (voice->channels * (voice->bits >> 3));
voice->position = 0;
voice->BlockLength = 0;
voice->Playing = TRUE;
MV_SetVoiceMixMode(voice);
@ -173,7 +166,6 @@ int32_t MV_PlayXMP(char *ptr, uint32_t length, int32_t loopstart, int32_t loopen
voice->channels = 2;
voice->SamplingRate = MV_MixRate;
voice->Playing = TRUE;
voice->Paused = FALSE;
voice->LoopStart = 0;