OLA plugin sending garbage to high channels - proposed patch included

Post Reply
User avatar
rawbengal
Posts: 18
Joined: Fri Jul 10, 2015 5:23 am
Location: Los Angeles, CA, USA
Real Name: Rob Engle

I was finally able to get the OLA plugin working on my Mac by rolling back my OLA version to 0.9.5. When I did that and started output to OLA I noted that the channels higher than the ones I was manipulating in the interface were filled with what looked like random data. I think the issue is that the QLC+ engine only sends the active channels to the plugin but the OLA plugin is sending all 512 DMX channels to the olad socket. Basically the code which copies the data into the output buffer is not filling in the rest of the buffer with zeros.

Here is a proposed patch to plugins/ola/olaouthread.cpp. It is untested because I have not been able to get a clean build of QLC+ on my machine.

Code: Select all

*** olaoutthread.cpp.orig	2015-07-10 23:49:43.000000000 -0700
--- olaoutthread.cpp	2015-07-10 23:54:48.000000000 -0700
***************
*** 104,113 ****
   */
  int OlaOutThread::write_dmx(unsigned int universe, const QByteArray& data)
  {
-     m_data.universe = universe;
-     memcpy(m_data.data, data.data(), data.size());
      if (m_pipe)
          m_pipe->Send((uint8_t*) &m_data, sizeof(m_data));
      return 0;
  }
  
--- 104,123 ----
   */
  int OlaOutThread::write_dmx(unsigned int universe, const QByteArray& data)
  {
      if (m_pipe)
+     {
+         const int src_sz = data.size();
+         Q_ASSERT(src_sz <= sizeof(m_data.data));
+ 
+         m_data.universe = universe;
+         memcpy(m_data.data, data.data(), src_sz);
+ 
+         // if a full src buffer was not provided, fill the rest of the dst buffer with zeroes.
+         if (src_sz < sizeof(m_data.data))
+             memset(m_data.data+src_sz, 0, sizeof(m_data.data)-src_sz);
+ 
          m_pipe->Send((uint8_t*) &m_data, sizeof(m_data));
+     }
      return 0;
  }
User avatar
rawbengal
Posts: 18
Joined: Fri Jul 10, 2015 5:23 am
Location: Los Angeles, CA, USA
Real Name: Rob Engle

After some messing about, I was able to get the build working and this patch seems to work fine. It required a change to the data type of src_sz but otherwise was fine. Is there a procedure for integrating changes into the source on Github? I'd love to get this checked in.

Additionally, I have another change which corrects the first universe addressed by the OLA plugin. OLA universes start at zero (not at one). Without correcting the plugin to start at zero it is impossible for users to access the first OLA universe. This change also required some adjustments to the user messaging code.

If I need to be enabled for Github access, my user ID is 'rawbengal'

-rob
plugz
Posts: 637
Joined: Sun Apr 12, 2015 6:30 pm
Real Name: David

Hi,

If you want your code to be merged, you can do a standard pull request on github:
https://help.github.com/articles/using-pull-requests/

EDIT:
Didn't see that you managed to create a pull request :)

To create 2 separate pull requests, you have to create 2 different branches on your repo, 1 for each change. Then create 2 pull requests, 1 for each branch :)
Post Reply