]> Repos - portaudio/commitdiff
wasapi: - releasing Input/Output buffer if error occurred inside the processing routine
authordmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 3 Feb 2011 15:37:12 +0000 (15:37 +0000)
committerdmitrykos <dmitrykos@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 3 Feb 2011 15:37:12 +0000 (15:37 +0000)
src/hostapi/wasapi/pa_win_wasapi.c

index 9211320d8ab8b5616f54f3459da9e987b95070e5..a61ce543e932c3c88c27c77ab5f92564630057a5 100644 (file)
@@ -4862,6 +4862,9 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                        // get available frames\r
                        if ((hr = _PollGetOutputFramesAvailable(stream, &o_frames)) != S_OK)\r
                        {\r
+                               // release input buffer\r
+                               IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);\r
+\r
                                LogHostError(hr);\r
                                break;\r
                        }\r
@@ -4889,6 +4892,11 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                                                        stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));\r
                                                        if (stream->out.monoBuffer == NULL)\r
                                                        {\r
+                                                               // release input buffer\r
+                                                               IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);\r
+                                                               // release output buffer\r
+                                                               IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);\r
+\r
                                                                LogPaError(paInsufficientMemory);\r
                                                                break;\r
                                                        }\r
@@ -4908,6 +4916,11 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                                                        stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));\r
                                                        if (stream->in.monoBuffer == NULL)\r
                                                        {\r
+                                                               // release input buffer\r
+                                                               IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);\r
+                                                               // release output buffer\r
+                                                               IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);\r
+\r
                                                                LogPaError(paInsufficientMemory);\r
                                                                break;\r
                                                        }\r
@@ -4954,11 +4967,6 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                        BYTE *i_data = NULL, *o_data = NULL, *o_data_host = NULL;\r
                        DWORD i_flags = 0;\r
                        UINT32 o_frames = 0;\r
-                       //BOOL repeat = FALSE;\r
-\r
-                       // going below 1 msec resolution, switching between 1 ms and no waiting\r
-                       //if (stream->in.shareMode == AUDCLNT_SHAREMODE_EXCLUSIVE)\r
-                       //      sleep_ms = !sleep_ms;\r
 \r
                        // Get next sleep time\r
                        if (sleep_ms == 0)\r
@@ -4985,9 +4993,6 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                                        break;\r
                                }\r
 \r
-                               //PA_DEBUG(("full-duplex: o_frames[%d] i_frames[%d] repeat[%d]\n", o_frames, i_frames, repeat));\r
-                               //repeat = TRUE;\r
-\r
                                // process equal ammount of frames\r
                                if (o_frames >= i_frames)\r
                                {\r
@@ -5011,6 +5016,11 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                                                                stream->out.monoBuffer = PaWasapi_ReallocateMemory(stream->out.monoBuffer, (stream->out.monoBufferSize = mono_frames_size));\r
                                                                if (stream->out.monoBuffer == NULL)\r
                                                                {\r
+                                                                       // release input buffer\r
+                                                                       IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);\r
+                                                                       // release output buffer\r
+                                                                       IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);\r
+\r
                                                                        LogPaError(paInsufficientMemory);\r
                                                                        goto thread_error;\r
                                                                }\r
@@ -5030,6 +5040,11 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
                                                                stream->in.monoBuffer = PaWasapi_ReallocateMemory(stream->in.monoBuffer, (stream->in.monoBufferSize = mono_frames_size));\r
                                                                if (stream->in.monoBuffer == NULL)\r
                                                                {\r
+                                                                       // release input buffer\r
+                                                                       IAudioCaptureClient_ReleaseBuffer(stream->captureClient, 0);\r
+                                                                       // release output buffer\r
+                                                                       IAudioRenderClient_ReleaseBuffer(stream->renderClient, 0, 0);\r
+\r
                                                                        LogPaError(paInsufficientMemory);\r
                                                                        goto thread_error;\r
                                                                }\r