Преглед изворни кода

Changed firstErrorOccurred to be class variable; Fix to ALSA input receiver id.

Gary Scavone пре 10 година
родитељ
комит
c39bb17ab4
2 измењених фајлова са 13 додато и 5 уклоњено
  1. 12 5
      RtMidi.cpp
  2. 1 0
      RtMidi.h

+ 12 - 5
RtMidi.cpp

@@ -241,16 +241,15 @@ void MidiApi :: setErrorCallback( RtMidiErrorCallback errorCallback, void *userD
 void MidiApi :: error( RtMidiError::Type type, std::string errorString )
 {
   if ( errorCallback_ ) {
-    static bool firstErrorOccured = false;
 
-    if ( firstErrorOccured )
+    if ( firstErrorOccured_ )
       return;
 
-    firstErrorOccured = true;
+    firstErrorOccured_ = true;
     const std::string errorMessage = errorString;
 
     errorCallback_( type, errorMessage, errorCallbackUserData_);
-    firstErrorOccured = false;
+    firstErrorOccured_ = false;
     return;
   }
 
@@ -1472,6 +1471,7 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName
   snd_seq_addr_t sender, receiver;
   sender.client = snd_seq_port_info_get_client( src_pinfo );
   sender.port = snd_seq_port_info_get_port( src_pinfo );
+  receiver.client = snd_seq_client_id( data->seq );
 
   snd_seq_port_info_t *pinfo;
   snd_seq_port_info_alloca( &pinfo );
@@ -1501,7 +1501,6 @@ void MidiInAlsa :: openPort( unsigned int portNumber, const std::string portName
     data->vport = snd_seq_port_info_get_port(pinfo);
   }
 
-  receiver.client = snd_seq_port_info_get_client( pinfo );
   receiver.port = data->vport;
 
   if ( !data->subscription ) {
@@ -2263,6 +2262,14 @@ std::string MidiOutWinMM :: getPortName( unsigned int portNumber )
   stringName = std::string( deviceCaps.szPname );
 #endif
 
+  // Next lines added to add the portNumber to the name so that 
+  // the device's names are sure to be listed with individual names
+  // even when they have the same brand name
+  std::ostringstream os;
+  os << " ";
+  os << portNumber;
+  stringName += os.str();
+
   return stringName;
 }
 

+ 1 - 0
RtMidi.h

@@ -460,6 +460,7 @@ protected:
   bool connected_;
   std::string errorString_;
   RtMidiErrorCallback errorCallback_;
+  bool firstErrorOccurred_;
   void *errorCallbackUserData_;
 };