Fix for ALSA runnable flag update mistake; moved streamname declaration in PULSE...
[rtaudio-cdist.git] / RtAudio.cpp
index efed868e185b26d8db4eb279102e5a5d4ec7e5c0..7d60e7716aab8c5df2ec30c937d40384bdd99c0e 100644 (file)
@@ -180,14 +180,15 @@ RtAudio :: RtAudio( RtAudio::Api api ) throw()
   // It should not be possible to get here because the preprocessor\r
   // definition __RTAUDIO_DUMMY__ is automatically defined if no\r
   // API-specific definitions are passed to the compiler. But just in\r
-  // case something weird happens, we'll print out an error message.\r
+  // case something weird happens, we'll thow an error.\r
   std::string errorText = "\nRtAudio: no compiled API support found ... critical error!!\n\n";\r
   throw( RtAudioError( errorText, RtAudioError::UNSPECIFIED ) );\r
 }\r
 \r
 RtAudio :: ~RtAudio() throw()\r
 {\r
-  delete rtapi_;\r
+  if ( rtapi_ )\r
+    delete rtapi_;\r
 }\r
 \r
 void RtAudio :: openStream( RtAudio::StreamParameters *outputParameters,\r
@@ -6143,7 +6144,6 @@ void RtApiAlsa :: startStream()
   stream_.state = STREAM_RUNNING;\r
 \r
  unlock:\r
-  apiInfo->runnable = false; // fixes high CPU usage when stopped\r
   pthread_cond_signal( &apiInfo->runnable_cv );\r
   MUTEX_UNLOCK( &stream_.mutex );\r
 \r
@@ -6229,6 +6229,7 @@ void RtApiAlsa :: abortStream()
   }\r
 \r
  unlock:\r
+  apiInfo->runnable = false; // fixes high CPU usage when stopped\r
   MUTEX_UNLOCK( &stream_.mutex );\r
 \r
   if ( result >= 0 ) return;\r
@@ -6804,6 +6805,7 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
   stream_.nUserChannels[mode] = channels;\r
   stream_.nDeviceChannels[mode] = channels + firstChannel;\r
   stream_.channelOffset[mode] = 0;\r
+  std::string streamName = "RtAudio";\r
 \r
   // Allocate necessary internal buffers.\r
   bufferBytes = stream_.nUserChannels[mode] * *bufferSize * formatBytes( stream_.userFormat );\r
@@ -6857,7 +6859,6 @@ bool RtApiPulse::probeDeviceOpen( unsigned int device, StreamMode mode,
   pah = static_cast<PulseAudioHandle *>( stream_.apiHandle );\r
 \r
   int error;\r
-  std::string streamName = "RtAudio";\r
   if ( !options->streamName.empty() ) streamName = options->streamName;\r
   switch ( mode ) {\r
   case INPUT:\r