MF_API void MFInput_EnableBufferedInput(bool bEnable, int frequency) { gInputFrequency = frequency; if(!gInputThread) { for(int i=0; i<MFInput_MaxInputID; ++i) { gInputEvents[IDD_Gamepad][i] = (MFInputEvent*)MFHeap_Alloc(sizeof(MFInputEvent)*MaxEvents); gNumEvents[IDD_Gamepad][i] = 0; } gInputMutex = MFThread_CreateMutex("MFInput Mutex"); gInputThread = MFThread_CreateThread("MFInput Thread", &MFInput_Thread, NULL); } else { bInputTerminate = true; MFThread_Join(gInputThread); gInputThread = NULL; MFThread_DestroyMutex(gInputMutex); for(int i=0; i<MFInput_MaxInputID; ++i) { MFHeap_Free(gInputEvents[IDD_Gamepad][i]); } } }
MF_API void MFSound_CloseCaptureDevice(MFDevice *pDevice) { MFDebug_Assert(pDevice->type == MFDT_AudioCapture, "Incorrect device type!"); MFAudioCaptureDevice &device = *(MFAudioCaptureDevice*)pDevice->pInternal; if(device.pAudioClient) { MFSound_StopCapture(pDevice); device.bTerminate = true; MFThread_Join(device.thread); MFThread_DestroyThread(device.thread); device.pCaptureClient->Release(); device.pCaptureClient = NULL; device.pAudioClient->Release(); device.pAudioClient = NULL; device.pDevice->Release(); device.pDevice = NULL; } }