Merge branch 'winrt' into 'master'
WASAPI: relax latency check in Exclusive mode when switching from Event to Poll mode +1: Etienne Dechamps Merged-on: https://assembla.com/code/portaudio/git/merge_requests/7097201
This commit is contained in:
commit
dfd780389b
1 changed files with 6 additions and 4 deletions
|
|
@ -2942,10 +2942,10 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
|
||||||
// Work 1:1 with user buffer (only polling allows to use >1)
|
// Work 1:1 with user buffer (only polling allows to use >1)
|
||||||
framesPerLatency += MakeFramesFromHns(SecondsTonano100(params->suggestedLatency), pSub->wavex.Format.nSamplesPerSec);
|
framesPerLatency += MakeFramesFromHns(SecondsTonano100(params->suggestedLatency), pSub->wavex.Format.nSamplesPerSec);
|
||||||
|
|
||||||
// Use Polling if overall latency is > 5ms as it allows to use 100% CPU in a callback,
|
// Use Polling if overall latency is >= 21.33ms as it allows to use 100% CPU in a callback,
|
||||||
// or user specified latency parameter
|
// or user specified latency parameter
|
||||||
overall = MakeHnsPeriod(framesPerLatency, pSub->wavex.Format.nSamplesPerSec);
|
overall = MakeHnsPeriod(framesPerLatency, pSub->wavex.Format.nSamplesPerSec);
|
||||||
if ((overall >= (106667*2)/*21.33ms*/) || ((INT32)(params->suggestedLatency*100000.0) != 0/*0.01 msec granularity*/))
|
if (overall >= (106667 * 2)/*21.33ms*/)
|
||||||
{
|
{
|
||||||
framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
|
framesPerLatency = _GetFramesPerHostBuffer(userFramesPerBuffer,
|
||||||
params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
|
params->suggestedLatency, pSub->wavex.Format.nSamplesPerSec, 0/*,
|
||||||
|
|
@ -2972,10 +2972,8 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
|
||||||
{
|
{
|
||||||
// Do it only for Polling mode
|
// Do it only for Polling mode
|
||||||
if ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)
|
if ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)
|
||||||
{
|
|
||||||
framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;
|
framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate aligned period
|
// Calculate aligned period
|
||||||
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
|
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
|
||||||
|
|
@ -3112,6 +3110,10 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
|
||||||
framesPerLatency = MakeFramesFromHns(pSub->period / ratio, pSub->wavex.Format.nSamplesPerSec);
|
framesPerLatency = MakeFramesFromHns(pSub->period / ratio, pSub->wavex.Format.nSamplesPerSec);
|
||||||
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
|
_CalculateAlignedPeriod(pSub, &framesPerLatency, ALIGN_BWD);
|
||||||
|
|
||||||
|
// Make sure we are not below the minimum period
|
||||||
|
if (pSub->period < pInfo->MinimumDevicePeriod)
|
||||||
|
pSub->period = pInfo->MinimumDevicePeriod;
|
||||||
|
|
||||||
// Release previous client
|
// Release previous client
|
||||||
SAFE_RELEASE(audioClient);
|
SAFE_RELEASE(audioClient);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue