]> Repos - portaudio/commitdiff
wasapi:
authordmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 6 Aug 2010 20:25:07 +0000 (20:25 +0000)
committerdmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Fri, 6 Aug 2010 20:25:07 +0000 (20:25 +0000)
 - fixed alignment missing for host buffer if overall buffer size was set to less than 3ms that results in device timeout
 - advanced Event driven mode and extended the range of host buffer size which can operate in this mode up up to 20.66 ms, e.g. your device buffer size will vary in range 3 - 20.66 ms, if goes above then Poll driven mode is switched on automatically

include/pa_win_wasapi.h
src/hostapi/wasapi/pa_win_wasapi.c

index e949dfe3aadab2f13446edd711fadcf7191e9f65..64eb49b02941ce3639562604c801f083a7d69879 100644 (file)
@@ -346,8 +346,8 @@ PaError PaWasapi_GetJackDescription(PaDeviceIndex nDevice, int jindex, PaWasapiJ
         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 th\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 b\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
index 5177bc40b42e13fc8485a29e56170d6cbf6e43c7..2db509e2c7223e5f4dc0e90614c98e43eb614363 100644 (file)
@@ -2094,7 +2094,7 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
                // 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
@@ -2124,12 +2124,22 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
        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
@@ -2152,7 +2162,6 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
                                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
@@ -2163,7 +2172,6 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
                                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