summaryrefslogtreecommitdiff
path: root/libs/ardour/session_feedback.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-04-04 03:26:08 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-04-04 03:26:08 +0000
commitf7c82c69113419a8db083f0095044af5ad4c872c (patch)
tree158067acc6c957b2f973802c089878812134b2b0 /libs/ardour/session_feedback.cc
parentaf5815e79bcd2a17edbdf5d45f1c7df02af546d8 (diff)
a) start at creating ControlProtocol objects
b) basic support for Frontier Design Tranzport c) probably broke some aspect of existing generic MIDI feedback git-svn-id: svn://localhost/trunk/ardour2@441 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_feedback.cc')
-rw-r--r--libs/ardour/session_feedback.cc86
1 files changed, 41 insertions, 45 deletions
diff --git a/libs/ardour/session_feedback.cc b/libs/ardour/session_feedback.cc
index 840cb6a97d..09e9021461 100644
--- a/libs/ardour/session_feedback.cc
+++ b/libs/ardour/session_feedback.cc
@@ -37,6 +37,7 @@
#include <ardour/session.h>
#include <ardour/audio_track.h>
#include <ardour/diskstream.h>
+#include <ardour/control_protocol.h>
#include "i18n.h"
@@ -65,11 +66,6 @@ Session::init_feedback ()
}
active_feedback = 0;
- midi_feedback = false;
-
- /* add possible feedback functions here */
-
- feedback_functions.push_back (mem_fun (*this, &Session::feedback_generic_midi_function));
if (pthread_create_and_store ("feedback", &feedback_thread, 0, _feedback_thread_work, this)) {
error << _("Session: could not create feedback thread") << endmsg;
@@ -99,6 +95,28 @@ Session::stop_feedback ()
}
void
+Session::set_feedback (bool yn)
+{
+ set_dirty();
+
+ if (yn) {
+ /* make sure the feedback thread is alive */
+ start_feedback ();
+ } else {
+ /* maybe put the feedback thread to sleep */
+ stop_feedback ();
+ }
+
+ ControlChanged (Feedback); /* EMIT SIGNAL */
+}
+
+bool
+Session::get_feedback() const
+{
+ return active_feedback > 0;
+}
+
+void
Session::terminate_feedback ()
{
void* status;
@@ -123,8 +141,7 @@ Session::feedback_thread_work ()
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
if (active_feedback) {
- /* XXX use Config->feedback_interval_usecs()*/;
- timeout = max (5, (int) Config->get_midi_feedback_interval_ms());
+ timeout = max (5, (int) Config->get_feedback_interval_ms());
} else {
timeout = -1;
}
@@ -162,7 +179,7 @@ Session::feedback_thread_work ()
switch ((FeedbackRequest::Type) req) {
case FeedbackRequest::Start:
- timeout = max (5, (int) Config->get_midi_feedback_interval_ms());
+ timeout = max (5, (int) Config->get_feedback_interval_ms());
active_feedback++;
break;
@@ -197,50 +214,29 @@ Session::feedback_thread_work ()
continue;
}
- for (list<FeedbackFunctionPtr>::iterator i = feedback_functions.begin(); i != feedback_functions.end(); ) {
-
- list<FeedbackFunctionPtr>::iterator tmp;
-
- tmp = i;
- ++tmp;
-
- if ((*i) ()) {
- feedback_functions.erase (i);
+ bool send = false;
+
+ for (vector<ControlProtocol*>::iterator i = control_protocols.begin(); i != control_protocols.end(); ++i) {
+ if ((*i)->send()) {
+ send = true;
+ break;
}
-
- i = tmp;
}
- }
-
- return 0;
-}
+
+ if (send) {
-int
-Session::feedback_generic_midi_function ()
-{
- const int32_t bufsize = 16 * 1024;
- int32_t bsize = bufsize;
- MIDI::byte* buf = new MIDI::byte[bufsize];
- MIDI::byte* end = buf;
+ RouteList routes = get_routes(); /* copies the routes */
- {
- RWLockMonitor lm (route_lock, false, __LINE__, __FILE__);
-
- for (RouteList::iterator i = routes.begin(); i != routes.end(); ++i) {
- end = (*i)->write_midi_feedback (end, bsize);
+ for (vector<ControlProtocol*>::iterator i = control_protocols.begin(); i != control_protocols.end(); ++i) {
+ if ((*i)->send_route_feedback ()) {
+ (*i)->send_route_feedback (routes);
+ }
+ (*i)->send_global_feedback ();
+ }
}
}
-
- if (end == buf) {
- delete [] buf;
- return 0;
- }
- deliver_midi (_midi_port, buf, (int32_t) (end - buf));
-
- //cerr << "MIDI feedback: wrote " << (int32_t) (end - buf) << " to midi port\n";
-
-
return 0;
}
+