audio chan pos rework, batchrender deadlock, titler/crikey grab_event tweak, thread...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / performanceprefs.C
index 99268702d7d63c42745c1be72776508c3a615dea..7adb020b099970b1c7bb4cc6015bc84215ea6bd2 100644 (file)
@@ -28,6 +28,7 @@
 #include "mwindow.h"
 #include "performanceprefs.h"
 #include "preferences.h"
+#include <ctype.h>
 #include <string.h>
 #include "theme.h"
 
@@ -55,13 +56,13 @@ void PerformancePrefs::create_objects()
 {
        int x, y;
        int xmargin1;
-       int xmargin2 = 170;
-       int xmargin3 = 250;
-       int xmargin4 = 380;
+       int xmargin2 = 180;
+       int xmargin3 = 260;
+       int xmargin4 = 420;
        char string[BCTEXTLEN];
        BC_Resources *resources = BC_WindowBase::get_resources();
        BC_WindowBase *win;
-       int maxw, curw, y1;
+       int maxw, curw;
 
        node_list = 0;
        generate_node_list();
@@ -77,53 +78,34 @@ void PerformancePrefs::create_objects()
 //
 //     y += get_text_height(LARGEFONT) + 5;
 
-       int ybx[2];
-       ybx[0] = y;
+       int y0 = y;
 
        win = add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
        maxw = win->get_w();
 
-       ybx[1] = y += 30;
+       int y1 = y += 30;
        win = add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
        if((curw = win->get_w()) > maxw)
                maxw = curw;
        maxw += x + 5;
 
-       cache_size = new CICacheSize(maxw,
-               ybx[0],
-               pwindow,
-               this);
+       cache_size = new CICacheSize(maxw, y0, pwindow, this);
        cache_size->create_objects();
+
        add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
-       PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
-               this,
-               maxw,
-               ybx[1]);
+       PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow, this, maxw, y1);
        preroll->create_objects();
        y += 30;
-       PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
-       add_subwindow(force_1cpu);
-
-       int x1 = force_1cpu->get_x() + force_1cpu->get_w() + 100;
-
-       PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x1, y);
-       add_subwindow(trap_segv);
-       int x2 = x1 + trap_segv->get_w() + 10;
-       add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
-       y += 30;
-
-       PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x1, y);
-       add_subwindow(trap_intr);
-       add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
-       ffmpeg_marker_indexes = new PrefsFFMPEGMarkerIndecies(this, x, y);
-       add_subwindow(ffmpeg_marker_indexes);
-       y += 30;
 
-       ffmpeg_early_probe = new PrefsFFMPEGEarlyProbe(this, x, y);
-       add_subwindow(ffmpeg_early_probe);
+       int x1 = x + xmargin4;
+       BC_Title *smp_title = new BC_Title(x1, y + 5, _("Project SMP cpus:"));
+       add_subwindow(smp_title);
+       int x2 = x1 + smp_title->get_w() + 5;
+       PrefsProjectSMP *proj_smp = new PrefsProjectSMP(pwindow, this, x2, y);
+       proj_smp->create_objects();
 
-       yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x1, y);
-       add_subwindow(yuv420p_dvdlace);
+       PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
+       add_subwindow(force_1cpu);
        y += 30;
 
 // Background rendering
@@ -134,9 +116,7 @@ void PerformancePrefs::create_objects()
        add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
        y1 = y += 30;
 
-       win = add_subwindow(new PrefsUseBRender(pwindow,
-               x,
-               y));
+       win = add_subwindow(new PrefsUseBRender(pwindow, x, y));
 
        y += win->get_h() + 10;
        win = add_subwindow(new BC_Title(x, y, _("Frames per background rendering job:")));
@@ -174,7 +154,7 @@ void PerformancePrefs::create_objects()
                1,
                0,  // Select compressors to be offered
                0,  // Prompt for recording options
-               0,  // If nonzero, prompt for insertion strategy
+               0,  // prompt for use labels
                1); // Supply file formats for background rendering
        x = xmargin1;
 
@@ -295,7 +275,7 @@ void PerformancePrefs::generate_node_list()
        }
 }
 
-static const char *titles[] =
+static const char *default_titles[] =
 {
        N_("On"),
        N_("Hostname"),
@@ -303,7 +283,7 @@ static const char *titles[] =
        N_("Framerate")
 };
 
