add new control protocol related files
[ardour.git] / libs / ardour / ardour / control_protocol.h
index c0869fad9a7a95bc9890e7e0128e959c54d64891..4088e2dd09d078bfbd4acb2b84d82291fa2f23a4 100644 (file)
@@ -16,7 +16,8 @@ class ControlProtocol : sigc::trackable {
        virtual ~ControlProtocol();
 
        virtual int init () { return 0; }
-       virtual bool active() const = 0;
+
+       sigc::signal<void> ActiveChanged;
 
        enum SendWhat {
                SendRoute,
@@ -26,6 +27,9 @@ class ControlProtocol : sigc::trackable {
        std::string name() const { return _name; }
 
        void set_send (SendWhat);
+       void set_active (bool yn);
+       bool get_active() const { return active_thread > 0; }
+
 
        bool send() const { return _send != 0; }
        bool send_route_feedback () const { return _send & SendRoute; }
@@ -35,11 +39,43 @@ class ControlProtocol : sigc::trackable {
        virtual void send_global_feedback () {}
 
   protected:
+
        ARDOUR::Session& session;
        SendWhat _send;
        std::string _name;
+       int active_thread;
+       int thread_request_pipe[2];
+       pthread_t _thread;
+
+       static void* _thread_work (void *);
+       void* thread_work ();
+
+       struct ThreadRequest {
+           enum Type {
+                   Start,
+                   Stop,
+                   Quit
+           };
+       };
+
+       int init_thread();
+       int start_thread ();
+       int stop_thread ();
+       void terminate_thread ();
+       int  poke_thread (ThreadRequest::Type);
 };
 
+extern "C" {
+       struct ControlProtocolDescriptor {
+           const char* name;
+           void*       ptr;
+           void*       module;
+           ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
+           void             (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
+           
+       };
+}
+
 }
 
 #endif // ardour_control_protocols_h