]> git.sesse.net Git - vlc/blobdiff - modules/misc/testsuite/test4.c
XCB: use dummy color map so selecting a non-default visual works
[vlc] / modules / misc / testsuite / test4.c
index 512e091822d12691b5295d3301d5dcdcc13c85a7..a7280a5f286b620a16a699d1e3b61df70cbb8e26 100644 (file)
@@ -28,7 +28,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 
 #include <signal.h>
 
@@ -62,8 +63,8 @@ static int    Signal    ( vlc_object_t *, char const *,
 /*****************************************************************************
  * Module descriptor.
  *****************************************************************************/
-vlc_module_begin();
-    set_description( _("Miscellaneous stress tests") );
+vlc_module_begin ()
+    set_description( N_("Miscellaneous stress tests") )
     var_Create( p_module->p_libvlc, "foo-test",
                 VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
     var_AddCallback( p_module->p_libvlc, "foo-test", Foo, NULL );
@@ -76,7 +77,7 @@ vlc_module_begin();
     var_Create( p_module->p_libvlc, "signal",
                 VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
     var_AddCallback( p_module->p_libvlc, "signal", Signal, NULL );
-vlc_module_end();
+vlc_module_end ()
 
 /*****************************************************************************
  * Foo: put anything here
@@ -98,16 +99,19 @@ static int Foo( vlc_object_t *p_this, char const *psz_cmd,
     var_Change( p_this, "honk", VLC_VAR_SETDEFAULT, &val, NULL );
 
     var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string );
+    free( val.psz_string );
 
     val.psz_string = "foo";
     var_Set( p_this, "honk", val );
 
     var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string );
+    free( val.psz_string );
 
     val.psz_string = "blork";
     var_Set( p_this, "honk", val );
 
     var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string );
+    free( val.psz_string );
 
     val.psz_string = "baz";
     var_Change( p_this, "honk", VLC_VAR_DELCHOICE, &val, NULL );
@@ -167,7 +171,7 @@ static int Callback( vlc_object_t *p_this, char const *psz_cmd,
 
     for( i = 0; i < 10; i++ )
     {
-        pp_objects[i] = vlc_object_create( p_this, VLC_OBJECT_GENERIC );
+        pp_objects[i] = vlc_object_create( p_this, sizeof( vlc_object_t ) );
         vlc_object_attach( pp_objects[i], p_this );
         vlc_thread_create( pp_objects[i], "foo", MyThread, 0, true );
     }
@@ -235,13 +239,16 @@ static void * MyThread( vlc_object_t *p_this )
 
     val.i_int = 42;
 
-    while( !p_this->b_die )
+    while( vlc_object_alive (p_this) )
     {
         int i = (int) (100.0 * rand() / (RAND_MAX));
+        /* FIXME: not thread-safe */
 
         sprintf( psz_var, "blork-%i", i );
         val.i_int = i + 200;
+        int canc = vlc_savecancel ();
         var_Set( p_parent, psz_var, val );
+        vlc_restorecancel (canc);
 
         /* This is quite heavy, but we only have 10 threads. Keep cool. */
         msleep( 1000 );
@@ -282,7 +289,7 @@ static int Stress( vlc_object_t *p_this, char const *psz_cmd,
 
     /* Allocate required data */
     ppsz_name = malloc( MAXVAR * i_level * sizeof(char*) );
-    psz_blob = malloc( 20 * MAXVAR * i_level * sizeof(char) );
+    psz_blob = malloc( 20 * MAXVAR * i_level );
     for( i = 0; i < MAXVAR * i_level; i++ )
     {
         ppsz_name[i] = psz_blob + 20 * i;
@@ -299,7 +306,7 @@ static int Stress( vlc_object_t *p_this, char const *psz_cmd,
     start = mdate();
     for( i = 0; i < MAXOBJ * i_level; i++ )
     {
-        pp_objects[i] = vlc_object_create( p_this, VLC_OBJECT_GENERIC );
+        pp_objects[i] = vlc_object_create( p_this, sizeof( vlc_object_t ) );
     }
 
     printf( " - randomly looking up %i objects\n", MAXLOOK * i_level );
@@ -384,7 +391,7 @@ static int Stress( vlc_object_t *p_this, char const *psz_cmd,
             MAXTH * i_level, MAXOBJ/MAXTH );
     for( i = 0; i < MAXTH * i_level; i++ )
     {
-        pp_objects[i] = vlc_object_create( p_this, VLC_OBJECT_GENERIC );
+        pp_objects[i] = vlc_object_create( p_this, sizeof( vlc_object_t ) );
         vlc_thread_create( pp_objects[i], "foo", Dummy, 0, true );
     }
 
@@ -416,12 +423,12 @@ static void * Dummy( vlc_object_t *p_this )
 
     for( i = 0; i < MAXOBJ/MAXTH; i++ )
     {
-        pp_objects[i] = vlc_object_create( p_this, VLC_OBJECT_GENERIC );
+        pp_objects[i] = vlc_object_create( p_this, sizeof( vlc_object_t ) );
     }
 
     vlc_thread_ready( p_this );
 
-    while( !p_this->b_die )
+    while( vlc_object_alive (p_this) )
     {
         msleep( 10000 );
     }