/* Wait for data to become available. Exclusive mode is slightly different. We always wait and then use the exact frame count returned by GetCurrentPadding(). */
for (;;) {
if (pDevice->playback.shareMode == mal_share_mode_exclusive) {
if (mal_device_is_reroute_required__wasapi(pDevice, mal_device_type_playback)) {
result = mal_device_reroute__wasapi(pDevice, mal_device_type_playback);
if (result != MAL_SUCCESS) {
exitOuterLoop = MAL_TRUE;
break;
}
}
/* The device buffer has become available, so now we need to get a pointer to it. */
/*
Check what's available. If there's not enough data available we need to wait. How much data must be available depends on whether or not the
device is in playback-only mode or duplex mode. In playback-only mode we only care about a period being available. In duplex mode we want at
least a whole period in the buffer ready for playback in addition to a whole period being available.
*/
result = mal_device__get_available_frames__wasapi(pDevice, (mal_IAudioClient*)pDevice->wasapi.pAudioClientPlayback, &pDevice->wasapi.deviceBufferFramesCapacityPlayback);
Must have at least 3 periods for full-duplex mode. The idea is that the playback and capture positions hang out in the middle period, with the surrounding
periods acting as a buffer in case the capture and playback devices get's slightly out of sync.
*/
if (config.deviceType == mal_device_type_duplex && config.periods < 3) {