summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/control_protocol.h
blob: c2ab8736b738129c7bc40b88ec7ac582f8dfd850 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef ardour_control_protocols_h
#define ardour_control_protocols_h

#include <string>
#include <list>
#include <sigc++/sigc++.h>

namespace ARDOUR {

class Route;
class Session;

class ControlProtocol : public sigc::trackable {
  public:
	ControlProtocol (Session&, std::string name);
	virtual ~ControlProtocol();

	virtual int init () { return 0; }

	sigc::signal<void> ActiveChanged;

	enum SendWhat {
		SendRoute,
		SendGlobal
	};

	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; }
	bool send_global_feedback () const { return _send & SendGlobal; }

	virtual void send_route_feedback (std::list<Route*>&) {}
	virtual void send_global_feedback () {}

	/* signals that a control protocol can emit and other (presumably graphical)
	   user interfaces can respond to
	*/

	static sigc::signal<void> ZoomToSession;
	static sigc::signal<void> ZoomIn;
	static sigc::signal<void> ZoomOut;
	static sigc::signal<void> Enter;
	static sigc::signal<void,float> ScrollTimeline;

  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