-static int widths[] =
+static int default_widths[] =
 {
        30,
        150,
@@ -314,13 +294,13 @@ static int widths[] =
 
 void PerformancePrefs::update_node_list()
 {
-       node_list->update(nodes,
-                                               titles,
-                                               widths,
-                                               TOTAL_COLUMNS,
-                                               node_list->get_xposition(),
-                                               node_list->get_yposition(),
-                                               node_list->get_selection_number(0, 0));
+       node_list->update_list();
+}
+
+void PrefsRenderFarmNodes::update_list()
+{
+       update(subwindow->nodes, titles, widths, PerformancePrefs::TOTAL_COLUMNS,
+               get_xposition(), get_yposition(), get_selection_number(0, 0));
 }
 
 
@@ -519,77 +499,6 @@ int PrefsForceUniprocessor::handle_event()
        return 1;
 }
 
-PrefsTrapSigSEGV::PrefsTrapSigSEGV(PerformancePrefs *perf_prefs, int x, int y)
- : BC_CheckBox(x, y,
-       perf_prefs->pwindow->thread->preferences->trap_sigsegv,
-       _("trap sigSEGV"))
-{
-       this->perf_prefs = perf_prefs;
-}
-PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
-{
-}
-int PrefsTrapSigSEGV::handle_event()
-{
-       perf_prefs->pwindow->thread->preferences->trap_sigsegv = get_value();
-       return 1;
-}
-
-PrefsTrapSigINTR::PrefsTrapSigINTR(PerformancePrefs *perf_prefs, int x, int y)
- : BC_CheckBox(x, y,
-       perf_prefs->pwindow->thread->preferences->trap_sigintr,
-       _("trap sigINT"))
-{
-       this->perf_prefs = perf_prefs;
-}
-PrefsTrapSigINTR::~PrefsTrapSigINTR()
-{
-}
-int PrefsTrapSigINTR::handle_event()
-{
-       perf_prefs->pwindow->thread->preferences->trap_sigintr = get_value();
-       return 1;
-}
-
-
-PrefsFFMPEGEarlyProbe::PrefsFFMPEGEarlyProbe(PerformancePrefs *perf_prefs, int x, int y)
- : BC_CheckBox(x, y,
-       perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe,
-       _("On file open, ffmpeg probes early"))
-{
-       this->perf_prefs = perf_prefs;
-}
-PrefsFFMPEGEarlyProbe::~PrefsFFMPEGEarlyProbe()
-{
-}
-
-int PrefsFFMPEGEarlyProbe::handle_event()
-{
-       perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe = get_value();
-       return 1;
-}
-
-
-PrefsFFMPEGMarkerIndecies::PrefsFFMPEGMarkerIndecies(PerformancePrefs *perf_prefs, int x, int y)
- : BC_CheckBox(x, y,
-       perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
-       _("build ffmpeg marker indexes"))
-{
-       this->perf_prefs = perf_prefs;
-}
-PrefsFFMPEGMarkerIndecies::~PrefsFFMPEGMarkerIndecies()
-{
-}
-
-int PrefsFFMPEGMarkerIndecies::handle_event()
-{
-       perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
-       return 1;
-}
-
-
-
-
 
 
 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
@@ -610,9 +519,6 @@ int PrefsRenderFarmConsolidate::handle_event()
 }
 
 
-
-
-
 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
        PerformancePrefs *subwindow,
        int x,
@@ -641,19 +547,15 @@ int PrefsRenderFarmPort::handle_event()
 
 
 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
-       PerformancePrefs *subwindow,
-       int x,
-       int y)
- : BC_ListBox(x,
-               y,
-               340,
-               230,
-               LISTBOX_TEXT,                         // Display text list or icons
-               subwindow->nodes,
-               titles,
-               widths,
-               4)
+       PerformancePrefs *subwindow, int x, int y)
+ : BC_ListBox(x, y, 340, 230, LISTBOX_TEXT, 0,0,0,1, 0,0, LISTBOX_MULTIPLE)
 {
+       for( int i=0; i<PerformancePrefs::TOTAL_COLUMNS; ++i ) {
+               titles[i] = _(default_titles[i]);
+               widths[i] = default_widths[i];
+       }
+       update(subwindow->nodes, titles, widths, PerformancePrefs::TOTAL_COLUMNS,
+               0, 0, -1, 0, 0);
        this->subwindow = subwindow;
        this->pwindow = pwindow;
 }
