Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make MME and DirectSound wait forever for the streaming thread to exit #920

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/hostapi/dsound/pa_win_ds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3089,9 +3089,7 @@ static PaError StopStream( PaStream *s )
#else
if( stream->processingThread )
{
if( WaitForSingleObject( stream->processingThreadCompleted, 30*100 ) == WAIT_TIMEOUT )
return paUnanticipatedHostError;

WaitForSingleObject(stream->processingThreadCompleted, INFINITE );
#ifdef CLOSE_THREAD_HANDLE
CloseHandle( stream->processingThread ); /* Delete thread. */
stream->processingThread = NULL;
Expand Down
21 changes: 2 additions & 19 deletions src/hostapi/wmme/pa_win_wmme.c
Original file line number Diff line number Diff line change
Expand Up @@ -3463,12 +3463,7 @@ static PaError StopStream( PaStream *s )
/* try to abort */
stream->abortProcessing = 1;
SetEvent( stream->abortEvent );
waitResult = WaitForSingleObject( stream->processingThread, timeoutMs );
if( waitResult == WAIT_TIMEOUT )
{
PA_DEBUG(("WinMME StopStream: timed out while waiting for background thread to finish.\n"));
result = paTimedOut;
}
WaitForSingleObject( stream->processingThread, INFINITE );
}

CloseHandle( stream->processingThread );
Expand Down Expand Up @@ -3575,8 +3570,6 @@ static PaError AbortStream( PaStream *s )
{
PaError result = paNoError;
PaWinMmeStream *stream = (PaWinMmeStream*)s;
DWORD timeoutMs;
DWORD waitResult;
MMRESULT mmresult;
unsigned int i;

Expand Down Expand Up @@ -3630,17 +3623,7 @@ static PaError AbortStream( PaStream *s )

PA_DEBUG(("WinMME AbortStream: waiting for background thread.\n"));

/* Calculate timeOut longer than longest time it could take to return all buffers. */
timeoutMs = (DWORD)(stream->allBuffersDurationMs * 1.5);
if( timeoutMs < PA_MME_MIN_TIMEOUT_MSEC_ )
timeoutMs = PA_MME_MIN_TIMEOUT_MSEC_;

waitResult = WaitForSingleObject( stream->processingThread, timeoutMs );
if( waitResult == WAIT_TIMEOUT )
{
PA_DEBUG(("WinMME AbortStream: timed out while waiting for background thread to finish.\n"));
return paTimedOut;
}
WaitForSingleObject( stream->processingThread, INFINITE );

CloseHandle( stream->processingThread );
stream->processingThread = NULL;
Expand Down
Loading