* test4.c : Miscellaneous stress tests module for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: test4.c,v 1.3 2002/10/17 13:15:30 sam Exp $
+ * $Id: test4.c,v 1.7 2003/05/04 22:42:17 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
-static int Callback ( vlc_object_t *, char *, char * );
+static int Foo ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+static int Callback ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
static int MyCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
static void * MyThread ( vlc_object_t * );
-static int Stress ( vlc_object_t *, char *, char * );
+static int Stress ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
static void * Dummy ( vlc_object_t * );
-static int Signal ( vlc_object_t *, char *, char * );
+static int Signal ( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* Module descriptor.
*****************************************************************************/
vlc_module_begin();
set_description( _("Miscellaneous stress tests") );
- var_Create( p_module->p_libvlc, "callback-test", VLC_VAR_COMMAND );
- var_Set( p_module->p_libvlc, "callback-test", (vlc_value_t)(void*)Callback );
- var_Create( p_module->p_libvlc, "stress-test", VLC_VAR_COMMAND );
- var_Set( p_module->p_libvlc, "stress-test", (vlc_value_t)(void*)Stress );
- var_Create( p_module->p_libvlc, "signal", VLC_VAR_COMMAND );
- var_Set( p_module->p_libvlc, "signal", (vlc_value_t)(void*)Signal );
+ var_Create( p_module->p_libvlc, "foo-test",
+ VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
+ var_AddCallback( p_module->p_libvlc, "foo-test", Foo, NULL );
+ var_Create( p_module->p_libvlc, "callback-test",
+ VLC_VAR_VOID | VLC_VAR_ISCOMMAND );
+ var_AddCallback( p_module->p_libvlc, "callback-test", Callback, NULL );
+ var_Create( p_module->p_libvlc, "stress-test",
+ VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
+ var_AddCallback( p_module->p_libvlc, "stress-test", Stress, NULL );
+ 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();
+/*****************************************************************************
+ * Foo: put anything here
+ *****************************************************************************/
+static int Foo( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
+{
+ vlc_value_t val;
+ int i;
+
+ var_Create( p_this, "honk", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
+
+ val.psz_string = "foo";
+ var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL );
+ val.psz_string = "bar";
+ var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL );
+ val.psz_string = "baz";
+ var_Change( p_this, "honk", VLC_VAR_ADDCHOICE, &val, NULL );
+ var_Change( p_this, "honk", VLC_VAR_SETDEFAULT, &val, NULL );
+
+ var_Get( p_this, "honk", &val ); printf( "value: %s\n", 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 );
+
+ val.psz_string = "blork";
+ var_Set( p_this, "honk", val );
+
+ var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string );
+
+ val.psz_string = "baz";
+ var_Change( p_this, "honk", VLC_VAR_DELCHOICE, &val, NULL );
+
+ var_Get( p_this, "honk", &val ); printf( "value: %s\n", val.psz_string );
+
+ var_Change( p_this, "honk", VLC_VAR_GETLIST, &val, NULL );
+ for( i = 0 ; i < val.p_list->i_count ; i++ )
+ {
+ printf( "value %i: %s\n", i, val.p_list->p_values[i].psz_string );
+ }
+ var_Change( p_this, "honk", VLC_VAR_FREELIST, &val, NULL );
+
+ var_Destroy( p_this, "honk" );
+
+ return VLC_SUCCESS;
+}
+
/*****************************************************************************
* Callback: test callback functions
*****************************************************************************/
-static int Callback( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+static int Callback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
int i;
char psz_var[20];
/*****************************************************************************
* Stress: perform various stress tests
*****************************************************************************/
-static int Stress( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+static int Stress( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
vlc_object_t **pp_objects;
mtime_t start;
char * psz_blob;
int i, i_level;
- if( *psz_arg )
+ if( *newval.psz_string )
{
- i_level = atoi( psz_arg );
+ i_level = atoi( newval.psz_string );
if( i_level <= 0 )
{
i_level = 1;
{
int id = (int) (MAXOBJ * i_level * 1.0 * rand() / (RAND_MAX));
vlc_object_get( p_this, pp_objects[id]->i_object_id );
+ vlc_object_release( p_this );
}
printf( " - destroying the objects (LIFO)\n" );
/*****************************************************************************
* Signal: send a signal to the current thread.
*****************************************************************************/
-static int Signal( vlc_object_t *p_this, char *psz_cmd, char *psz_arg )
+static int Signal( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval, void *p_data )
{
- raise( atoi(psz_arg) );
+ raise( atoi(newval.psz_string) );
return VLC_SUCCESS;
}
-