// Here is where we try to determine the best format to use with the device. If the client if wanting exclusive mode, first try finding the best format for that. If this fails, fall back to shared mode.
// Unfortunately we need to release and re-acquire the audio client according to MSDN. Seems silly - why not just call IAudioClient_Initialize() again?!
mal_post_error(pDevice,"[WASAPI] WARNING: Failed to release internal buffer from capture device in preparation for sending new data to the client.",MAL_WASAPI_FAILED_TO_RELEASE_INTERNAL_BUFFER);
mal_post_error(pDevice,"[WASAPI] WARNING: Failed to release internal buffer from capture device in preparation for sending new data to the client.",MAL_WASAPI_FAILED_TO_RELEASE_INTERNAL_BUFFER);
// Latency with WinMM seems pretty bad from my testing... Need to increase the default buffer size.
if(pDevice->usingDefaultBufferSize){
pDevice->bufferSizeInFrames*=6;// <-- Might need to fiddle with this to find a more ideal value. May even be able to just add a fixed amount rather than scaling.
if(pDevice->type==mal_device_type_playback){
pDevice->bufferSizeInFrames*=4;// <-- Might need to fiddle with this to find a more ideal value. May even be able to just add a fixed amount rather than scaling.
}else{
pDevice->bufferSizeInFrames*=2;
}
}
// The size of the intermediary buffer needs to be able to fit every fragment.
mal_post_error(pDevice,"[WinMM] Failed to prepare header for capture device in preparation for adding a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to unprepare header for capture device in preparation for adding a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for capture device in preparation for addin a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));
mal_post_error(pDevice,"[WinMM] Failed to prepare header for capture device in preparation for adding a new capture buffer for the device.",mal_result_from_MMRESULT(resultMM));