Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Incorporate WASAPI stream stopped check fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AnErrupTion committed Dec 11, 2021
1 parent c4101df commit 589af88
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib-src/portaudio-v19/src/hostapi/wasapi/pa_win_wasapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@ typedef struct PaWasapiStream
// thread is being started
volatile BOOL running;

// stream has not or is no longer started
BOOL stopped;

PA_THREAD_ID dwThreadId;
HANDLE hThread;
HANDLE hCloseRequest;
Expand Down Expand Up @@ -3797,6 +3800,9 @@ static PaError OpenStream( struct PaUtilHostApiRepresentation *hostApi,
if (framesPerBuffer == 0)
framesPerBuffer = ((UINT32)sampleRate / 100) * 2;

stream->stopped = TRUE;
stream->running = FALSE;

// Try create device: Input
if (inputParameters != NULL)
{
Expand Down Expand Up @@ -4522,6 +4528,7 @@ static PaError StartStream( PaStream *s )
// Signal: stream running.
stream->running = TRUE;
}
stream->stopped = FALSE;

return result;

Expand Down Expand Up @@ -4563,6 +4570,7 @@ void _StreamFinish(PaWasapiStream *stream)
_StreamCleanup(stream);

stream->running = FALSE;
stream->stopped = TRUE;
}

// ------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -4596,7 +4604,7 @@ static PaError AbortStream( PaStream *s )
// ------------------------------------------------------------------------------------------
static PaError IsStreamStopped( PaStream *s )
{
return !((PaWasapiStream *)s)->running;
return ((PaWasapiStream *)s)->stopped;
}

// ------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 589af88

Please sign in to comment.