summaryrefslogtreecommitdiff
path: root/libs/ardour/session_feedback.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-04-05 00:21:43 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-04-05 00:21:43 +0000
commit9ae0f6cbeec4702b50bcd2360ea4d5dc1aeebd47 (patch)
tree4879aebc558936ab87857749656b66a208b9ee99 /libs/ardour/session_feedback.cc
parentf7c82c69113419a8db083f0095044af5ad4c872c (diff)
a) dynamically loadable control surface support
b) move tranzport and generic midi into separate dirs under "surfaces" git-svn-id: svn://localhost/trunk/ardour2@442 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/session_feedback.cc')
-rw-r--r--libs/ardour/session_feedback.cc193
1 files changed, 0 insertions, 193 deletions
diff --git a/libs/ardour/session_feedback.cc b/libs/ardour/session_feedback.cc
index 09e9021461..600567892e 100644
--- a/libs/ardour/session_feedback.cc
+++ b/libs/ardour/session_feedback.cc
@@ -45,198 +45,5 @@ using namespace std;
using namespace ARDOUR;
//using namespace sigc;
-int
-Session::init_feedback ()
-{
- if (pipe (feedback_request_pipe) != 0) {
- error << string_compose (_("cannot create feedback request pipe (%1)"),
- strerror (errno))
- << endmsg;
- return -1;
- }
-
- if (fcntl (feedback_request_pipe[0], F_SETFL, O_NONBLOCK)) {
- error << string_compose(_("UI: cannot set O_NONBLOCK on " "signal read pipe (%1)"), strerror (errno)) << endmsg;
- return -1;
- }
-
- if (fcntl (feedback_request_pipe[1], F_SETFL, O_NONBLOCK)) {
- error << string_compose(_("UI: cannot set O_NONBLOCK on " "signal write pipe (%1)"), strerror (errno)) << endmsg;
- return -1;
- }
-
- active_feedback = 0;
-
- if (pthread_create_and_store ("feedback", &feedback_thread, 0, _feedback_thread_work, this)) {
- error << _("Session: could not create feedback thread") << endmsg;
- return -1;
- }
-
- return 0;
-}
-
-int
-Session::poke_feedback (FeedbackRequest::Type why)
-{
- char c = (char) why;
- return !(write (feedback_request_pipe[1], &c, 1) == 1);
-}
-
-int
-Session::start_feedback ()
-{
- return poke_feedback (FeedbackRequest::Start);
-}
-
-int
-Session::stop_feedback ()
-{
- return poke_feedback (FeedbackRequest::Stop);
-}
-
-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;
- poke_feedback (FeedbackRequest::Quit);
- pthread_join (feedback_thread, &status);
-}
-
-void*
-Session::_feedback_thread_work (void* arg)
-{
- return static_cast<Session*> (arg)->feedback_thread_work ();
-}
-
-void*
-Session::feedback_thread_work ()
-{
- PBD::ThreadCreated (pthread_self(), X_("Feedback"));
- struct pollfd pfd[1];
- int timeout;
-
- pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
- pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
-
- if (active_feedback) {
- timeout = max (5, (int) Config->get_feedback_interval_ms());
- } else {
- timeout = -1;
- }
-
- while (1) {
-
- pfd[0].fd = feedback_request_pipe[0];
- pfd[0].events = POLLIN|POLLHUP|POLLERR;
-
- if (poll (pfd, 1, timeout) < 0) {
- if (errno == EINTR) {
- continue;
- }
- error << string_compose (_("Feedback thread poll failed (%1)"),
- strerror (errno))
- << endmsg;
- break;
- }
-
- if (pfd[0].revents & ~POLLIN) {
- error << _("Error on feedback thread request pipe") << endmsg;
- break;
- }
-
- if (pfd[0].revents & POLLIN) {
-
- char req;
-
- /* empty the pipe of all current requests */
-
- while (1) {
- size_t nread = read (feedback_request_pipe[0], &req, sizeof (req));
-
- if (nread == 1) {
- switch ((FeedbackRequest::Type) req) {
-
- case FeedbackRequest::Start:
- timeout = max (5, (int) Config->get_feedback_interval_ms());
- active_feedback++;
- break;
-
- case FeedbackRequest::Stop:
- timeout = -1;
- if (active_feedback) {
- active_feedback--;
- }
- break;
-
- case FeedbackRequest::Quit:
- pthread_exit_pbd (0);
- /*NOTREACHED*/
- break;
-
- default:
- break;
- }
-
- } else if (nread == 0) {
- break;
- } else if (errno == EAGAIN) {
- break;
- } else {
- fatal << _("Error reading from feedback request pipe") << endmsg;
- /*NOTREACHED*/
- }
- }
- }
-
- if (!active_feedback || transport_stopped()) {
- continue;
- }
-
- bool send = false;
-
- for (vector<ControlProtocol*>::iterator i = control_protocols.begin(); i != control_protocols.end(); ++i) {
- if ((*i)->send()) {
- send = true;
- break;
- }
- }
-
- if (send) {
-
- RouteList routes = get_routes(); /* copies the routes */
-
- 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 ();
- }
- }
- }
-
- return 0;
-}