]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/atmo/atmo.cpp
Spell "separate"
[vlc] / modules / video_filter / atmo / atmo.cpp
index 931699708e34175630bdc343af2231b56ceaa485..7e21b0e04b0c68c7b7f0081f5c719a5330c1639c 100644 (file)
@@ -67,12 +67,6 @@ static void DelStateVariableCallback( filter_t *);
 static int StateCallback(vlc_object_t *, char const *,
                          vlc_value_t, vlc_value_t, void *);
 
-/* callback for variable crop-update */
-static void AddCropVariableCallback( filter_t *);
-static void DelCropVariableCallback( filter_t *);
-static int CropCallback(vlc_object_t *, char const *,
-                        vlc_value_t, vlc_value_t, void *);
-
 /* callback for atmo settings variables whose change
    should be immediately realized and applied to output
 */
@@ -132,7 +126,7 @@ strings for settings menus and hints
  "You can also have a look at pictures and some movies showing such a device " \
  "in live action.")
 
-#define DRIVER_TEXT            N_("Devicetype")
+#define DRIVER_TEXT            N_("Device type")
 #define DRIVER_LONGTEXT        N_("Choose your prefered hardware from " \
                                   "the list, or choose AtmoWin Software " \
                                   "to delegate processing to the external " \
@@ -145,7 +139,8 @@ static const int pi_device_type_values[] = {
      1, /* AtmoLight classic */
      2, /* Quattro AtmoLight */
      3, /* DMX Device */
-     4  /* MoMoLight device */
+     4, /* MoMoLight device */
+     5  /* fnordlicht */
 };
 static const char *const ppsz_device_type_descriptions[] = {
 #if defined( WIN32 )
@@ -154,7 +149,8 @@ static const char *const ppsz_device_type_descriptions[] = {
         N_("Classic AtmoLight"),
         N_("Quattro AtmoLight"),
         N_("DMX"),
-        N_("MoMoLight")
+        N_("MoMoLight"),
+        N_("fnordlicht")
 };
 
 #define DMX_CHANNELS_TEXT      N_("Count of AtmoLight channels")
@@ -162,12 +158,17 @@ static const char *const ppsz_device_type_descriptions[] = {
                                   "emulated with that DMX device")
 #define DMX_CHBASE_TEXT        N_("DMX address for each channel")
 #define DMX_CHBASE_LONGTEXT    N_("Define here the DMX base address for each " \
-                                  "channel use , or ; to seperate the values")
+                                  "channel use , or ; to separate the values")
 
 #define MOMO_CHANNELS_TEXT      N_("Count of channels")
 #define MOMO_CHANNELS_LONGTEXT  N_("Depending on your MoMoLight hardware " \
                                    "choose 3 or 4 channels")
 
+#define FNORDLICHT_AMOUNT_TEXT      N_("Count of fnordlicht's")
+#define FNORDLICHT_AMOUNT_LONGTEXT  N_("Depending on the amount your " \
+                                   "fnordlicht hardware " \
+                                   "choose 1 to 4 channels")
+
 #if defined( WIN32 )
 #  define DEFAULT_DEVICE   0
 #else
