int32_t MV_KillAllVoices(void) { if (!MV_Installed) return MV_Error; DisableInterrupts(); if (&VoiceList == VoiceList.next) { RestoreInterrupts(); return MV_Ok; } VoiceNode * voice = VoiceList.prev; // Remove all the voices from the list while (voice != &VoiceList) { if (voice->priority == MV_MUSIC_PRIORITY) { voice = voice->prev; continue; } MV_Kill(voice->handle); voice = VoiceList.prev; } RestoreInterrupts(); return MV_Ok; }
int FX_StopSound ( int handle ) { int status; status = MV_Kill( handle ); if ( status != MV_Ok ) { FX_SetErrorCode( FX_MultiVocError ); return( FX_Warning ); } return( FX_Ok ); }
VoiceNode *MV_AllocVoice(int32_t priority) { VoiceNode *voice, *node; DisableInterrupts(); // Check if we have any free voices if (LL_Empty(&VoicePool, next, prev)) { // check if we have a higher priority than a voice that is playing. for (voice = node = VoiceList.next; node != &VoiceList; node = node->next) { if (node->priority < voice->priority) voice = node; } if (priority >= voice->priority && voice != &VoiceList && voice->handle >= MV_MINVOICEHANDLE) MV_Kill(voice->handle); if (LL_Empty(&VoicePool, next, prev)) { // No free voices RestoreInterrupts(); return NULL; } } voice = VoicePool.next; LL_Remove(voice, next, prev); RestoreInterrupts(); int32_t vhan = MV_MINVOICEHANDLE; // Find a free voice handle do { if (++vhan < MV_MINVOICEHANDLE || vhan > MV_MaxVoices) vhan = MV_MINVOICEHANDLE; } while (MV_VoicePlaying(vhan)); voice->handle = vhan; return voice; }