#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
+#include <sys/file.h>
#include <limits.h>
#include <errno.h>
delete [] base_path;
}
-int MWindow::load_plugin_index(MWindow *mwindow, const char *index_path, const char *plugin_dir)
+int MWindow::load_plugin_index(MWindow *mwindow, FILE *fp, const char *plugin_dir)
{
-// load index
- FILE *fp = fopen(index_path, "r");
if( !fp ) return -1;
-
+// load index
+ fseek(fp, 0, SEEK_SET);
int ret = 0;
char index_line[BCTEXTLEN];
int index_version = -1, len = strlen(plugin_dir);
ret = 1; continue;
}
}
- fclose(fp);
if( !ret )
ret = check_plugin_index(plugins, plugin_dir, ".");
create_defaults_path(index_path, PLUGIN_FILE);
char *plugin_dir = FileSystem::basepath(preferences->plugin_dir);
strcpy(plugin_path, plugin_dir); delete [] plugin_dir;
- if( !load_plugin_index(mwindow, index_path, plugin_path) ) return 1;
- printf("init plugin index: %s\n", plugin_path);
- FILE *fp = fopen(index_path,"w");
+ FILE *fp = fopen(index_path,"a+");
if( !fp ) {
fprintf(stderr,_("MWindow::init_plugins: "
- "can't create plugin index: %s\n"), index_path);
- return 1;
+ "can't open plugin index: %s\n"), index_path);
+ return -1;
+ }
+ int fd = fileno(fp), ret = -1;
+ if( !flock(fd, LOCK_EX) ) {
+ fseek(fp, 0, SEEK_SET);
+ ret = load_plugin_index(mwindow, fp, plugin_path);
+ }
+ if( ret > 0 ) {
+ ftruncate(fd, 0);
+ fseek(fp, 0, SEEK_SET);
+ printf("init plugin index: %s\n", plugin_path);
+ fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
+ fprintf(fp, "%s\n", plugin_path);
+ init_plugin_index(mwindow, preferences, fp, plugin_path);
+ init_ffmpeg_index(mwindow, preferences, fp);
+ init_lv2_index(mwindow, preferences, fp);
+ fseek(fp, 0, SEEK_SET);
+ ret = load_plugin_index(mwindow, fp, plugin_path);
+ }
+ if( ret ) {
+ fprintf(stderr,_("MWindow::init_plugins: "
+ "can't %s plugin index: %s\n"),
+ ret>0 ? _("create") : _("lock"), index_path);
}
- fprintf(fp, "%d\n", PLUGIN_FILE_VERSION);
- fprintf(fp, "%s\n", plugin_path);
- init_plugin_index(mwindow, preferences, fp, plugin_path);
- init_ffmpeg_index(mwindow, preferences, fp);
- init_lv2_index(mwindow, preferences, fp);
fclose(fp);
- return load_plugin_index(mwindow, index_path, plugin_path);
+ return ret;
}
int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
for( char *bp=plugin_path; *bp!=0; ++bp )
*cp++ = *bp=='/' ? '_' : *bp;
*cp = 0;
- if( !load_plugin_index(mwindow, index_path, plugin_path) ) continue;
- if( init_ladspa_index(mwindow, preferences, index_path, plugin_path) ) continue;
- load_plugin_index(mwindow, index_path, plugin_path);
+ FILE *fp = fopen(index_path,"a+");
+ if( !fp ) {
+ fprintf(stderr,_("MWindow::init_ladspa_plugins: "
+ "can't open ladspa plugin index: %s\n"), index_path);
+ continue;
+ }
+ int fd = fileno(fp), ret = -1;
+ if( !flock(fd, LOCK_EX) ) {
+ fseek(fp, 0, SEEK_SET);
+ ret = load_plugin_index(mwindow, fp, plugin_path);
+ }
+ if( ret > 0 ) {
+ ftruncate(fd, 0);
+ fseek(fp, 0, SEEK_SET);
+ init_ladspa_index(mwindow, preferences, fp, plugin_path);
+ fseek(fp, 0, SEEK_SET);
+ ret = load_plugin_index(mwindow, fp, plugin_path);
+ }
+ if( ret ) {
+ fprintf(stderr,_("MWindow::init_ladspa_plugins: "
+ "can't %s ladspa plugin index: %s\n"),
+ ret>0 ? _("create") : _("lock"), index_path);
+ }
+ fclose(fp);
}
return 1;
}
void MWindow::close_mixers(int destroy)
{
+ ArrayList<ZWindow*> closed;
zwindows_lock->lock("MWindow::close_mixers");
for( int i=zwindows.size(); --i>=0; ) {
ZWindow *zwindow = zwindows[i];
zgui->lock_window("MWindow::select_zwindow 0");
zgui->set_done(0);
zgui->unlock_window();
+ closed.append(zwindow);
}
zwindows_lock->unlock();
- for( int i=0; i<zwindows.size(); ++i ) {
- ZWindow *zwindow = zwindows[i];
- if( zwindow->idx < 0 ) continue;
- zwindow->close_window();
+ for( int i=0; i<closed.size(); ++i ) {
+ ZWindow *zwindow = closed[i];
+ zwindow->join();
}
}
void MWindow::init_gui()
{
gui = new MWindowGUI(this);
- gui->lock_window("MWindow::init_gui");
gui->create_objects();
- gui->unlock_window();
gui->load_defaults(defaults);
}
if( edl->session->proxy_scale == 1 &&
edl->session->proxy_disabled_scale != 1 ) {
int new_scale = edl->session->proxy_disabled_scale;
+ int new_use_scaler = edl->session->proxy_use_scaler;
edl->session->proxy_disabled_scale = 1;
Asset *asset = new Asset;
asset->format = FILE_FFMPEG;
asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0);
- ret = to_proxy(asset, new_scale);
+ ret = to_proxy(asset, new_scale, new_use_scaler);
asset->remove_user();
if( ret > 0 )
beep(2000., 1.5, 0.5);
{
if( edl->session->proxy_scale != 1 &&
edl->session->proxy_disabled_scale == 1 ) {
+ int new_scale = 1;
+ int new_use_scaler = edl->session->proxy_use_scaler;
edl->session->proxy_disabled_scale = edl->session->proxy_scale;
Asset *asset = new Asset;
asset->format = FILE_FFMPEG;
asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0);
- to_proxy(asset, 1);
+ to_proxy(asset, new_scale, new_use_scaler);
asset->remove_user();
}
return 1;
}
-int MWindow::to_proxy(Asset *asset, int new_scale)
+int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler)
{
ArrayList<Indexable*> orig_idxbls;
ArrayList<Indexable*> proxy_assets;
// revert project to original size from current size
// remove all session proxy assets at the at the current proxy_scale
int proxy_scale = edl->session->proxy_scale;
- int proxy_use_scaler = edl->session->proxy_use_scaler;
if( proxy_scale > 1 ) {
Asset *orig_asset = edl->assets->first;
result = proxy_render.create_needed_proxies(new_scale);
if( !result ) // resize project
- edl->set_proxy(new_scale, proxy_use_scaler,
+ edl->set_proxy(new_scale, new_use_scaler,
&proxy_render.orig_idxbls, &proxy_render.orig_proxies);
undo->update_undo_after(_("proxy"), LOAD_ALL);
check_language();
init_preferences();
if(splash_window)
- splash_window->operation->update(_("Initializing Plugins"));
+ splash_window->update_status(_("Initializing Plugins"));
init_plugins(this, preferences);
if(debug) PRINT_TRACE
init_ladspa_plugins(this, preferences);
if(debug) PRINT_TRACE
init_plugin_tips(*plugindb, cin_lang);
if(splash_window)
- splash_window->operation->update(_("Initializing GUI"));
+ splash_window->update_status(_("Initializing GUI"));
if(debug) PRINT_TRACE
init_theme();
init_error();
if(splash_window)
- splash_window->operation->update(_("Initializing Fonts"));
+ splash_window->update_status(_("Initializing Fonts"));
char string[BCTEXTLEN];
strcpy(string, preferences->plugin_dir);
strcat(string, "/" FONT_SEARCHPATH);