Permalink
Browse files

fixed slgui dropping messages for loops > 5

I got the initial registration/get, that fires when you add and
remove loops too, to make its own little thread and send everything
4 loops at a time.
  • Loading branch information...
1 parent adc0d96 commit f8e4b9e95cd3faf530ff88371ed5c7bf70122925 @kasbah kasbah committed Jul 11, 2012
Showing with 53 additions and 15 deletions.
  1. +1 −0 CHANGES
  2. +47 −0 src/gui/loop_control.cpp
  3. +4 −1 src/gui/loop_control.hpp
  4. +1 −14 src/gui/main_panel.cpp
View
@@ -9,6 +9,7 @@ GUI:
- MIDI bindings choice now sorted alphabetically
- File selector now defaults to home and tracks last load/save
- Removed arbitrary maximum loop memory limit in Add Custom Loop...
+- Fixed issue of some controls not showing up when you have more than 5 loops
SooperLooper engine:
- Fixed issue of not being able to load audio files from session when not started from the same directory
@@ -1091,6 +1091,53 @@ LoopControl::save_midi_bindings(const wxString & filename)
lo_send(_osc_addr, "/save_midi_bindings", "ss", (const char *) filename.ToAscii(), "");
}
+
+int
+LoopControl::register_all_in_new_thread(int number_of_loops)
+{
+
+ pthread_t register_thread;
+ get_spawn_config().num_loops = number_of_loops; //XXX why don't we have the right num_loops already?
+ return pthread_create (&register_thread, NULL, &LoopControl::_register_all, this);
+
+}
+
+void *
+LoopControl::_register_all (void *arg)
+{
+ //send all registrations in groups of 4 pausing inbetween to
+ //avoid losing osc messages, osc messages for loops greater
+ //than 5 were getting lost
+
+ LoopControl * lc = static_cast<LoopControl *>(arg);
+
+ lc->request_global_values ();
+
+ int num_of_loops = lc->get_spawn_config().num_loops;
+ int div = num_of_loops/4;
+ int rem = num_of_loops % 4;
+
+ for (int j = 0; j < div; ++j) {
+ for (int i = (4 * j); i < (4 + (4 * j)); ++i) {
+ lc->register_auto_updates(i);
+ lc->register_input_controls(i);
+ lc->request_all_values (i);
+ }
+#if wxCHECK_VERSION(2,5,3)
+ ::wxMilliSleep(150);
+#else
+ ::wxUsleep(150);
+#endif
+ }
+ for (int i = (4 * div); i < (rem + (4 * div)); ++i) {
+ lc->register_auto_updates(i);
+ lc->register_input_controls(i);
+ lc->request_all_values (i);
+ }
+
+ return 0;
+}
+
void
LoopControl::register_auto_updates(int index, bool unreg)
{
@@ -128,12 +128,15 @@ class LoopControl
void update_values();
+ int register_all_in_new_thread(int num_of_loops);
+ static void* _register_all(void* arg);
+
void register_global_updates(bool unreg=false);
void register_auto_updates(int index, bool unreg=false);
void register_input_controls(int index, bool unreg=false);
void register_control (int index, wxString ctrl, bool unreg=false);
void register_auto_update(int index, wxString ctrl, bool unreg=false);
-
+
void send_quit();
void send_alive_ping();
@@ -466,20 +466,7 @@ MainPanel::init_loopers (int count)
//_main_sizer->SetSizeHints( _scroller ); // set size hints to honour mininum size
// request all values for initial state
- _loop_control->request_global_values ();
-
- for (unsigned int i=0; i < _looper_panels.size(); ++i) {
- _looper_panels[i]->set_index(i);
- _loop_control->register_auto_updates((int) i);
- _loop_control->register_input_controls((int) i);
- _loop_control->request_all_values ((int)i);
- // sleep for a short bit to prevent UDP droppage
-#if wxCHECK_VERSION(2,5,3)
- ::wxMilliSleep(50);
-#else
- ::wxUsleep(50);
-#endif
- }
+ _loop_control->register_all_in_new_thread(_looper_panels.size());
init_syncto_choice ();

0 comments on commit f8e4b9e

Please sign in to comment.