]> Repos - portaudio/commitdiff
wasapi:
authordmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 16 Feb 2012 14:49:28 +0000 (14:49 +0000)
committerdmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 16 Feb 2012 14:49:28 +0000 (14:49 +0000)
- fixed device name incorrect in case it contains non-Latin characters (thanks to Robert Bielik for proposed solution), now it is converted to UTF-8 encoded string
- fixed damaged audio (pops & clicks) for Input exclusive event-driven mode if specified latency was below 23 ms

src/hostapi/wasapi/pa_win_wasapi.c

index d3824323944228d1c2d34c7801067623e857f8e3..a6bafdddc6ccf338592ce2ade8a9a7600ce4bd98 100644 (file)
@@ -1248,7 +1248,7 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
                         goto error;\r
                     }\r
                                        if (value.pwszVal)\r
-                                               wcstombs(deviceName, value.pwszVal, MAX_STR_LEN-1);\r
+                                               WideCharToMultiByte(CP_UTF8, 0, value.pwszVal, (int)wcslen(value.pwszVal), deviceName, MAX_STR_LEN-1, 0, 0);\r
                                        else\r
                                                _snprintf(deviceName, MAX_STR_LEN-1, "baddev%d", i);\r
                     deviceInfo->name = deviceName;\r
@@ -2211,11 +2211,15 @@ static HRESULT CreateAudioClient(PaWasapiStream *pStream, PaWasapiSubStream *pSu
        if (framesPerLatency == 0)\r
                framesPerLatency = MakeFramesFromHns(pInfo->DefaultDevicePeriod, pSub->wavex.Format.nSamplesPerSec);\r
 \r
-       //! Exclusive Input stream renders data in 6 packets, we must set then the size of\r
-       //! single packet, total buffer size, e.g. required latency will be PacketSize * 6\r
+       // Exclusive Input stream renders data in 6 packets, we must set then the size of\r
+       // single packet, total buffer size, e.g. required latency will be PacketSize * 6\r
        if (!output && (pSub->shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE))\r
        {\r
-               framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;\r
+               // Do it only for Polling mode\r
+               if ((pSub->streamFlags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK) == 0)\r
+               {\r
+                       framesPerLatency /= WASAPI_PACKETS_PER_INPUT_BUFFER;\r
+               }\r
        }\r
 \r
        // Calculate aligned period\r
@@ -3460,7 +3464,7 @@ static PaError ReadStream( PaStream* s, void *_buffer, unsigned long frames )
 \r
                // Limit desired to amount of requested frames\r
                desired = available;\r
-               if (desired > frames)\r
+               if ((UINT32)desired > frames)\r
                        desired = frames;\r
                \r
                // Get pointers to read regions\r