@@ -322,7 +323,7 @@ static const char *const ppsz_zone_assignment_descriptions[] = {
 #define CHANNELS_ASSIGN_TEXT        N_("Channel / Zone Assignment")
 #define CHANNELS_ASSIGN_LONGTEXT N_("for devices with more than five " \
                   "channels / zones write down here for each channel " \
-                  "the zone number to show and seperate the values with " \
+                  "the zone number to show and separate the values with " \
                   ", or ; and use -1 to not use some channels. For the " \
                   "classic AtmoLight the sequence 4,3,1,0,2 would set the " \
                   "default channel/zone mapping. " \
@@ -382,7 +383,7 @@ add_string(CFG_PREFIX "serialdev", "COM1", NULL,
 add_file(CFG_PREFIX "atmowinexe", NULL, NULL,
          ATMOWINEXE_TEXT, ATMOWINEXE_LONGTEXT, false )
 #else
-add_string(CFG_PREFIX "serialdev", "/dev/ttyS01", NULL,
+add_string(CFG_PREFIX "serialdev", "/dev/ttyUSB0", NULL,
            SERIALDEV_TEXT, SERIALDEV_LONGTEXT, false )
 #endif
 
@@ -427,6 +428,13 @@ set_section( N_("MoMoLight options" ), 0 )
 add_integer_with_range(CFG_PREFIX "momo-channels",   3, 3, 4, NULL,
                        MOMO_CHANNELS_TEXT, MOMO_CHANNELS_LONGTEXT, false)
 
+/* 2,2,4 means 2 is the default value, 1 minimum amount,
+   4 maximum amount
+*/
+set_section( N_("fnordlicht options" ), 0 )
+add_integer_with_range(CFG_PREFIX "fnordlicht-amount",   2, 1, 4, NULL,
+                       FNORDLICHT_AMOUNT_TEXT,
+                       FNORDLICHT_AMOUNT_LONGTEXT, false)
 
 
 /*
@@ -658,6 +666,7 @@ static const char *const ppsz_filter_options[] = {
         "dmx-channels",
         "dmx-chbase",
         "momo-channels",
+        "fnordlicht-amount",
 
 #if defined(WIN32 )
         "atmowinexe",
@@ -1529,6 +1538,14 @@ static void Atmo_SetupConfig(filter_t *p_filter, CAtmoConfig *p_atmo_config)
     p_atmo_config->setMoMo_Channels(
         var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "momo-channels")
        );
+
+    /*
+      fnordlicht options
+    */
+    p_atmo_config->setFnordlicht_Amount(
+        var_CreateGetIntegerCommand( p_filter, CFG_PREFIX "fnordlicht-amount")
+       );
+
 }
 
 
@@ -1609,55 +1626,64 @@ static void Atmo_SetupParameters(filter_t *p_filter)
 
             /* importing all required functions I hope*/
             p_sys->pf_ctrl_atmo_initialize =
-                (int32_t (*)(void))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoInitialize");
+                (int32_t (*)(void))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoInitialize");
             if(!p_sys->pf_ctrl_atmo_initialize)
                 msg_Err( p_filter, "export AtmoInitialize missing.");
 
             p_sys->pf_ctrl_atmo_finalize =
-                (void (*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoFinalize");
+                (void (*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoFinalize");
             if(!p_sys->pf_ctrl_atmo_finalize)
                 msg_Err( p_filter, "export AtmoFinalize missing.");
 
             p_sys->pf_ctrl_atmo_switch_effect =
-                (int32_t(*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoSwitchEffect");
+                (int32_t(*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoSwitchEffect");
             if(!p_sys->pf_ctrl_atmo_switch_effect)
                 msg_Err( p_filter, "export AtmoSwitchEffect missing.");
 
             p_sys->pf_ctrl_atmo_set_live_source =
-                (int32_t(*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoSetLiveSource");
+                (int32_t(*)(int32_t))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoSetLiveSource");
             if(!p_sys->pf_ctrl_atmo_set_live_source)
                 msg_Err( p_filter, "export AtmoSetLiveSource missing.");
 
             p_sys->pf_ctrl_atmo_create_transfer_buffers =
-                (void (*)(int32_t, int32_t, int32_t , int32_t))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoCreateTransferBuffers");
+                (void (*)(int32_t, int32_t, int32_t , int32_t))
+                    GetProcAddress(p_sys->h_AtmoCtrl,"AtmoCreateTransferBuffers");
             if(!p_sys->pf_ctrl_atmo_create_transfer_buffers)
                 msg_Err( p_filter, "export AtmoCreateTransferBuffers missing.");
 
             p_sys->pf_ctrl_atmo_lock_transfer_buffer=
-                (uint8_t*(*) (void))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoLockTransferBuffer");
+                (uint8_t*(*) (void))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoLockTransferBuffer");
             if(!p_sys->pf_ctrl_atmo_lock_transfer_buffer)
                 msg_Err( p_filter, "export AtmoLockTransferBuffer missing.");
 
             p_sys->pf_ctrl_atmo_send_pixel_data =
-                (void (*)(void))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoSendPixelData");
+                (void (*)(void))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoSendPixelData");
             if(!p_sys->pf_ctrl_atmo_send_pixel_data)
                 msg_Err( p_filter, "export AtmoSendPixelData missing.");
 
             p_sys->pf_ctrl_atmo_get_image_size =
-                (void (*)(int32_t*,int32_t*))GetProcAddress(p_sys->h_AtmoCtrl,"AtmoWinGetImageSize");
+                (void (*)(int32_t*,int32_t*))GetProcAddress(p_sys->h_AtmoCtrl,
+                            "AtmoWinGetImageSize");
             if(!p_sys->pf_ctrl_atmo_get_image_size)
                 msg_Err( p_filter, "export AtmoWinGetImageSize missing.");
 
         } else {
             /* the DLL is missing try internal filter ...*/
-            msg_Warn( p_filter, "AtmoCtrlLib.dll missing fallback to internal atmo classic driver");
+            msg_Warn( p_filter,
+                "AtmoCtrlLib.dll missing fallback to internal atmo classic driver");
             p_sys->i_device_type = 1;
         }
     }
 #endif
 
     if(p_sys->i_device_type >= 1) {
-        msg_Dbg( p_filter, "try use buildin driver %d ", p_sys->i_device_type );
+        msg_Dbg( p_filter, "try use buildin driver %d ", p_sys->i_device_type);
         /*
         now we have to read a lof of options from the config dialog
         most important the serial device if not set ... we can skip
@@ -1690,6 +1716,10 @@ static void Atmo_SetupParameters(filter_t *p_filter)
                 p_sys->p_atmo_config->setConnectionType( actMoMoLight );
                 break;
 
+            case 5:
+                p_sys->p_atmo_config->setConnectionType( actFnordlicht );
+                break;
+
             default:
                 msg_Warn( p_filter, "invalid device type %d found",
                                     p_sys->i_device_type );
@@ -1711,16 +1741,6 @@ static void Atmo_SetupParameters(filter_t *p_filter)
         p_sys->pf_extract_mini_image = NULL;
     }
 
-    p_sys->i_crop_x_offset  = 0;
-    p_sys->i_crop_y_offset  = 0;
-    p_sys->i_crop_width     = p_filter->fmt_in.video.i_visible_width;
-    p_sys->i_crop_height    = p_filter->fmt_in.video.i_visible_height;
-
-    msg_Dbg( p_filter, "set default crop %d,%d %dx%d",p_sys->i_crop_x_offset,
-        p_sys->i_crop_y_offset,
-        p_sys->i_crop_width,
-        p_sys->i_crop_height );
-
     /*
     for debugging purpose show the samplinggrid on each frame as
     white dots
@@ -1922,8 +1942,6 @@ static int CreateFilter( vlc_object_t *p_this )
 
     AddStateVariableCallback(p_filter);
 
-    AddCropVariableCallback(p_filter);
-
     AddAtmoSettingsVariablesCallbacks(p_filter);
 
     Atmo_SetupParameters(p_filter);
@@ -1948,7 +1966,7 @@ static void DestroyFilter( vlc_object_t *p_this )
     msg_Dbg( p_filter, "Destroy Atmo Filter");
 
     DelStateVariableCallback(p_filter);
-    DelCropVariableCallback(p_filter);
+
     DelAtmoSettingsVariablesCallbacks(p_filter);
 
     Atmo_Shutdown(p_filter);
@@ -2245,7 +2263,8 @@ static void CreateMiniImage( filter_t *p_filter, picture_t *p_inpic)
         }
     }
 
-    msg_Dbg( p_filter, "AtmoFrame %u Time: %d ms", p_sys->ui_frame_counter, mdate() / 1000);
+    msg_Dbg( p_filter, "AtmoFrame %u Time: %d ms", p_sys->ui_frame_counter,
+                mdate() / 1000);
     p_sys->ui_frame_counter++;
 #endif
 
@@ -2276,6 +2295,11 @@ static picture_t * Filter( filter_t *p_filter, picture_t *p_pic )
         (p_sys->pf_extract_mini_image != NULL) &&
         (p_sys->b_pause_live == false))
     {
+        p_sys->i_crop_x_offset  = p_filter->fmt_in.video.i_x_offset;
+        p_sys->i_crop_y_offset  = p_filter->fmt_in.video.i_y_offset;
+        p_sys->i_crop_width     = p_filter->fmt_in.video.i_visible_width;
+        p_sys->i_crop_height    = p_filter->fmt_in.video.i_visible_height;
+
         CreateMiniImage(p_filter, p_pic);
     }
 
@@ -2516,71 +2540,6 @@ static void DelStateVariableCallback( filter_t *p_filter )
     }
 }
 
-
-static int CropCallback(vlc_object_t *p_this, char const *psz_cmd,
-                        vlc_value_t oldval, vlc_value_t newval,
-                        void *p_data)
-{
-    vout_thread_t *p_vout = (vout_thread_t *)p_this;
-    filter_t *p_filter = (filter_t *)p_data;
-    filter_sys_t *p_sys = (filter_sys_t *)p_filter->p_sys;
-
-    /*
-    //if the handler is attache to crop variable directly!
-    int i_visible_width, i_visible_height, i_x_offset, i_y_offset;
-    atmo_parse_crop(newval.psz_string, p_vout->fmt_render,
-    p_vout->fmt_render,
-    i_visible_width, i_visible_height,
-    i_x_offset, i_y_offset);
-    p_sys->i_crop_x_offset  = i_x_offset;
-    p_sys->i_crop_y_offset  = i_y_offset;
-    p_sys->i_crop_width     = i_visible_width;
-    p_sys->i_crop_height    = i_visible_height;
-    */
-
-    p_sys->i_crop_x_offset  = p_vout->fmt_in.i_x_offset;
-    p_sys->i_crop_y_offset  = p_vout->fmt_in.i_y_offset;
-    p_sys->i_crop_width     = p_vout->fmt_in.i_visible_width;
-    p_sys->i_crop_height    = p_vout->fmt_in.i_visible_height;
-
-    msg_Dbg(p_filter, "cropping picture %ix%i to %i,%i,%ix%i",
-        p_vout->fmt_in.i_width,
-        p_vout->fmt_in.i_height,
-        p_sys->i_crop_x_offset,
-        p_sys->i_crop_y_offset,
-        p_sys->i_crop_width,
-        p_sys->i_crop_height
-        );
-
-    return VLC_SUCCESS;
-}
-
-
-static void AddCropVariableCallback( filter_t *p_filter)
-{
-    vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find( p_filter,
-        VLC_OBJECT_VOUT,
-        FIND_ANYWHERE );
-    if( p_vout )
-    {
-        var_AddCallback( p_vout, "crop-update", CropCallback, p_filter );
-        vlc_object_release( p_vout );
-    }
-}
-
-static void DelCropVariableCallback( filter_t *p_filter)
-{
-    vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find( p_filter,
-        VLC_OBJECT_VOUT,
-        FIND_ANYWHERE );
-    if( p_vout )
-    {
-        var_DelCallback( p_vout, "crop-update", CropCallback, p_filter );
-        vlc_object_release( p_vout );
-    }
-}
-
-
 /****************************************************************************
 * StateCallback: Callback for the inputs variable "State" to get notified
 * about Pause and Continue Playback events.
@@ -2840,10 +2799,14 @@ static void atmo_parse_crop(char *psz_cropconfig,
             i_crop_bottom = strtol( psz_end, &psz_end, 10 );
             if( *psz_end != '\0' ) return;
 
-            i_width = fmt_render.i_visible_width - i_crop_left - i_crop_right;
+            i_width = fmt_render.i_visible_width -
+                        i_crop_left -
+                        i_crop_right;
             i_visible_width = i_width;
 
-            i_height = fmt_render.i_visible_height - i_crop_top - i_crop_bottom;
+            i_height = fmt_render.i_visible_height -
+                        i_crop_top -
+                        i_crop_bottom;
             i_visible_height = i_height;
 
             i_x_offset = i_crop_left;