@@ -1703,7 +1703,6 @@ RtAudioErrorType RtApiCore :: abortStream( void )
1703
1703
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
1704
1704
errorText_ = " RtApiCore::abortStream(): the stream is stopping or closed!" ;
1705
1705
return error ( RTAUDIO_WARNING );
1706
- // return;
1707
1706
}
1708
1707
1709
1708
CoreHandle *handle = (CoreHandle *) stream_.apiHandle ;
@@ -3487,8 +3486,11 @@ bool stopThreadCalled = false;
3487
3486
3488
3487
RtAudioErrorType RtApiAsio :: startStream()
3489
3488
{
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!" ;
3492
3494
return error ( RTAUDIO_WARNING );
3493
3495
}
3494
3496
@@ -3519,8 +3521,11 @@ RtAudioErrorType RtApiAsio :: startStream()
3519
3521
3520
3522
RtAudioErrorType RtApiAsio :: stopStream()
3521
3523
{
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!" ;
3524
3529
return error ( RTAUDIO_WARNING );
3525
3530
}
3526
3531
@@ -3546,8 +3551,11 @@ RtAudioErrorType RtApiAsio :: stopStream()
3546
3551
3547
3552
RtAudioErrorType RtApiAsio :: abortStream()
3548
3553
{
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!" ;
3551
3559
return error ( RTAUDIO_WARNING );
3552
3560
}
3553
3561
@@ -4648,8 +4656,11 @@ void RtApiWasapi::closeStream( void )
4648
4656
4649
4657
RtAudioErrorType RtApiWasapi::startStream ( void )
4650
4658
{
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!" ;
4653
4664
return error ( RTAUDIO_WARNING );
4654
4665
}
4655
4666
@@ -4678,15 +4689,13 @@ RtAudioErrorType RtApiWasapi::startStream( void )
4678
4689
4679
4690
RtAudioErrorType RtApiWasapi::stopStream ( void )
4680
4691
{
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!" ;
4683
4697
return error ( RTAUDIO_WARNING );
4684
4698
}
4685
- if ( stream_.state == STREAM_STOPPING ) {
4686
- errorText_ = " RtApiWasapi::stopStream: The stream is already stopping." ;
4687
- error ( RtAudioError::WARNING );
4688
- return ;
4689
- }
4690
4699
4691
4700
// inform stream thread by setting stream state to STREAM_STOPPING
4692
4701
stream_.state = STREAM_STOPPING;
@@ -4707,16 +4716,14 @@ RtAudioErrorType RtApiWasapi::stopStream( void )
4707
4716
4708
4717
RtAudioErrorType RtApiWasapi::abortStream ( void )
4709
4718
{
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!" ;
4712
4724
return error ( RTAUDIO_WARNING );
4713
4725
}
4714
- if ( stream_.state == STREAM_STOPPING ) {
4715
- errorText_ = " RtApiWasapi::abortStream: The stream is already stopping." ;
4716
- error ( RtAudioError::WARNING );
4717
- return ;
4718
- }
4719
-
4726
+
4720
4727
// inform stream thread by setting stream state to STREAM_STOPPING
4721
4728
stream_.state = STREAM_STOPPING;
4722
4729
@@ -6664,8 +6671,7 @@ RtAudioErrorType RtApiDs :: abortStream()
6664
6671
DsHandle *handle = (DsHandle *) stream_.apiHandle ;
6665
6672
handle->drainCounter = 2 ;
6666
6673
6667
- stopStream ();
6668
- return RTAUDIO_NO_ERROR;
6674
+ return stopStream ();
6669
6675
}
6670
6676
6671
6677
void RtApiDs :: callbackEvent()
0 commit comments