Skip to content

Commit f9fd872

Browse files
Gary ScavoneGary Scavone
Gary Scavone
authored and
Gary Scavone
committed
Misc. updates to APIs other than CoreAudio and Jack to conform with noexceptions changes.
1 parent 0890827 commit f9fd872

File tree

1 file changed

+99
-58
lines changed

1 file changed

+99
-58
lines changed

RtAudio.cpp

Lines changed: 99 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,8 +3478,9 @@ void RtApiAsio :: closeStream()
34783478
stream_.deviceBuffer = 0;
34793479
}
34803480

3481-
stream_.mode = UNINITIALIZED;
3482-
stream_.state = STREAM_CLOSED;
3481+
clearStreamInfo();
3482+
//stream_.mode = UNINITIALIZED;
3483+
//stream_.state = STREAM_CLOSED;
34833484
}
34843485

34853486
bool stopThreadCalled = false;
@@ -3494,9 +3495,11 @@ RtAudioErrorType RtApiAsio :: startStream()
34943495
return error( RTAUDIO_WARNING );
34953496
}
34963497

3498+
/*
34973499
#if defined( HAVE_GETTIMEOFDAY )
34983500
gettimeofday( &stream_.lastTickTimestamp, NULL );
34993501
#endif
3502+
*/
35003503

35013504
AsioHandle *handle = (AsioHandle *) stream_.apiHandle;
35023505
ASIOError result = ASIOStart();
@@ -4648,8 +4651,8 @@ void RtApiWasapi::closeStream( void )
46484651
stream_.deviceBuffer = 0;
46494652
}
46504653

4651-
// update stream state
4652-
stream_.state = STREAM_CLOSED;
4654+
clearStreamInfo();
4655+
//stream_.state = STREAM_CLOSED;
46534656
}
46544657

46554658
//-----------------------------------------------------------------------------
@@ -4664,10 +4667,12 @@ RtAudioErrorType RtApiWasapi::startStream( void )
46644667
return error( RTAUDIO_WARNING );
46654668
}
46664669

4670+
/*
46674671
#if defined( HAVE_GETTIMEOFDAY )
46684672
gettimeofday( &stream_.lastTickTimestamp, NULL );
46694673
#endif
4670-
4674+
*/
4675+
46714676
// update stream state
46724677
stream_.state = STREAM_RUNNING;
46734678

@@ -6495,21 +6500,27 @@ void RtApiDs :: closeStream()
64956500
stream_.deviceBuffer = 0;
64966501
}
64976502

6498-
stream_.mode = UNINITIALIZED;
6499-
stream_.state = STREAM_CLOSED;
6503+
clearStreamInfo();
6504+
//stream_.mode = UNINITIALIZED;
6505+
//stream_.state = STREAM_CLOSED;
65006506
}
65016507

