]> Repos - portaudio/commitdiff
wasapi:
authordmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Tue, 18 May 2010 15:02:41 +0000 (15:02 +0000)
committerdmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Tue, 18 May 2010 15:02:41 +0000 (15:02 +0000)
 - fixed Event-driven mode, broken in 1496 rev.

src/hostapi/wasapi/pa_win_wasapi.c

index f889c7e78758977be836545c6eb004a48299e688..ad27274455ae9a5a1606fbde429f5d96f28ba61a 100644 (file)
@@ -3327,6 +3327,7 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
        DWORD dwResult;\r
     PaWasapiStream *stream = (PaWasapiStream *)param;\r
        PaWasapiHostProcessor defaultProcessor;\r
+       BOOL set_event[S_COUNT] = { FALSE, FALSE };\r
 \r
        // Waiting on all events in case of Full-Duplex/Exclusive mode.\r
        BOOL bWaitAllEvents = FALSE;\r
@@ -3345,18 +3346,29 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
        // Boost thread priority\r
        PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);\r
 \r
+       // Create events\r
+       if (stream->event[S_OUTPUT] == NULL)\r
+       {\r
+               stream->event[S_OUTPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);\r
+               set_event[S_OUTPUT] = TRUE;\r
+       }\r
+       if (stream->event[S_INPUT] == NULL)\r
+       {\r
+               stream->event[S_INPUT]  = CreateEvent(NULL, FALSE, FALSE, NULL);\r
+               set_event[S_INPUT] = TRUE;\r
+       }\r
+       if ((stream->event[S_OUTPUT] == NULL) || (stream->event[S_INPUT] == NULL))\r
+       {\r
+               PRINT(("WASAPI Thread: failed creating Input/Output event handle\n"));\r
+               goto thread_error;\r
+       }\r
+\r
        // Initialize event & start INPUT stream\r
        if (stream->in.client)\r
        {\r
                // Create & set handle\r
-               if (stream->event[S_INPUT] == NULL)\r
+               if (set_event[S_INPUT])\r
                {\r
-                       stream->event[S_INPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);\r
-                       if (stream->event[S_INPUT] == NULL)\r
-                       {\r
-                               PRINT(("WASAPI Thread: failed creating Input event handle\n"));\r
-                               goto thread_error;\r
-                       }\r
                        if ((hr = IAudioClient_SetEventHandle(stream->in.client, stream->event[S_INPUT])) != S_OK)\r
                        {\r
                                LogHostError(hr);\r
@@ -3386,15 +3398,8 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
        if (stream->out.client)\r
        {\r
                // Create & set handle\r
-               if (stream->event[S_OUTPUT] == NULL)\r
+               if (set_event[S_OUTPUT])\r
                {\r
-                       stream->event[S_OUTPUT] = CreateEvent(NULL, FALSE, FALSE, NULL);\r
-                       if (stream->event[S_OUTPUT] == NULL)\r
-                       {\r
-                               PRINT(("WASAPI Thread: failed creating Output event handle\n"));\r
-                               goto thread_error;\r
-                       }\r
-\r
                        if ((hr = IAudioClient_SetEventHandle(stream->out.client, stream->event[S_OUTPUT])) != S_OK)\r
                        {\r
                                LogHostError(hr);\r