DirectSound don't crash when starting a blocking io (non-callback) stream. blocking io still not implemented though.
This commit is contained in:
parent
64936ef6ee
commit
011c1c0880
1 changed files with 25 additions and 18 deletions
|
|
@ -2417,11 +2417,14 @@ static PaError StartStream( PaStream *s )
|
||||||
|
|
||||||
if( stream->bufferProcessor.outputChannelCount > 0 )
|
if( stream->bufferProcessor.outputChannelCount > 0 )
|
||||||
{
|
{
|
||||||
/* Give user callback a chance to pre-fill buffer. REVIEW - i thought we weren't pre-filling, rb. */
|
if( stream->streamRepresentation.streamCallback )
|
||||||
TimeSlice( stream );
|
{
|
||||||
/* we ignore the return value from TimeSlice here and start the stream as usual.
|
/* Give user callback a chance to pre-fill buffer. REVIEW - i thought we weren't pre-filling, rb. */
|
||||||
The first timer callback will detect if the callback has completed. */
|
TimeSlice( stream );
|
||||||
|
/* we ignore the return value from TimeSlice here and start the stream as usual.
|
||||||
|
The first timer callback will detect if the callback has completed. */
|
||||||
|
}
|
||||||
|
|
||||||
QueryPerformanceCounter( &stream->previousPlayTime );
|
QueryPerformanceCounter( &stream->previousPlayTime );
|
||||||
stream->previousPlayCursor = 0;
|
stream->previousPlayCursor = 0;
|
||||||
stream->finalZeroBytesWritten = 0;
|
stream->finalZeroBytesWritten = 0;
|
||||||
|
|
@ -2449,9 +2452,9 @@ static PaError StartStream( PaStream *s )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( stream->streamRepresentation.streamCallback )
|
||||||
/* Create timer that will wake us up so we can fill the DSound buffer. */
|
|
||||||
{
|
{
|
||||||
|
/* Create timer that will wake us up so we can fill the DSound buffer. */
|
||||||
int resolution;
|
int resolution;
|
||||||
int framesPerWakeup = stream->framesPerDSBuffer / 4;
|
int framesPerWakeup = stream->framesPerDSBuffer / 4;
|
||||||
int msecPerWakeup = MSEC_PER_SECOND * framesPerWakeup / (int) stream->streamRepresentation.streamInfo.sampleRate;
|
int msecPerWakeup = MSEC_PER_SECOND * framesPerWakeup / (int) stream->streamRepresentation.streamInfo.sampleRate;
|
||||||
|
|
@ -2460,13 +2463,14 @@ static PaError StartStream( PaStream *s )
|
||||||
resolution = msecPerWakeup/4;
|
resolution = msecPerWakeup/4;
|
||||||
stream->timerID = timeSetEvent( msecPerWakeup, resolution, (LPTIMECALLBACK) TimerCallback,
|
stream->timerID = timeSetEvent( msecPerWakeup, resolution, (LPTIMECALLBACK) TimerCallback,
|
||||||
(DWORD_PTR) stream, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS );
|
(DWORD_PTR) stream, TIME_PERIODIC | TIME_KILL_SYNCHRONOUS );
|
||||||
}
|
|
||||||
if( stream->timerID == 0 )
|
if( stream->timerID == 0 )
|
||||||
{
|
{
|
||||||
stream->isActive = 0;
|
stream->isActive = 0;
|
||||||
result = paUnanticipatedHostError;
|
result = paUnanticipatedHostError;
|
||||||
PA_DS_SET_LAST_DIRECTSOUND_ERROR( hr );
|
PA_DS_SET_LAST_DIRECTSOUND_ERROR( hr );
|
||||||
goto error;
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream->isStarted = TRUE;
|
stream->isStarted = TRUE;
|
||||||
|
|
@ -2484,12 +2488,15 @@ static PaError StopStream( PaStream *s )
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
int timeoutMsec;
|
int timeoutMsec;
|
||||||
|
|
||||||
stream->stopProcessing = 1;
|
if( stream->streamRepresentation.streamCallback )
|
||||||
|
{
|
||||||
|
stream->stopProcessing = 1;
|
||||||
|
|
||||||
/* Set timeout at 4 times maximum time we might wait. */
|
/* Set timeout at 4 times maximum time we might wait. */
|
||||||
timeoutMsec = (int) (4 * MSEC_PER_SECOND * (stream->framesPerDSBuffer / stream->streamRepresentation.streamInfo.sampleRate));
|
timeoutMsec = (int) (4 * MSEC_PER_SECOND * (stream->framesPerDSBuffer / stream->streamRepresentation.streamInfo.sampleRate));
|
||||||
|
|
||||||
WaitForSingleObject( stream->processingCompleted, timeoutMsec );
|
WaitForSingleObject( stream->processingCompleted, timeoutMsec );
|
||||||
|
}
|
||||||
|
|
||||||
if( stream->timerID != 0 )
|
if( stream->timerID != 0 )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue