int FX_Shutdown ( void ) { int status; if ( !FX_Installed ) { return( FX_Ok ); } status = FX_Ok; switch( FX_SoundDevice ) { case SoundBlaster : case Awe32 : case ProAudioSpectrum : case SoundMan16 : case SoundScape : case SoundSource : case TandySoundSource : case UltraSound : status = MV_Shutdown(); if ( status != MV_Ok ) { FX_SetErrorCode( FX_MultiVocError ); status = FX_Error; } break; default : FX_SetErrorCode( FX_InvalidCard ); status = FX_Error; } FX_Installed = FALSE; LL_UnlockMemory(); return( status ); }
int FX_Shutdown ( void ) { int status; if ( !FX_Installed ) { return( FX_Ok ); } status = MV_Shutdown(); if ( status != MV_Ok ) { FX_SetErrorCode( FX_MultiVocError ); status = FX_Error; } FX_Installed = FALSE; return( status ); }
int32_t MV_Init(int32_t soundcard, int32_t MixRate, int32_t Voices, int32_t numchannels, void *initdata) { if (MV_Installed) MV_Shutdown(); MV_SetErrorCode(MV_Ok); // MV_TotalMemory + 2: FIXME, see valgrind_errors.log int const totalmem = Voices * sizeof(VoiceNode) + MV_TOTALBUFFERSIZE + 2; #ifdef _3DS char *ptr = (char *) linearAlloc( totalmem); #else char *ptr = (char *) Xaligned_alloc(16, totalmem); #endif if (!ptr) { MV_SetErrorCode(MV_NoMem); return MV_Error; } Bmemset(ptr, 0, totalmem); MV_Voices = (VoiceNode *)ptr; ptr += Voices * sizeof(VoiceNode); // Set number of voices before calculating volume table MV_MaxVoices = Voices; LL_Reset((VoiceNode*) &VoiceList, next, prev); LL_Reset((VoiceNode*) &VoicePool, next, prev); for (int index = 0; index < Voices; index++) { LL_Add((VoiceNode*) &VoicePool, &MV_Voices[ index ], next, prev); } MV_SetReverseStereo(FALSE); ASS_SoundDriver = soundcard; // Initialize the sound card if (SoundDriver_Init(&MixRate, &numchannels, initdata) != MV_Ok) MV_SetErrorCode(MV_DriverError); if (MV_ErrorCode != MV_Ok) { ALIGNED_FREE_AND_NULL(MV_Voices); return MV_Error; } MV_Installed = TRUE; MV_CallBackFunc = NULL; MV_ReverbLevel = 0; MV_ReverbTable = NULL; // Set the sampling rate MV_MixRate = MixRate; // Set Mixer to play stereo digitized sound MV_SetMixMode(numchannels); MV_ReverbDelay = MV_BufferSize * 3; // Make sure we don't cross a physical page MV_MixBuffer[ MV_NumberOfBuffers ] = ptr; for (int buffer = 0; buffer < MV_NumberOfBuffers; buffer++) { MV_MixBuffer[ buffer ] = ptr; ptr += MV_BufferSize; } // Calculate pan table MV_CalcPanTable(); MV_SetVolume(MV_MAXTOTALVOLUME); // Start the playback engine if (MV_StartPlayback() != MV_Ok) { // Preserve error code while we shutdown. int status = MV_ErrorCode; MV_Shutdown(); MV_SetErrorCode(status); return MV_Error; } return MV_Ok; }