4 #include "edlsession.h"
7 #include "mainprogress.h"
9 #include "mwindowgui.h"
10 #include "pluginarray.h"
11 #include "pluginserver.h"
12 #include "preferences.h"
13 #include "bcprogressbox.h"
16 #define _(String) gettext(String)
17 #define gettext_noop(String) String
18 #define N_(String) gettext_noop (String)
22 PluginArray::PluginArray()
23 : ArrayList<PluginServer*>()
27 PluginArray::~PluginArray()
34 PluginServer* PluginArray::scan_plugindb(char *title)
36 return mwindow->scan_plugindb(title);
39 int PluginArray::start_plugins(MWindow *mwindow,
41 PluginServer *plugin_server,
47 this->mwindow = mwindow;
49 this->plugin_server = plugin_server;
50 this->keyframe = keyframe;
55 cache = new CICache(this->edl, mwindow->preferences, mwindow->plugindb);
56 //printf("PluginArray::start_plugins 1\n");
57 buffer_size = get_bufsize();
58 get_recordable_tracks();
62 //printf("PluginArray::start_plugins 2\n");
63 if(!plugin_server->realtime)
68 if(!plugin_server->multichannel)
70 // ============================ single channel plugins
71 // start 1 plugin for each track
72 for(i = 0; i < total_tracks(); i++)
74 //printf("PluginArray::start_plugins 3 %d\n", i);
75 append(plugin = new PluginServer(*plugin_server));
76 plugin->set_mwindow(mwindow);
77 plugin->set_keyframe(keyframe);
78 plugin->set_module(modules[i]);
79 plugin->open_plugin(0, mwindow->edl, 0);
80 if(i == 0) plugin->set_interactive();
81 plugin->start_loop(start, end, buffer_size, 1);
82 //printf("PluginArray::start_plugins 4\n");
87 // ============================ multichannel
88 // start 1 plugin for all tracks
89 //printf("PluginArray::start_plugins 5\n");
90 append(plugin = new PluginServer(*plugin_server));
91 //printf("PluginArray::start_plugins 4\n");
92 plugin->set_mwindow(mwindow);
93 //printf("PluginArray::start_plugins 4\n");
94 plugin->set_keyframe(keyframe);
95 //printf("PluginArray::start_plugins 4\n");
96 for(i = 0; i < total_tracks(); i++)
97 plugin->set_module(modules[i]);
98 //printf("PluginArray::start_plugins 4\n");
99 plugin->open_plugin(0, mwindow->edl, 0);
100 // set one plugin for progress bars
101 plugin->set_interactive();
102 //printf("PluginArray::start_plugins 4\n");
103 plugin->start_loop(start, end, buffer_size, total_tracks());
104 //printf("PluginArray::start_plugins 6\n");
107 //printf("PluginArray::start_plugins 5\n");
111 PluginServer *plugin;
114 if(!plugin_server->multichannel)
116 // single channel plugins
117 // start 1 plugin for each track
118 for(i = 0; i < total_tracks(); i++)
120 append(plugin = new PluginServer(*plugin_server));
121 plugin->set_mwindow(mwindow);
122 plugin->set_keyframe(keyframe);
123 plugin->open_plugin(0, mwindow->edl, 0);
124 plugin->init_realtime(0, 1, get_bufsize());
125 // Plugin loads configuration on its own
126 // plugin->get_configuration_change(plugin_data);
132 // start 1 plugin for all tracks
133 append(plugin = new PluginServer(*plugin_server));
134 plugin->set_mwindow(mwindow);
135 plugin->set_keyframe(keyframe);
136 plugin->open_plugin(0, mwindow->edl, 0);
137 plugin->init_realtime(0, total_tracks(), get_bufsize());
138 // Plugin loads configuration on its own
139 // plugin->get_configuration_change(plugin_data);
142 //printf("PluginArray::start_plugins 8\n");
150 int PluginArray::run_plugins()
153 // Length to write after process_loop
154 int64_t write_length;
156 done = 0; // for when done
158 //printf("PluginArray::run_plugins 1\n");
159 if(plugin_server->realtime)
162 MainProgressBar *progress;
163 char string[BCTEXTLEN], string2[BCTEXTLEN];
165 //printf("PluginArray::run_plugins 2\n");
166 sprintf(string, _("%s..."), plugin_server->title);
167 progress = mwindow->mainprogress->start_progress(string, end - start);
169 //printf("PluginArray::run_plugins 3\n");
170 for(int current_position = start;
171 current_position < end && !done && !error;
172 current_position += len)
175 if(current_position + len > end) len = end - current_position;
177 //printf("PluginArray::run_plugins 4\n");
179 for(i = 0; i < total_tracks(); i++)
181 load_module(i, current_position, len);
183 //printf("PluginArray::run_plugins 5\n");
186 for(i = 0; i < total; i++)
188 process_realtime(i, current_position, len);
190 //printf("PluginArray::run_plugins 6 %d\n", len);
193 error = write_buffers(len);
194 done = progress->update(current_position - start + len);
195 //printf("PluginArray::run_plugins 7 %d %d %d %d\n", error, done, current_position, end);
198 progress->get_time(string2);
199 progress->stop_progress();
202 sprintf(string, _("%s took %s"), plugin_server->title, string2);
203 mwindow->gui->lock_window();
204 mwindow->gui->show_message(string2, BLACK);
205 mwindow->gui->unlock_window();
206 //printf("PluginArray::run_plugins 8\n");
210 // Run main loop once for multichannel plugins.
211 // Run multiple times for single channel plugins.
212 // Each write to the file must contain all the channels
213 while(!done && !error)
215 for(i = 0; i < total; i++)
217 //printf("PluginArray::run_plugins 9 %d\n", i);
219 done += process_loop(i, write_length);
220 //printf("PluginArray::run_plugins 10 %d\n", write_length);
225 error = write_buffers(write_length);
226 //printf("PluginArray::run_plugins 11 %d\n", write_length);
234 int PluginArray::stop_plugins()
236 if(plugin_server->realtime)
238 for(int i = 0; i < total; i++)
240 values[i]->close_plugin();
245 for(int i = 0; i < total; i++)
247 values[i]->stop_loop();
248 values[i]->close_plugin();