Hi Albert,

I hope to review and test your patch within the next day or so, and I'll
back to you on it.


Please use the attached (commented) patch, which also does away with the compile time warnings.

The more subtle warnings come from macros expanding into assert(<address of local var>), which in itself expands to an "if" which is always true. Because these warnings are annoying and misleading at best, I used local variables to muffle gcc. These parts of the patch don't change functionality in any way, but I feel that every warning removed is a good thing.

- Ján

Index: mixxx/src/midiobjectalsaseq.h
===================================================================
--- mixxx/src/midiobjectalsaseq.h	(revision 1768)
+++ mixxx/src/midiobjectalsaseq.h	(working copy)
@@ -32,6 +32,7 @@
     int getClientPortsList(void);
     void devOpen(QString device);
     void devClose();
+    void sendShortMsg(unsigned int word);
 protected:
     void run();
     
Index: mixxx/src/midiobjectalsaseq.cpp
===================================================================
--- mixxx/src/midiobjectalsaseq.cpp	(revision 1768)
+++ mixxx/src/midiobjectalsaseq.cpp	(working copy)
@@ -46,13 +46,14 @@
     }
 
     snd_seq_port_info_alloca(&pinfo);
-    snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE );
+    snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_SUBS_WRITE |
+				     SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_READ );
     snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION );
     snd_seq_port_info_set_midi_channels(pinfo, 16);
     snd_seq_port_info_set_timestamping(pinfo, 1);
     snd_seq_port_info_set_timestamp_real(pinfo, 1);
     snd_seq_port_info_set_timestamp_queue(pinfo, m_queue);
-    snd_seq_port_info_set_name(pinfo, "input");
+    snd_seq_port_info_set_name(pinfo, "Mixxx");
     m_input = snd_seq_create_port(m_handle, pinfo);
 
     if (m_input != 0)
@@ -61,13 +62,6 @@
         return;
     }
 
-    err = snd_seq_connect_from(m_handle, m_input, SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE);
-    if (err != 0)
-    {
-        qDebug("snd_seq_connect_from failed" );
-        return;
-    }
-
     // BJW Actually open the requested device (otherwise it won't be opened
     // until reconfigured via the Preferences dialog!)
     devOpen(device);
@@ -100,8 +94,15 @@
     snd_seq_client_info_t * pClientInfo;
     snd_seq_port_info_t * pPortInfo;
 
-    snd_seq_client_info_alloca(&pClientInfo);
-    snd_seq_port_info_alloca(&pPortInfo);
+    {
+	// Use temporary variables to avoid misleading warnings
+        // from the _alloca macros
+	snd_seq_client_info_t ** ppCI = &pClientInfo;
+	snd_seq_port_info_t ** ppPI = &pPortInfo;
+
+	snd_seq_client_info_alloca(ppCI);
+	snd_seq_port_info_alloca(ppPI);
+    }
     snd_seq_client_info_set_client(pClientInfo, -1);
 
     while (snd_seq_query_next_client(m_handle, pClientInfo) >= 0) {
@@ -148,8 +149,8 @@
 {
     if (!snd_seq_free_queue(m_handle, m_queue))
         qDebug("snd_seq_free_queue failed" );
-    if(!snd_seq_close(m_handle)) ;
-    qDebug("snd_seq_close failed" );
+    if (!snd_seq_close(m_handle))
+	qDebug("snd_seq_close failed" );
 }
 
 //Connects the Mixxx ALSA seq device to a "client" picked from the combobox...
@@ -168,8 +169,15 @@
     snd_seq_client_info_t * pClientInfo;
     snd_seq_port_info_t * pPortInfo;
 
-    snd_seq_client_info_alloca(&pClientInfo);
-    snd_seq_port_info_alloca(&pPortInfo);
+    {
+	// Use temporary variables to avoid misleading warnings
+        // from the _alloca macros
+	snd_seq_client_info_t ** ppCI = &pClientInfo;
+	snd_seq_port_info_t ** ppPI = &pPortInfo;
+
+	snd_seq_client_info_alloca(ppCI);
+	snd_seq_port_info_alloca(ppPI);
+    }
     snd_seq_client_info_set_client(pClientInfo, -1);
 
     while (snd_seq_query_next_client(m_handle, pClientInfo) >= 0) {
@@ -193,10 +201,14 @@
                         //qDebug("Connecting " + sPortName + " to Mixxx");
 
                         snd_seq_connect_from(m_handle, m_input, iAlsaClient, iAlsaPort);
+                        snd_seq_connect_to(m_handle, m_input, iAlsaClient, iAlsaPort);
                         sActivePortName = sPortName;
                     }
-                    else                     //Disconnect Mixxx from any other ports (might be annoying, but let's us be safe.)
+                    else {
+                        //Disconnect Mixxx from any other ports (might be annoying, but let's us be safe.)
                         snd_seq_disconnect_from(m_handle, snd_seq_port_info_get_port(pPortInfo), iAlsaClient, iAlsaPort);
+                        snd_seq_disconnect_to(m_handle, snd_seq_port_info_get_port(pPortInfo), iAlsaClient, iAlsaPort);
+		    }
 
                     iDirtyCount++;
                 }
@@ -293,3 +305,31 @@
     }
 }
 
+void MidiObjectALSASeq::sendShortMsg(unsigned int word) {
+    snd_seq_event_t ev;
+    int byte1, byte2, byte3;
+
+    // Safely retrieve the message sequence from the input
+    byte1 = word & 0xff;
+    byte2 = (word>>8) & 0xff;
+    byte3 = (word>>16) & 0xff;
+    // qDebug("MIDI message send via alsa seq: %02x %02x %02x", byte1, byte2, byte3);
+
+    // Initialize the event structure
+    snd_seq_ev_set_direct(&ev);
+    snd_seq_ev_set_source(&ev, m_input);
+
+    // Send to all subscribers
+    snd_seq_ev_set_dest(&ev, SND_SEQ_ADDRESS_SUBSCRIBERS, 0);
+
+    // Decide which event type to choose
+    switch ((byte1 & 0xf0)) {
+    case 0x90:
+        snd_seq_ev_set_noteon(&ev, byte1&0xf, byte2, byte3);
+	break;
+    case 0xb0:
+	snd_seq_ev_set_controller(&ev, byte1&0xf, byte2, byte3);
+	break;
+    }
+    snd_seq_event_output_direct(m_handle, &ev);
+}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Mixxx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mixxx-devel

Reply via email to