Commit 93900cd7 authored by Jean-Paul Saman's avatar Jean-Paul Saman Committed by Jean-Paul Saman

libvlc: refactor sfilter enabling/disabling

Refactor sfilter enabling and disabling. One glitch stays present:
A user needs to call libvlc_{logo,marq,adjust}_int{ p_mi, libvlc_{logo,marq,adjust}_Enable, twice initially. Once before setting options to get module to load and second after setting options. After this Enabling/Disabling works as expected.
NOTE: when changing an option one MUST call
libvlc_{logo,marq,adjust}_int{ p_mi, libvlc_{logo,marq,adjust}_Enable, again.

The patch removes the dependency on the deprecated function vlc_object_find_name()
parent 7513dc81
...@@ -610,33 +610,32 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, ...@@ -610,33 +610,32 @@ void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
/* module helpers */ /* module helpers */
/* ************** */ /* ************** */
static bool find_sub_source_by_name( libvlc_media_player_t *p_mi, const char *restrict name )
static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
const char *name )
{ {
vlc_object_t *object;
vout_thread_t *vout = GetVout( p_mi, 0 ); vout_thread_t *vout = GetVout( p_mi, 0 );
if (!vout)
return false;
if( vout ) char *psz_sources = var_GetString( vout, "sub-source" );
if( !psz_sources )
{ {
object = vlc_object_find_name( vout, name ); libvlc_printerr( "%s not enabled", name );
vlc_object_release(vout); vlc_object_release( vout );
return false;
} }
else
object = NULL;
if( !object ) /* Find 'name' */
libvlc_printerr( "%s not enabled", name ); char *p = strstr( psz_sources, name );
return object; free( psz_sources );
vlc_object_release( vout );
return (p != NULL);
} }
typedef const struct { typedef const struct {
const char name[20]; const char name[20];
unsigned type; unsigned type;
} opt_t; } opt_t;
static void static void
set_int( libvlc_media_player_t *p_mi, const char *restrict name, set_int( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, int value ) const opt_t *restrict opt, int value )
...@@ -648,7 +647,9 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -648,7 +647,9 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name,
vout_thread_t *vout = GetVout( p_mi, 0 ); vout_thread_t *vout = GetVout( p_mi, 0 );
if (vout) if (vout)
{ {
/* Fill sub-source */
vout_EnableFilter( vout, opt->name, value, false ); vout_EnableFilter( vout, opt->name, value, false );
var_TriggerCallback( vout, "sub-source" );
vlc_object_release( vout ); vlc_object_release( vout );
} }
return; return;
...@@ -660,16 +661,9 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -660,16 +661,9 @@ set_int( libvlc_media_player_t *p_mi, const char *restrict name,
return; return;
} }
var_SetInteger(p_mi, opt->name, value); var_SetInteger( p_mi, opt->name, value );
vlc_object_t *object = get_object( p_mi, name );
if( object )
{
var_SetInteger(object, opt->name, value);
vlc_object_release( object );
}
} }
static int static int
get_int( libvlc_media_player_t *p_mi, const char *restrict name, get_int( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt ) const opt_t *restrict opt )
...@@ -680,9 +674,8 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -680,9 +674,8 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name,
{ {
case 0: /* the enabler */ case 0: /* the enabler */
{ {
vlc_object_t *object = get_object( p_mi, name ); bool b_enabled = find_sub_source_by_name( p_mi, name );
vlc_object_release( object ); return b_enabled ? 1 : 0;
return object != NULL;
} }
case VLC_VAR_INTEGER: case VLC_VAR_INTEGER:
return var_GetInteger(p_mi, opt->name); return var_GetInteger(p_mi, opt->name);
...@@ -692,7 +685,6 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -692,7 +685,6 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name,
} }
} }
static void static void
set_float( libvlc_media_player_t *p_mi, const char *restrict name, set_float( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, float value ) const opt_t *restrict opt, float value )
...@@ -706,23 +698,14 @@ set_float( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -706,23 +698,14 @@ set_float( libvlc_media_player_t *p_mi, const char *restrict name,
} }
var_SetFloat( p_mi, opt->name, value ); var_SetFloat( p_mi, opt->name, value );
vlc_object_t *object = get_object( p_mi, name );
if( object )
{
var_SetFloat(object, opt->name, value );
vlc_object_release( object );
}
} }
static float static float
get_float( libvlc_media_player_t *p_mi, const char *restrict name, get_float( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt ) const opt_t *restrict opt )
{ {
if( !opt ) return 0.0; if( !opt ) return 0.0;
if( opt->type != VLC_VAR_FLOAT ) if( opt->type != VLC_VAR_FLOAT )
{ {
libvlc_printerr( "Invalid argument to %s in %s", name, "get float" ); libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
...@@ -732,7 +715,6 @@ get_float( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -732,7 +715,6 @@ get_float( libvlc_media_player_t *p_mi, const char *restrict name,
return var_GetFloat( p_mi, opt->name ); return var_GetFloat( p_mi, opt->name );
} }
static void static void
set_string( libvlc_media_player_t *p_mi, const char *restrict name, set_string( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt, const char *restrict psz_value ) const opt_t *restrict opt, const char *restrict psz_value )
...@@ -746,16 +728,8 @@ set_string( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -746,16 +728,8 @@ set_string( libvlc_media_player_t *p_mi, const char *restrict name,
} }
var_SetString( p_mi, opt->name, psz_value ); var_SetString( p_mi, opt->name, psz_value );
vlc_object_t *object = get_object( p_mi, name );
if( object )
{
var_SetString(object, opt->name, psz_value );
vlc_object_release( object );
}
} }
static char * static char *
get_string( libvlc_media_player_t *p_mi, const char *restrict name, get_string( libvlc_media_player_t *p_mi, const char *restrict name,
const opt_t *restrict opt ) const opt_t *restrict opt )
...@@ -771,7 +745,6 @@ get_string( libvlc_media_player_t *p_mi, const char *restrict name, ...@@ -771,7 +745,6 @@ get_string( libvlc_media_player_t *p_mi, const char *restrict name,
return var_GetString( p_mi, opt->name ); return var_GetString( p_mi, opt->name );
} }
static const opt_t * static const opt_t *
marq_option_bynumber(unsigned option) marq_option_bynumber(unsigned option)
{ {
...@@ -796,8 +769,6 @@ marq_option_bynumber(unsigned option) ...@@ -796,8 +769,6 @@ marq_option_bynumber(unsigned option)
return r; return r;
} }
static vlc_object_t *get_object( libvlc_media_player_t *, const char *);
/***************************************************************************** /*****************************************************************************
* libvlc_video_get_marquee_int : get a marq option value * libvlc_video_get_marquee_int : get a marq option value
*****************************************************************************/ *****************************************************************************/
...@@ -837,7 +808,6 @@ void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi, ...@@ -837,7 +808,6 @@ void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
/* logo module support */ /* logo module support */
static const opt_t * static const opt_t *
logo_option_bynumber( unsigned option ) logo_option_bynumber( unsigned option )
{ {
...@@ -861,11 +831,10 @@ logo_option_bynumber( unsigned option ) ...@@ -861,11 +831,10 @@ logo_option_bynumber( unsigned option )
return r; return r;
} }
void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi, void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
unsigned option, const char *psz_value ) unsigned option, const char *psz_value )
{ {
set_string( p_mi,"logo",logo_option_bynumber(option),psz_value ); set_string( p_mi,"logo",logo_option_bynumber(option), psz_value );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment