diff options
| author | garyscavone <garyscavone@users.noreply.github.com> | 2019-08-28 10:11:03 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-28 10:11:03 -0400 |
| commit | 1cba5c90a35b0e79915dc46dd5525da2285a211b (patch) | |
| tree | be5803f04f2f5908816af37c30f7d7be09520a0f | |
| parent | 1b570c8b2d87743f056f7250569f0e2808170e1c (diff) | |
| parent | 2d9b95f9992659150fc7dabf92e161327c56a099 (diff) | |
Merge pull request #210 from f1xpl/master
Fix high CPU usage by PulseAudio backend when stream is stopped
| -rw-r--r-- | RtAudio.cpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/RtAudio.cpp b/RtAudio.cpp index 1108c74..dce61fe 100644 --- a/RtAudio.cpp +++ b/RtAudio.cpp @@ -8699,15 +8699,18 @@ void RtApiPulse::stopStream( void ) stream_.state = STREAM_STOPPED; MUTEX_LOCK( &stream_.mutex ); - if ( pah && pah->s_play ) { - int pa_error; - if ( pa_simple_drain( pah->s_play, &pa_error ) < 0 ) { - errorStream_ << "RtApiPulse::stopStream: error draining output device, " << - pa_strerror( pa_error ) << "."; - errorText_ = errorStream_.str(); - MUTEX_UNLOCK( &stream_.mutex ); - error( RtAudioError::SYSTEM_ERROR ); - return; + if ( pah ) { + pah->runnable = false; + if ( pah->s_play ) { + int pa_error; + if ( pa_simple_drain( pah->s_play, &pa_error ) < 0 ) { + errorStream_ << "RtApiPulse::stopStream: error draining output device, " << + pa_strerror( pa_error ) << "."; + errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); + error( RtAudioError::SYSTEM_ERROR ); + return; + } } } @@ -8733,15 +8736,18 @@ void RtApiPulse::abortStream( void ) stream_.state = STREAM_STOPPED; MUTEX_LOCK( &stream_.mutex ); - if ( pah && pah->s_play ) { - int pa_error; - if ( pa_simple_flush( pah->s_play, &pa_error ) < 0 ) { - errorStream_ << "RtApiPulse::abortStream: error flushing output device, " << - pa_strerror( pa_error ) << "."; - errorText_ = errorStream_.str(); - MUTEX_UNLOCK( &stream_.mutex ); - error( RtAudioError::SYSTEM_ERROR ); - return; + if ( pah ) { + pah->runnable = false; + if ( pah->s_play ) { + int pa_error; + if ( pa_simple_flush( pah->s_play, &pa_error ) < 0 ) { + errorStream_ << "RtApiPulse::abortStream: error flushing output device, " << + pa_strerror( pa_error ) << "."; + errorText_ = errorStream_.str(); + MUTEX_UNLOCK( &stream_.mutex ); + error( RtAudioError::SYSTEM_ERROR ); + return; + } } } |
