no longer need ffmpeg patch0 which was for Termux
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / mwindow.C
index b7af252fc68f0b9b7b00690d3427abfd92f4858f..1291b99213fce9781c2fe883d733e9bb65cd6189 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -240,7 +241,6 @@ MWindow::MWindow()
        sighandler = 0;
        restart_status = 0;
        screens = 1;
-       appimageDir = getenv("APPDIR"); //NULL if not running as appimage
        in_destructor = 0;
        speed_edl = 0;
        beeper = 0;
@@ -284,8 +284,10 @@ MWindow::~MWindow()
        delete convert_render;  convert_render = 0;
        delete render;          render = 0;
        delete mixers_align;    mixers_align = 0;
+#ifdef HAVE_COMMERCIALS
        commit_commercial();
        if( commercials && !commercials->remove_user() ) commercials = 0;
+#endif
        close_mixers();
        if( speed_edl ) { speed_edl->remove_user();  speed_edl = 0; }
 // Save defaults for open plugins
@@ -561,9 +563,8 @@ void MWindow::get_plugin_path(char *path, const char *plug_dir, const char *fs_p
 * @brief Load plugins according to an index file.
 * 
 * @details Builds an ArrayList of plugin servers only if there is no
-* mismatch for file layout version, index identifier, or executable
-* timestamp mismatch for the built-in plugins. If OK, add the plugin
-* servers to the global list.
+* mismatch for file layout version, index identifier, or timestamp of
+* the built-in plugins. If OK, add the plugin servers to the global list.
 * 
 * @note If an error is returned the index file needs to be rebuilt, and
 * then this function must be called again.
@@ -673,9 +674,13 @@ int MWindow::check_plugin_index(ArrayList<PluginServer*> &plugins,
        }
        return 0;
 }
-/*
+
+/**
 * @brief Load built-in and LV2 plugins as specified in index file,
 *        rebuild the index file if needed.
+* @param[in]   mwindow: GUI class pointer, will be NULL for batch
+*               rendering or renderfarm client.
+* @param[in]   preferences: Information from cinelerra_rc file.
 */
 int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
 {
@@ -689,7 +694,7 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
        // index_id is 2nd line of the index file, normally full plugin path,
        // but fixed value if AppImage because the path changes on each run.
        // And if the second line does not match on the next run the index is rebuilt.
-       if( mwindow->appimageDir ) strcpy(index_id, getenv("CINGG_BUILD"));
+       if( getenv("APPDIR") && getenv("CINGG_BUILD")) strcpy(index_id, getenv("CINGG_BUILD"));
        else strcpy(index_id, plugin_path);
        FILE *fp = fopen(index_path,"a+");
        if( !fp ) {
@@ -723,14 +728,18 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
        return ret;
 }
 
-/*
+/**
 * @brief Load ladspa plugins as specified in index files, for each ladspa
 *        directory keep a separate index file. Rebuild index file(s) if needed.
-**/
+* @param[in]   mwindow: GUI class pointer, will be NULL for batch
+*               rendering or renderfarm client.
+* @param[in]   preferences: Information from cinelerra_rc file.
+*/
 int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
 {
 #ifdef HAVE_LADSPA
        char *path = getenv("LADSPA_PATH");
+       char *appdir = getenv("APPDIR");
        char ladspa_path[BCTEXTLEN];
        if( !path ) {                   // if no env var, use CinGG's own ladspa dir
                strncpy(ladspa_path, File::get_ladspa_path(), sizeof(ladspa_path));
@@ -749,7 +758,7 @@ int MWindow::init_ladspa_plugins(MWindow *mwindow, Preferences *preferences)
                // If the first part of the plugin_path matches the APPDIR, we are
                // referring to CinGG's ladspa, replace the path by a fixed ID. APPDIR
                // only exists if we are running as AppImage (with variable mount points).
-               if( mwindow->appimageDir && strncmp(plugin_path, mwindow->appimageDir, strlen(mwindow->appimageDir)) == 0 )
+               if( appdir && strncmp(plugin_path, appdir, strlen(appdir)) == 0 )
                        strcpy(index_id, getenv("CINGG_BUILD"));
                else strcpy(index_id, plugin_path);
 
@@ -818,7 +827,7 @@ void MWindow::scan_plugin_index(MWindow *mwindow, Preferences *preferences, FILE
                char fs_path[BCTEXTLEN], path[BCTEXTLEN];
                get_plugin_path(fs_path, 0, fs.dir_list[i]->path);
                get_plugin_path(path, plug_dir, fs_path);
-               if( fs.is_dir(fs_path) ) {
+               if( fs.is_dir(fs_path) ) {      // recursively scan child directory
                        scan_plugin_index(mwindow, preferences, fp, plug_dir, path, idx);
                        continue;
                }
@@ -2212,6 +2221,13 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__);
                        }
                        result = 0;
                        break; }
+// File is a list and size of listed files don't match
+  case FILE_SIZE_DONT_MATCH: {
+   eprintf(_("File sizes don't match"));
+   sprintf(string, _("File sizes don't match"));
+   gui->show_message(string, theme->message_error);
+   gui->update_default_message();
+   break; }
 
                case FILE_NOT_FOUND: {
                        eprintf(_("Failed to open %s"), new_asset->path);
@@ -5288,7 +5304,7 @@ int MWindow::select_asset(Asset *asset, int vstream, int astream, int delete_tra
                int channels = 0;
                for( uint64_t mask=channel_mask; mask!=0; mask>>=1 ) channels += mask & 1;
                if( channels < 1 ) channels = 1;
-               if( channels > 6 ) channels = 6;
+               if( channels > MAXCHANNELS ) channels = MAXCHANNELS;
                session->audio_tracks = session->audio_channels = channels;
 
                int *achannel_positions = preferences->channel_positions[session->audio_channels-1];