summaryrefslogtreecommitdiff
path: root/libs/surfaces/tranzport/io.cc
diff options
context:
space:
mode:
authorJohn Anderson <ardour@semiosix.com>2007-02-14 19:56:16 +0000
committerJohn Anderson <ardour@semiosix.com>2007-02-14 19:56:16 +0000
commite878b365193ad9315e557a8245b767d8a0fe568d (patch)
treed03d6b7bc7bb57c7c55d370010b8c6e6bb6619ae /libs/surfaces/tranzport/io.cc
parent92c09a6d91fa90bbfaec4d94e2c6e6c11f1e49a3 (diff)
merge r1449 from surfaces branch to include mackie surface and tranzport updates. Thanks to Gerd Flaig for the merge command: svn merge svn+ssh://ardoursvn@ardour.org/ardour2/trunk@1449 svn+ssh://ardoursvn@ardour.org/ardour2/branches/surfaces.
git-svn-id: svn://localhost/ardour2/trunk@1460 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/surfaces/tranzport/io.cc')
-rw-r--r--libs/surfaces/tranzport/io.cc95
1 files changed, 95 insertions, 0 deletions
diff --git a/libs/surfaces/tranzport/io.cc b/libs/surfaces/tranzport/io.cc
new file mode 100644
index 0000000000..14242ea0ec
--- /dev/null
+++ b/libs/surfaces/tranzport/io.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2006 Paul Davis
+ * Copyright (C) 2007 Michael Taht
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * */
+
+/* The routines in here should know absolutely nothing about how io is actually done */
+
+#include <tranzport_control_protocol.h>
+
+int
+TranzportControlProtocol::flush ()
+{
+ int pending = 0;
+
+// Always write the lights first
+ if(!(pending = lights_flush())) {
+ pending = screen_flush();
+ }
+
+#if DEBUG_TRANZPORT_BITS > 9
+ int s;
+ if(s = (screen_invalid.count())) { // + lights_invalid.count())) {
+ printf("VALID : %s %s\n",
+ screen_invalid.to_string().c_str(),
+ lights_invalid.to_string().c_str());
+ printf("CURR : %s %s\n",
+ screen_invalid.to_string().c_str(),
+ lights_current.to_string().c_str());
+ printf("PENDING : %s %s\n",
+ screen_invalid.to_string().c_str(),
+ lights_pending.to_string().c_str());
+#if DEBUG_TRANZPORT_BITS > 10
+ printf("invalid bits: %d\n",s);
+#endif
+ }
+#endif
+ return pending;
+}
+
+
+int
+TranzportControlProtocol::lights_flush ()
+{
+ std::bitset<LIGHTS> light_state;
+ light_state = lights_pending ^ lights_current;
+ if ( (light_state.none() || lights_invalid.none()))
+ {
+ return (0);
+ }
+
+#if DEBUG_TRANZPORT_LIGHTS
+ printf("LPEND : %s\n", lights_pending.to_string().c_str());
+ printf("LCURR : %s\n", lights_current.to_string().c_str());
+#endif
+
+ // if ever we thread reads/writes STATUS_OK will have to move into the loop
+ int i;
+
+ if ( _device_status == STATUS_OK || _device_status == STATUS_ONLINE) {
+ for (i = 0; i<LIGHTS; i++) {
+ if(light_state[i]) {
+ if(light_set ((LightID)i,lights_pending[i])) {
+#if DEBUG_TRANZPORT_LIGHTS > 2
+ printf("Did %d light writes\n",i);
+#endif
+ return light_state.count();
+ } else {
+ light_state[i] = 0;
+ }
+
+ }
+ }
+ }
+ light_state = lights_pending ^ lights_current;
+#if DEBUG_TRANZPORT_LIGHTS > 2
+ printf("Did %d light writes, left: %d\n",i, light_state.count());
+#endif
+
+ return light_state.count();
+}