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
// 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
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