Skip to content

Commit 0890827

Browse files
Gary ScavoneGary Scavone
Gary Scavone
authored and
Gary Scavone
committed
Wasapi fixes for new noexception behaviour.
1 parent 0f4b52c commit 0890827

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

RtAudio.cpp

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,6 @@ RtAudioErrorType RtApiCore :: abortStream( void )
17031703
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
17041704
errorText_ = "RtApiCore::abortStream(): the stream is stopping or closed!";
17051705
return error( RTAUDIO_WARNING );
1706-
//return;
17071706
}
17081707

17091708
CoreHandle *handle = (CoreHandle *) stream_.apiHandle;
@@ -3487,8 +3486,11 @@ bool stopThreadCalled = false;
34873486

34883487
RtAudioErrorType RtApiAsio :: startStream()
34893488
{
3490-
if ( stream_.state == STREAM_RUNNING ) {
3491-
errorText_ = "RtApiAsio::startStream(): the stream is already running!";
3489+
if ( stream_.state != STREAM_STOPPED ) {
3490+
if ( stream_.state == STREAM_RUNNING )
3491+
errorText_ = "RtApiAsio::startStream(): the stream is already running!";
3492+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
3493+
errorText_ = "RtApiAsio::startStream(): the stream is stopping or closed!";
34923494
return error( RTAUDIO_WARNING );
34933495
}
34943496

@@ -3519,8 +3521,11 @@ RtAudioErrorType RtApiAsio :: startStream()
35193521

35203522
RtAudioErrorType RtApiAsio :: stopStream()
35213523
{
3522-
if ( stream_.state == STREAM_STOPPED ) {
3523-
errorText_ = "RtApiAsio::stopStream(): the stream is already stopped!";
3524+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
3525+
if ( stream_.state == STREAM_STOPPED )
3526+
errorText_ = "RtApiAsio::stopStream(): the stream is already stopped!";
3527+
else if ( stream_.state == STREAM_CLOSED )
3528+
errorText_ = "RtApiAsio::stopStream(): the stream is closed!";
35243529
return error( RTAUDIO_WARNING );
35253530
}
35263531

@@ -3546,8 +3551,11 @@ RtAudioErrorType RtApiAsio :: stopStream()
35463551

35473552
RtAudioErrorType RtApiAsio :: abortStream()
35483553
{
3549-
if ( stream_.state == STREAM_STOPPED ) {
3550-
errorText_ = "RtApiAsio::abortStream(): the stream is already stopped!";
3554+
if ( stream_.state != STREAM_RUNNING ) {
3555+
if ( stream_.state == STREAM_STOPPED )
3556+
errorText_ = "RtApiAsio::abortStream(): the stream is already stopped!";
3557+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
3558+
errorText_ = "RtApiAsio::abortStream(): the stream is stopping or closed!";
35513559
return error( RTAUDIO_WARNING );
35523560
}
35533561

@@ -4648,8 +4656,11 @@ void RtApiWasapi::closeStream( void )
46484656

46494657
RtAudioErrorType RtApiWasapi::startStream( void )
46504658
{
4651-
if ( stream_.state == STREAM_RUNNING ) {
4652-
errorText_ = "RtApiWasapi::startStream: The stream is already running.";
4659+
if ( stream_.state != STREAM_STOPPED ) {
4660+
if ( stream_.state == STREAM_RUNNING )
4661+
errorText_ = "RtApiWasapi::startStream(): the stream is already running!";
4662+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
4663+
errorText_ = "RtApiWasapi::startStream(): the stream is stopping or closed!";
46534664
return error( RTAUDIO_WARNING );
46544665
}
46554666

@@ -4678,15 +4689,13 @@ RtAudioErrorType RtApiWasapi::startStream( void )
46784689

46794690
RtAudioErrorType RtApiWasapi::stopStream( void )
46804691
{
4681-
if ( stream_.state == STREAM_STOPPED ) {
4682-
errorText_ = "RtApiWasapi::stopStream: The stream is already stopped.";
4692+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
4693+
if ( stream_.state == STREAM_STOPPED )
4694+
errorText_ = "RtApiWasapi::stopStream(): the stream is already stopped!";
4695+
else if ( stream_.state == STREAM_CLOSED )
4696+
errorText_ = "RtApiWasapi::stopStream(): the stream is closed!";
46834697
return error( RTAUDIO_WARNING );
46844698
}
4685-
if ( stream_.state == STREAM_STOPPING ) {
4686-
errorText_ = "RtApiWasapi::stopStream: The stream is already stopping.";
4687-
error( RtAudioError::WARNING );
4688-
return;
4689-
}
46904699

46914700
// inform stream thread by setting stream state to STREAM_STOPPING
46924701
stream_.state = STREAM_STOPPING;
@@ -4707,16 +4716,14 @@ RtAudioErrorType RtApiWasapi::stopStream( void )
47074716

47084717
RtAudioErrorType RtApiWasapi::abortStream( void )
47094718
{
4710-
if ( stream_.state == STREAM_STOPPED ) {
4711-
errorText_ = "RtApiWasapi::abortStream: The stream is already stopped.";
4719+
if ( stream_.state != STREAM_RUNNING ) {
4720+
if ( stream_.state == STREAM_STOPPED )
4721+
errorText_ = "RtApiWasapi::abortStream(): the stream is already stopped!";
4722+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
4723+
errorText_ = "RtApiWasapi::abortStream(): the stream is stopping or closed!";
47124724
return error( RTAUDIO_WARNING );
47134725
}
4714-
if ( stream_.state == STREAM_STOPPING ) {
4715-
errorText_ = "RtApiWasapi::abortStream: The stream is already stopping.";
4716-
error( RtAudioError::WARNING );
4717-
return;
4718-
}
4719-
4726+
47204727
// inform stream thread by setting stream state to STREAM_STOPPING
47214728
stream_.state = STREAM_STOPPING;
47224729

@@ -6664,8 +6671,7 @@ RtAudioErrorType RtApiDs :: abortStream()
66646671
DsHandle *handle = (DsHandle *) stream_.apiHandle;
66656672
handle->drainCounter = 2;
66666673

6667-
stopStream();
6668-
return RTAUDIO_NO_ERROR;
6674+
return stopStream();
66696675
}
66706676

66716677
void RtApiDs :: callbackEvent()

0 commit comments

Comments
 (0)