1) Event-Driven:\r
This is the most powerful WASAPI implementation which provides glitch-free\r
audio at around 3ms latency in Exclusive mode. Lowest possible latency for this mode is \r
- usually - 1.4(Vista only)-3ms(Windows 7+) for HD Audio class audio chips. For the \r
- Shared mode latency can not be lower than 20ms.\r
+ 3 ms for HD Audio class audio chips. For the Shared mode latency can not be \r
+ lower than 20 ms.\r
\r
2) Poll-Driven:\r
Polling is another 2-nd method to operate with WASAPI. It is less efficient than Event-Driven\r
// Use Polling if overall latency is > 5ms as it allows to use 100% CPU in a callback,\r
// or user specified latency parameter\r
overall = MakeHnsPeriod(framesPerLatency, pSub->wavex.Format.nSamplesPerSec);\r
- if ((overall > 50000) || (params->suggestedLatency > 0))\r
+ if ((overall >= (106667*2)/*21.33ms*/) || ((INT32)(params->suggestedLatency*100000.0) != 0/*0.01 msec granularity*/))\r
{\r
framesPerLatency = PaUtil_GetFramesPerHostBuffer(userFramesPerBuffer,\r
params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,\r
if (pSub->shareMode == AUDCLNT_SHAREMODE_SHARED)\r
{\r
if (pSub->period < pInfo->DefaultDevicePeriod)\r
+ {\r
pSub->period = pInfo->DefaultDevicePeriod;\r
+ // Recalculate aligned period\r
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);\r
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);\r
+ }\r
}\r
else\r
{\r
if (pSub->period < pInfo->MinimumDevicePeriod)\r
+ {\r
pSub->period = pInfo->MinimumDevicePeriod;\r
+ // Recalculate aligned period\r
+ framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);\r
+ _CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);\r
+ }\r
}\r
\r
/*! Windows 7 does not allow to set latency lower than minimal device period and will\r
if (pSub->period > MAX_BUFFER_EVENT_DURATION)\r
{\r
pSub->period = MAX_BUFFER_EVENT_DURATION;\r
-\r
// Recalculate aligned period\r
framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);\r
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);\r
if (pSub->period > MAX_BUFFER_POLL_DURATION)\r
{\r
pSub->period = MAX_BUFFER_POLL_DURATION;\r
-\r
// Recalculate aligned period\r
framesPerLatency = MakeFramesFromHns(pSub->period, pSub->wavex.Format.nSamplesPerSec);\r
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);\r