@@ -663,7 +565,7 @@ PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
 
 int PrefsRenderFarmNodes::column_resize_event()
 {
-       for(int i = 0; i < 3; i++)
+       for( int i=0; i<PerformancePrefs::TOTAL_COLUMNS; ++i )
                widths[i] = get_column_width(i);
        return 1;
 }
@@ -675,7 +577,9 @@ SET_TRACE
        {
                subwindow->hot_node = get_selection_number(1, 0);
                subwindow->edit_node->update(get_selection(1, 0)->get_text());
-               subwindow->edit_port->update(get_selection(2, 0)->get_text());
+               const char *text = get_selection(2, 0)->get_text();
+               subwindow->edit_port->update(text);
+               pwindow->thread->preferences->renderfarm_port = atol(text);
                if(get_cursor_x() < widths[0])
                {
                        pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
@@ -726,7 +630,7 @@ int PrefsRenderFarmEditNode::handle_event()
 
 
 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
- : BC_GenericButton(x, y, _("Add Node"))
+ : BC_GenericButton(x, y, _("Add Nodes"))
 {
        this->pwindow = pwindow;
        this->subwindow = subwindow;
@@ -736,10 +640,17 @@ PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
 }
 int PrefsRenderFarmNewNode::handle_event()
 {
-       pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
-               pwindow->thread->preferences->renderfarm_port,
-               1,
-               0.0);
+       const char *name = subwindow->edit_node->get_text();
+       char *cp = (char*)subwindow->edit_port->get_text();
+       int64_t start_port = strtol(cp, &cp, 0), end_port = start_port;
+       while( isspace(*cp) ) ++cp;
+       if( *cp++ == '-' )
+               end_port = strtol(cp, &cp, 0);
+       for( int port=start_port; port<=end_port; ++port ) {
+               pwindow->thread->preferences->add_node(name, port, 1, 0.0);
+       }
+       pwindow->thread->preferences->renderfarm_port = end_port;
+       subwindow->edit_port->update(end_port);
        pwindow->thread->preferences->reset_rates();
        subwindow->generate_node_list();
        subwindow->update_node_list();
@@ -781,7 +692,7 @@ int PrefsRenderFarmReplaceNode::handle_event()
 
 
 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
- : BC_GenericButton(x, y, _("Delete Node"))
+ : BC_GenericButton(x, y, _("Delete Nodes"))
 {
        this->pwindow = pwindow;
        this->subwindow = subwindow;
@@ -791,13 +702,14 @@ PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
 }
 int PrefsRenderFarmDelNode::handle_event()
 {
-       if( subwindow->hot_node >= 0 ) {
-               pwindow->thread->preferences->delete_node(subwindow->hot_node);
-
-               subwindow->generate_node_list();
-               subwindow->update_node_list();
-               subwindow->hot_node = -1;
+       ArrayList<BC_ListBoxItem *> &item_list = subwindow->nodes[0];
+       for( int i=item_list.size(); --i>=0; ) {
+               if( !item_list[i]->get_selected() ) continue;
+               pwindow->thread->preferences->delete_node(i);
        }
+       subwindow->generate_node_list();
+       subwindow->update_node_list();
+       subwindow->hot_node = -1;
        return 1;
 }
 
@@ -861,6 +773,25 @@ int PrefsRenderFarmReset::handle_event()
 
 
 
+PrefsProjectSMP::PrefsProjectSMP(PreferencesWindow *pwindow,
+               PerformancePrefs *subwindow, int x, int y)
+ : BC_TumbleTextBox(subwindow,
+       (int64_t)pwindow->thread->preferences->project_smp,
+       (int64_t)1, (int64_t)100, x, y, 100)
+{
+       this->pwindow = pwindow;
+}
+PrefsProjectSMP::~PrefsProjectSMP()
+{
+}
+int PrefsProjectSMP::handle_event()
+{
+       pwindow->thread->preferences->project_smp = atol(get_text());
+       return 1;
+}
+
+
+
 
 
 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
@@ -928,19 +859,3 @@ int PrefsRenderFarmVFS::handle_event()
        return 1;
 }
 
-
-PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
-       PerformancePrefs *subwindow, int x, int y)
- : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
-       _("Use yuv420p dvd interlace format"))
-{
-       this->pwindow = pwindow;
-       this->subwindow = subwindow;
-}
-
-int PrefsYUV420P_DVDlace::handle_event()
-{
-       pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();
-       return 1;
-}
-