65026508
RtAudioErrorType RtApiDs :: startStream()
65036509
{
6504-
if ( stream_.state == STREAM_RUNNING ) {
6505-
errorText_ = "RtApiDs::startStream(): the stream is already running!";
6510+
if ( stream_.state != STREAM_STOPPED ) {
6511+
if ( stream_.state == STREAM_RUNNING )
6512+
errorText_ = "RtApiDs::startStream(): the stream is already running!";
6513+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
6514+
errorText_ = "RtApiDs::startStream(): the stream is stopping or closed!";
65066515
return error( RTAUDIO_WARNING );
65076516
}
65086517

6518+
/*
65096519
#if defined( HAVE_GETTIMEOFDAY )
65106520
gettimeofday( &stream_.lastTickTimestamp, NULL );
65116521
#endif
6512-
6522+
*/
6523+
65136524
DsHandle *handle = (DsHandle *) stream_.apiHandle;
65146525

65156526
// Increase scheduler frequency on lesser windows (a side-effect of
@@ -6560,8 +6571,11 @@ RtAudioErrorType RtApiDs :: startStream()
65606571

65616572
RtAudioErrorType RtApiDs :: stopStream()
65626573
{
6563-
if ( stream_.state == STREAM_STOPPED ) {
6564-
errorText_ = "RtApiDs::stopStream(): the stream is already stopped!";
6574+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
6575+
if ( stream_.state == STREAM_STOPPED )
6576+
errorText_ = "RtApiDs::stopStream(): the stream is already stopped!";
6577+
else if ( stream_.state == STREAM_CLOSED )
6578+
errorText_ = "RtApiDs::stopStream(): the stream is closed!";
65656579
return error( RTAUDIO_WARNING );
65666580
}
65676581

@@ -6663,8 +6677,11 @@ RtAudioErrorType RtApiDs :: stopStream()
66636677

66646678
RtAudioErrorType RtApiDs :: abortStream()
66656679
{
6666-
if ( stream_.state == STREAM_STOPPED ) {
6667-
errorText_ = "RtApiDs::abortStream(): the stream is already stopped!";
6680+
if ( stream_.state != STREAM_RUNNING ) {
6681+
if ( stream_.state == STREAM_STOPPED )
6682+
errorText_ = "RtApiDs::abortStream(): the stream is already stopped!";
6683+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
6684+
errorText_ = "RtApiDs::abortStream(): the stream is stopping or closed!";
66686685
return error( RTAUDIO_WARNING );
66696686
}
66706687

@@ -8199,25 +8216,31 @@ void RtApiAlsa :: closeStream()
81998216
stream_.deviceBuffer = 0;
82008217
}
82018218

8202-
stream_.mode = UNINITIALIZED;
8203-
stream_.state = STREAM_CLOSED;
8219+
clearStreamInfo();
8220+
//stream_.mode = UNINITIALIZED;
8221+
//stream_.state = STREAM_CLOSED;
82048222
}
82058223

82068224
RtAudioErrorType RtApiAlsa :: startStream()
82078225
{
82088226
// This method calls snd_pcm_prepare if the device isn't already in that state.
82098227

8210-
if ( stream_.state == STREAM_RUNNING ) {
8211-
errorText_ = "RtApiAlsa::startStream(): the stream is already running!";
8228+
if ( stream_.state != STREAM_STOPPED ) {
8229+
if ( stream_.state == STREAM_RUNNING )
8230+
errorText_ = "RtApiAlsa::startStream(): the stream is already running!";
8231+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
8232+
errorText_ = "RtApiAlsa::startStream(): the stream is stopping or closed!";
82128233
return error( RTAUDIO_WARNING );
82138234
}
82148235

82158236
MUTEX_LOCK( &stream_.mutex );
82168237

8238+
/*
82178239
#if defined( HAVE_GETTIMEOFDAY )
82188240
gettimeofday( &stream_.lastTickTimestamp, NULL );
82198241
#endif
8220-
8242+
*/
8243+
82218244
int result = 0;
82228245
snd_pcm_state_t state;
82238246
AlsaHandle *apiInfo = (AlsaHandle *) stream_.apiHandle;
@@ -8260,8 +8283,11 @@ RtAudioErrorType RtApiAlsa :: startStream()
82608283

82618284
RtAudioErrorType RtApiAlsa :: stopStream()
82628285
{
8263-
if ( stream_.state == STREAM_STOPPED ) {
8264-
errorText_ = "RtApiAlsa::stopStream(): the stream is already stopped!";
8286+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
8287+
if ( stream_.state == STREAM_STOPPED )
8288+
errorText_ = "RtApiAlsa::stopStream(): the stream is already stopped!";
8289+
else if ( stream_.state == STREAM_CLOSED )
8290+
errorText_ = "RtApiAlsa::stopStream(): the stream is closed!";
82658291
return error( RTAUDIO_WARNING );
82668292
}
82678293

@@ -8302,8 +8328,11 @@ RtAudioErrorType RtApiAlsa :: stopStream()
83028328

83038329
RtAudioErrorType RtApiAlsa :: abortStream()
83048330
{
8305-
if ( stream_.state == STREAM_STOPPED ) {
8306-
errorText_ = "RtApiAlsa::abortStream(): the stream is already stopped!";
8331+
if ( stream_.state != STREAM_RUNNING ) {
8332+
if ( stream_.state == STREAM_STOPPED )
8333+
errorText_ = "RtApiAlsa::abortStream(): the stream is already stopped!";
8334+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
8335+
errorText_ = "RtApiAlsa::abortStream(): the stream is stopping or closed!";
83078336
return error( RTAUDIO_WARNING );
83088337
}
83098338

@@ -8874,8 +8903,9 @@ void RtApiPulse::closeStream( void )
88748903
stream_.userBuffer[1] = 0;
88758904
}
88768905

8877-
stream_.state = STREAM_CLOSED;
8878-
stream_.mode = UNINITIALIZED;
8906+
clearStreamInfo();
8907+
//stream_.state = STREAM_CLOSED;
8908+
//stream_.mode = UNINITIALIZED;
88798909
}
88808910

88818911
void RtApiPulse::callbackEvent( void )
@@ -8972,23 +9002,24 @@ void RtApiPulse::callbackEvent( void )
89729002

89739003
RtAudioErrorType RtApiPulse::startStream( void )
89749004
{
8975-
PulseAudioHandle *pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );
8976-
8977-
if ( stream_.state == STREAM_CLOSED ) {
8978-
errorText_ = "RtApiPulse::startStream(): the stream is not open!";
8979-
return error( RTAUDIO_INVALID_USE );
8980-
}
8981-
if ( stream_.state == STREAM_RUNNING ) {
8982-
errorText_ = "RtApiPulse::startStream(): the stream is already running!";
9005+
if ( stream_.state != STREAM_STOPPED ) {
9006+
if ( stream_.state == STREAM_RUNNING )
9007+
errorText_ = "RtApiPulse::startStream(): the stream is already running!";
9008+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
9009+
errorText_ = "RtApiPulse::startStream(): the stream is stopping or closed!";
89839010
return error( RTAUDIO_WARNING );
89849011
}
9012+
9013+
PulseAudioHandle *pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );
89859014

89869015
MUTEX_LOCK( &stream_.mutex );
89879016

9017+
/*
89889018
#if defined( HAVE_GETTIMEOFDAY )
89899019
gettimeofday( &stream_.lastTickTimestamp, NULL );
89909020
#endif
8991-
9021+
*/
9022+
89929023
stream_.state = STREAM_RUNNING;
89939024

89949025
pah->runnable = true;
@@ -8999,16 +9030,15 @@ RtAudioErrorType RtApiPulse::startStream( void )
89999030

90009031
RtAudioErrorType RtApiPulse::stopStream( void )
90019032
{
9002-
PulseAudioHandle *pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );
9003-
9004-
if ( stream_.state == STREAM_CLOSED ) {
9005-
errorText_ = "RtApiPulse::stopStream(): the stream is not open!";
9006-
return error( RTAUDIO_INVALID_USE );
9007-
}
9008-
if ( stream_.state == STREAM_STOPPED ) {
9009-
errorText_ = "RtApiPulse::stopStream(): the stream is already stopped!";
9033+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
9034+
if ( stream_.state == STREAM_STOPPED )
9035+
errorText_ = "RtApiPulse::stopStream(): the stream is already stopped!";
9036+
else if ( stream_.state == STREAM_CLOSED )
9037+
errorText_ = "RtApiPulse::stopStream(): the stream is closed!";
90109038
return error( RTAUDIO_WARNING );
90119039
}
9040+
9041+
PulseAudioHandle *pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );
90129042

90139043
stream_.state = STREAM_STOPPED;
90149044
MUTEX_LOCK( &stream_.mutex );
@@ -9034,16 +9064,15 @@ RtAudioErrorType RtApiPulse::stopStream( void )
90349064

90359065
RtAudioErrorType RtApiPulse::abortStream( void )
90369066
{
9037-
PulseAudioHandle *pah = static_cast<PulseAudioHandle*>( stream_.apiHandle );
9038-
9039-
if ( stream_.state == STREAM_CLOSED ) {
9040-
errorText_ = "RtApiPulse::abortStream(): the stream is not open!";
9041-
return error( RTAUDIO_INVALID_USE );
9042-
}
9043-
if ( stream_.state == STREAM_STOPPED ) {
9044-
errorText_ = "RtApiPulse::abortStream(): the stream is already stopped!";
9067+
if ( stream_.state != STREAM_RUNNING ) {
9068+
if ( stream_.state == STREAM_STOPPED )
9069+
errorText_ = "RtApiPulse::abortStream(): the stream is already stopped!";
9070+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
9071+
errorText_ = "RtApiPulse::abortStream(): the stream is stopping or closed!";
90459072
return error( RTAUDIO_WARNING );
90469073
}
9074+
9075+
PulseAudioHandle *pah = static_cast<PulseAudioHandle*>( stream_.apiHandle );
90479076

90489077
stream_.state = STREAM_STOPPED;
90499078
MUTEX_LOCK( &stream_.mutex );
@@ -10022,22 +10051,28 @@ void RtApiOss :: closeStream()
1002210051
stream_.deviceBuffer = 0;
1002310052
}
1002410053

10025-
stream_.mode = UNINITIALIZED;
10026-
stream_.state = STREAM_CLOSED;
10054+
clearStreamInfo();
10055+
//stream_.mode = UNINITIALIZED;
10056+
//stream_.state = STREAM_CLOSED;
1002710057
}
1002810058

1002910059
RtAudioErrorType RtApiOss :: startStream()
1003010060
{
10031-
if ( stream_.state == STREAM_RUNNING ) {
10032-
errorText_ = "RtApiOss::startStream(): the stream is already running!";
10061+
if ( stream_.state != STREAM_STOPPED ) {
10062+
if ( stream_.state == STREAM_RUNNING )
10063+
errorText_ = "RtApiOss::startStream(): the stream is already running!";
10064+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
10065+
errorText_ = "RtApiOss::startStream(): the stream is stopping or closed!";
1003310066
return error( RTAUDIO_WARNING );
1003410067
}
1003510068

1003610069
MUTEX_LOCK( &stream_.mutex );
1003710070

10071+
/*
1003810072
#if defined( HAVE_GETTIMEOFDAY )
1003910073
gettimeofday( &stream_.lastTickTimestamp, NULL );
1004010074
#endif
10075+
*/
1004110076

1004210077
stream_.state = STREAM_RUNNING;
1004310078

@@ -10053,8 +10088,11 @@ RtAudioErrorType RtApiOss :: startStream()
1005310088

1005410089
RtAudioErrorType RtApiOss :: stopStream()
1005510090
{
10056-
if ( stream_.state == STREAM_STOPPED ) {
10057-
errorText_ = "RtApiOss::stopStream(): the stream is already stopped!";
10091+
if ( stream_.state != STREAM_RUNNING && stream_.state != STREAM_STOPPING ) {
10092+
if ( stream_.state == STREAM_STOPPED )
10093+
errorText_ = "RtApiOss::stopStream(): the stream is already stopped!";
10094+
else if ( stream_.state == STREAM_CLOSED )
10095+
errorText_ = "RtApiOss::stopStream(): the stream is closed!";
1005810096
return error( RTAUDIO_WARNING );
1005910097
}
1006010098

@@ -10123,8 +10161,11 @@ RtAudioErrorType RtApiOss :: stopStream()
1012310161

1012410162
RtAudioErrorType RtApiOss :: abortStream()
1012510163
{
10126-
if ( stream_.state == STREAM_STOPPED ) {
10127-
errorText_ = "RtApiOss::abortStream(): the stream is already stopped!";
10164+
if ( stream_.state != STREAM_RUNNING ) {
10165+
if ( stream_.state == STREAM_STOPPED )
10166+
errorText_ = "RtApiOss::abortStream(): the stream is already stopped!";
10167+
else if ( stream_.state == STREAM_STOPPING || stream_.state == STREAM_CLOSED )
10168+
errorText_ = "RtApiOss::abortStream(): the stream is stopping or closed!";
1012810169
return error( RTAUDIO_WARNING );
1012910170
}
1013010171

0 commit comments

Comments
 (0)