Update NTK.
[nondaw.git] / mixer / src / Plugin_Module.H
blobe32cafc576a532b34bf916df836acd1be5f13c14
2 /*******************************************************************************/
3 /* Copyright (C) 2009 Jonathan Moore Liles                                     */
4 /*                                                                             */
5 /* This program is free software; you can redistribute it and/or modify it     */
6 /* under the terms of the GNU General Public License as published by the       */
7 /* Free Software Foundation; either version 2 of the License, or (at your      */
8 /* option) any later version.                                                  */
9 /*                                                                             */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
12 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
13 /* more details.                                                               */
14 /*                                                                             */
15 /* You should have received a copy of the GNU General Public License along     */
16 /* with This program; see the file COPYING.  If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18 /*******************************************************************************/
20 #pragma once
22 #include "Module.H"
23 #include "Loggable.H"
25 class Fl_Menu_Button;
26 class Thread;
28 class Plugin_Module : public Module {
30     static Thread *plugin_discover_thread;
32 public:
34     struct Plugin_Info
35     {
36         const char *path;
37         unsigned long id;
39         Plugin_Info ( )
40             {
41                 path = 0;
42                 id = 0;
43             }
44     };
46     bool load ( unsigned long id );
48 private:
50     void init ( void );
52     void bbox ( int &X, int &Y, int &W, int &H )
53         {
54             X = x();
55             Y = y() + 5;
56             W = w();
57             H = h() - 10;
58         }
60     void cb_handle(Fl_Widget*);
61     static void cb_handle(Fl_Widget*, void*);
63     Fl_Button *close_button;
65     struct ImplementationData;
67     ImplementationData *_idata;
69     bool _active;
70     int _plugin_ins;
71     int _plugin_outs;
72     bool _crosswire;
74     static void *discover_thread ( void * );
75     static Plugin_Info* get_all_plugins ( void );
78     void set_input_buffer ( int n, void *buf );
79     void set_output_buffer ( int n, void *buf );
80     void set_control_buffer ( int n, void *buf );
81     void activate ( void );
82     void deactivate ( void );
83     void process ( unsigned long nframes );
84     bool active ( void ) const { return _active; }
86     bool plugin_instances ( unsigned int );
88     void connect_ports ( void );
91 public:
93     static void spawn_discover_thread ( void );
94     static void join_discover_thread ( void );
96     Plugin_Module ( );
97     virtual ~Plugin_Module();
99     static Plugin_Module * pick_plugin ( void );
100     static void add_plugins_to_menu ( Fl_Menu_Button *menu );
102     int plugin_ins ( void ) const { return _plugin_ins; }
103     int plugin_outs ( void ) const { return _plugin_outs; }
105     void select_plugin ( unsigned long id );
107     const char *name ( void ) const { return "Plugin"; }
109     int can_support_inputs ( int );
110     bool configure_inputs ( int );
112     void process ( nframes_t );
114     void handle_port_connection_change ( void );
116     LOG_CREATE_FUNC( Plugin_Module );
118     MODULE_CLONE_FUNC( Plugin_Module );
120 protected:
122     void get ( Log_Entry &e ) const;
123     void set ( Log_Entry &e );