Commit 7720f981 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove vlc_object_find_name() search mode parameter

parent 9747349a
...@@ -40,10 +40,6 @@ ...@@ -40,10 +40,6 @@
/* Please do not add new object types anyway */ /* Please do not add new object types anyway */
#define VLC_OBJECT_GENERIC (-666) #define VLC_OBJECT_GENERIC (-666)
/* Object search mode */
#define FIND_CHILD 0x0002
#define FIND_ANYWHERE 0x0003
/* Object flags */ /* Object flags */
#define OBJECT_FLAGS_NODBG 0x0001 #define OBJECT_FLAGS_NODBG 0x0001
#define OBJECT_FLAGS_QUIET 0x0002 #define OBJECT_FLAGS_QUIET 0x0002
...@@ -62,7 +58,7 @@ struct vlc_object_t ...@@ -62,7 +58,7 @@ struct vlc_object_t
* Prototypes * Prototypes
*****************************************************************************/ *****************************************************************************/
VLC_API void *vlc_object_create( vlc_object_t *, size_t ) VLC_MALLOC VLC_USED; VLC_API void *vlc_object_create( vlc_object_t *, size_t ) VLC_MALLOC VLC_USED;
VLC_API vlc_object_t *vlc_object_find_name( vlc_object_t *, const char *, int ) VLC_USED VLC_DEPRECATED; VLC_API vlc_object_t *vlc_object_find_name( vlc_object_t *, const char * ) VLC_USED VLC_DEPRECATED;
VLC_API void * vlc_object_hold( vlc_object_t * ); VLC_API void * vlc_object_hold( vlc_object_t * );
VLC_API void vlc_object_release( vlc_object_t * ); VLC_API void vlc_object_release( vlc_object_t * );
VLC_API vlc_list_t *vlc_list_children( vlc_object_t * ) VLC_USED; VLC_API vlc_list_t *vlc_list_children( vlc_object_t * ) VLC_USED;
...@@ -74,8 +70,8 @@ VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED; ...@@ -74,8 +70,8 @@ VLC_API char *vlc_object_get_name( const vlc_object_t * ) VLC_USED;
#define vlc_object_create(a,b) vlc_object_create( VLC_OBJECT(a), b ) #define vlc_object_create(a,b) vlc_object_create( VLC_OBJECT(a), b )
#define vlc_object_find_name(a,b,c) \ #define vlc_object_find_name(a,b) \
vlc_object_find_name( VLC_OBJECT(a),b,c) vlc_object_find_name( VLC_OBJECT(a),b)
#define vlc_object_hold(a) \ #define vlc_object_hold(a) \
vlc_object_hold( VLC_OBJECT(a) ) vlc_object_hold( VLC_OBJECT(a) )
......
...@@ -206,7 +206,7 @@ static void RunIntf( intf_thread_t *p_intf ) ...@@ -206,7 +206,7 @@ static void RunIntf( intf_thread_t *p_intf )
{ {
/* TODO: cache object pointer */ /* TODO: cache object pointer */
vlc_object_t *p_obj = vlc_object_t *p_obj =
vlc_object_find_name( p_intf->p_libvlc, "rotate", FIND_CHILD ); vlc_object_find_name( p_intf->p_libvlc, "rotate" );
if( p_obj ) if( p_obj )
{ {
var_SetInteger( p_obj, "rotate-deciangle", var_SetInteger( p_obj, "rotate-deciangle",
......
...@@ -481,8 +481,7 @@ ...@@ -481,8 +481,7 @@
- (IBAction)telxTransparent:(id)sender - (IBAction)telxTransparent:(id)sender
{ {
vlc_object_t *p_vbi; vlc_object_t *p_vbi;
p_vbi = (vlc_object_t *) vlc_object_find_name( pl_Get( VLCIntf ), p_vbi = (vlc_object_t *) vlc_object_find_name( pl_Get( VLCIntf ), "zvbi" );
"zvbi", FIND_CHILD );
if( p_vbi ) if( p_vbi )
{ {
var_SetBool( p_vbi, "vbi-opaque", [sender state] ); var_SetBool( p_vbi, "vbi-opaque", [sender state] );
...@@ -509,8 +508,7 @@ ...@@ -509,8 +508,7 @@
i_page = 'b' << 16; i_page = 'b' << 16;
if( i_page == 0 ) return; if( i_page == 0 ) return;
p_vbi = (vlc_object_t *) vlc_object_find_name( pl_Get( VLCIntf ), p_vbi = (vlc_object_t *) vlc_object_find_name( pl_Get( VLCIntf ), "zvbi" );
"zvbi", FIND_CHILD );
if( p_vbi ) if( p_vbi )
{ {
var_SetInteger( p_vbi, "vbi-page", i_page ); var_SetInteger( p_vbi, "vbi-page", i_page );
......
...@@ -352,7 +352,7 @@ static VLCExtended *_o_sharedInstance = nil; ...@@ -352,7 +352,7 @@ static VLCExtended *_o_sharedInstance = nil;
else else
{ {
msg_Dbg( p_intf, "we found a vout to adjust, let's look for the filter" ); msg_Dbg( p_intf, "we found a vout to adjust, let's look for the filter" );
p_filter = vlc_object_find_name( pl_Get(p_intf), "adjust", FIND_CHILD ); p_filter = vlc_object_find_name( pl_Get(p_intf), "adjust" );
if(! p_filter ) if(! p_filter )
{ {
......
...@@ -109,8 +109,7 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) : ...@@ -109,8 +109,7 @@ ExtVideo::ExtVideo( intf_thread_t *_p_intf, QTabWidget *_parent ) :
{ \ { \
vlc_object_t *p_obj = ( vlc_object_t * ) \ vlc_object_t *p_obj = ( vlc_object_t * ) \
vlc_object_find_name( p_intf->p_libvlc, \ vlc_object_find_name( p_intf->p_libvlc, \
#widget, \ #widget ); \
FIND_CHILD ); \
QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \ QCheckBox *checkbox = qobject_cast<QCheckBox*>( ui.widget##Enable ); \
QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \ QGroupBox *groupbox = qobject_cast<QGroupBox*>( ui.widget##Enable ); \
if( p_obj ) \ if( p_obj ) \
...@@ -456,9 +455,7 @@ void ExtVideo::setWidgetValue( QObject *widget ) ...@@ -456,9 +455,7 @@ void ExtVideo::setWidgetValue( QObject *widget )
//std::cout << "Option name: " << option.toStdString() << std::endl; //std::cout << "Option name: " << option.toStdString() << std::endl;
vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_t *p_obj = ( vlc_object_t * )
vlc_object_find_name( p_intf->p_libvlc, vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
qtu( module ),
FIND_CHILD );
int i_type; int i_type;
vlc_value_t val; vlc_value_t val;
...@@ -549,9 +546,7 @@ void ExtVideo::updateFilterOptions() ...@@ -549,9 +546,7 @@ void ExtVideo::updateFilterOptions()
//std::cout << "Option name: " << option.toStdString() << std::endl; //std::cout << "Option name: " << option.toStdString() << std::endl;
vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_t *p_obj = ( vlc_object_t * )
vlc_object_find_name( p_intf->p_libvlc, vlc_object_find_name( p_intf->p_libvlc, qtu( module ) );
qtu( module ),
FIND_CHILD );
int i_type; int i_type;
bool b_is_command; bool b_is_command;
if( !p_obj ) if( !p_obj )
...@@ -686,7 +681,7 @@ void ExtV4l2::showEvent( QShowEvent *event ) ...@@ -686,7 +681,7 @@ void ExtV4l2::showEvent( QShowEvent *event )
void ExtV4l2::Refresh( void ) void ExtV4l2::Refresh( void )
{ {
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2", FIND_CHILD ); vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
help->hide(); help->hide();
if( box ) if( box )
{ {
...@@ -830,7 +825,7 @@ void ExtV4l2::ValueChange( bool value ) ...@@ -830,7 +825,7 @@ void ExtV4l2::ValueChange( bool value )
void ExtV4l2::ValueChange( int value ) void ExtV4l2::ValueChange( int value )
{ {
QObject *s = sender(); QObject *s = sender();
vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2", FIND_CHILD ); vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
if( p_obj ) if( p_obj )
{ {
char *psz_var = strdup( qtu( s->objectName() ) ); char *psz_var = strdup( qtu( s->objectName() ) );
...@@ -1734,7 +1729,7 @@ void SyncControls::subsdelaySetFactor( double f_factor ) ...@@ -1734,7 +1729,7 @@ void SyncControls::subsdelaySetFactor( double f_factor )
config_PutFloat( p_intf, SUBSDELAY_CFG_FACTOR, f_factor ); config_PutFloat( p_intf, SUBSDELAY_CFG_FACTOR, f_factor );
/* Try to find an instance of subsdelay, and set its factor */ /* Try to find an instance of subsdelay, and set its factor */
vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_find_name( p_intf->p_libvlc, "subsdelay", FIND_CHILD ); vlc_object_t *p_obj = ( vlc_object_t * ) vlc_object_find_name( p_intf->p_libvlc, "subsdelay" );
if( p_obj ) if( p_obj )
{ {
var_SetFloat( p_obj, SUBSDELAY_CFG_FACTOR, f_factor ); var_SetFloat( p_obj, SUBSDELAY_CFG_FACTOR, f_factor );
......
...@@ -474,8 +474,7 @@ void PLSelector::podcastAdd( PLSelItem * ) ...@@ -474,8 +474,7 @@ void PLSelector::podcastAdd( PLSelItem * )
setSource( podcastsParent ); //to load the SD in case it's not loaded setSource( podcastsParent ); //to load the SD in case it's not loaded
vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name( vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name( p_intf->p_libvlc, "podcast" );
p_intf->p_libvlc, "podcast", FIND_CHILD );
if( !p_obj ) return; if( !p_obj ) return;
QString request("ADD:"); QString request("ADD:");
...@@ -498,7 +497,7 @@ void PLSelector::podcastRemove( PLSelItem* item ) ...@@ -498,7 +497,7 @@ void PLSelector::podcastRemove( PLSelItem* item )
if( !input ) return; if( !input ) return;
vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name( vlc_object_t *p_obj = (vlc_object_t*) vlc_object_find_name(
p_intf->p_libvlc, "podcast", FIND_CHILD ); p_intf->p_libvlc, "podcast" );
if( !p_obj ) return; if( !p_obj ) return;
QString request("RM:"); QString request("RM:");
......
...@@ -72,8 +72,7 @@ void PodcastConfigDialog::accept() ...@@ -72,8 +72,7 @@ void PodcastConfigDialog::accept()
} }
config_PutPsz( p_intf, "podcast-urls", qtu( urls ) ); config_PutPsz( p_intf, "podcast-urls", qtu( urls ) );
vlc_object_t *p_obj = (vlc_object_t*) vlc_object_t *p_obj = (vlc_object_t*)
vlc_object_find_name( p_intf->p_libvlc, vlc_object_find_name( p_intf->p_libvlc, "podcast" );
"podcast", FIND_CHILD );
if( p_obj ) if( p_obj )
{ {
var_SetString( p_obj, "podcast-urls", qtu( urls ) ); var_SetString( p_obj, "podcast-urls", qtu( urls ) );
......
...@@ -609,7 +609,7 @@ static vlc_object_t *get_object( libvlc_media_player_t * p_mi, ...@@ -609,7 +609,7 @@ static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
if( vout ) if( vout )
{ {
object = vlc_object_find_name( vout, name, FIND_CHILD ); object = vlc_object_find_name( vout, name );
vlc_object_release(vout); vlc_object_release(vout);
} }
else else
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
static int DumpCommand( vlc_object_t *, char const *, static int DumpCommand( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static vlc_object_t * FindChildName ( vlc_object_internals_t *, const char * ); static vlc_object_t * FindName ( vlc_object_internals_t *, const char * );
static void PrintObject( vlc_object_internals_t *, const char * ); static void PrintObject( vlc_object_internals_t *, const char * );
static void DumpStructure( vlc_object_internals_t *, unsigned, char * ); static void DumpStructure( vlc_object_internals_t *, unsigned, char * );
...@@ -426,35 +426,21 @@ static int objnamecmp(const vlc_object_t *obj, const char *name) ...@@ -426,35 +426,21 @@ static int objnamecmp(const vlc_object_t *obj, const char *name)
* *
* @param p_this object to search from * @param p_this object to search from
* @param psz_name name of the object to search for * @param psz_name name of the object to search for
* @param i_mode search direction: FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
* *
* @return a matching object (must be released by the caller), * @return a matching object (must be released by the caller),
* or NULL on error. * or NULL on error.
*/ */
vlc_object_t *vlc_object_find_name( vlc_object_t *p_this, vlc_object_t *vlc_object_find_name( vlc_object_t *p_this, const char *psz_name )
const char *psz_name, int i_mode )
{ {
vlc_object_t *p_found; vlc_object_t *p_found;
/* Reading psz_object_name from a separate inhibits thread-safety. /* Reading psz_object_name from a separate inhibits thread-safety.
* Use a libvlc address variable instead for that sort of things! */ * Use a libvlc address variable instead for that sort of things! */
msg_Warn( p_this, "%s(%s) is not safe!", __func__, psz_name ); msg_Err( p_this, "%s(\"%s\") is not safe!", __func__, psz_name );
/* If have the requested name ourselves, don't look further */
if( !objnamecmp(p_this, psz_name) )
{
vlc_object_hold( p_this );
return p_this;
}
/* Otherwise, recursively look for the object */
if (i_mode == FIND_ANYWHERE)
return vlc_object_find_name (VLC_OBJECT(p_this->p_libvlc), psz_name,
FIND_CHILD);
assert (i_mode == FIND_CHILD);
libvlc_lock (p_this->p_libvlc); libvlc_lock (p_this->p_libvlc);
vlc_mutex_lock (&name_lock); vlc_mutex_lock (&name_lock);
p_found = FindChildName (vlc_internals (p_this), psz_name); p_found = FindName (vlc_internals (p_this), psz_name);
vlc_mutex_unlock (&name_lock); vlc_mutex_unlock (&name_lock);
libvlc_unlock (p_this->p_libvlc); libvlc_unlock (p_this->p_libvlc);
return p_found; return p_found;
...@@ -512,7 +498,7 @@ void vlc_object_release( vlc_object_t *p_this ) ...@@ -512,7 +498,7 @@ void vlc_object_release( vlc_object_t *p_this )
if( b_should_destroy ) if( b_should_destroy )
{ {
/* Detach from parent to protect against FIND_CHILDREN */ /* Detach from parent to protect against vlc_object_find_name() */
parent = p_this->p_parent; parent = p_this->p_parent;
if (likely(parent)) if (likely(parent))
{ {
...@@ -654,7 +640,7 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd, ...@@ -654,7 +640,7 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
if( *newval.psz_string ) if( *newval.psz_string )
{ {
/* try using the object's name to find it */ /* try using the object's name to find it */
p_object = vlc_object_find_name( p_data, newval.psz_string, FIND_CHILD ); p_object = vlc_object_find_name( p_data, newval.psz_string );
if( !p_object ) if( !p_object )
return VLC_ENOOBJ; return VLC_ENOOBJ;
} }
...@@ -713,15 +699,14 @@ void vlc_list_release( vlc_list_t *p_list ) ...@@ -713,15 +699,14 @@ void vlc_list_release( vlc_list_t *p_list )
/* Following functions are local */ /* Following functions are local */
static vlc_object_t *FindChildName (vlc_object_internals_t *priv, static vlc_object_t *FindName (vlc_object_internals_t *priv, const char *name)
const char *name)
{ {
for (priv = priv->first; priv != NULL; priv = priv->next) if (priv->psz_name != NULL && !strcmp (priv->psz_name, name))
{
if (priv->psz_name && !strcmp (priv->psz_name, name))
return vlc_object_hold (vlc_externals (priv)); return vlc_object_hold (vlc_externals (priv));
vlc_object_t *found = FindChildName (priv, name); for (priv = priv->first; priv != NULL; priv = priv->next)
{
vlc_object_t *found = FindName (priv, name);
if (found != NULL) if (found != NULL)
return found; return found;
} }
......
...@@ -1373,7 +1373,7 @@ int var_Command( vlc_object_t *p_this, const char *psz_name, ...@@ -1373,7 +1373,7 @@ int var_Command( vlc_object_t *p_this, const char *psz_name,
const char *psz_cmd, const char *psz_arg, char **psz_msg ) const char *psz_cmd, const char *psz_arg, char **psz_msg )
{ {
vlc_object_t *p_obj = vlc_object_find_name( p_this->p_libvlc, vlc_object_t *p_obj = vlc_object_find_name( p_this->p_libvlc,
psz_name, FIND_CHILD ); psz_name );
int i_type, i_ret; int i_type, i_ret;
if( !p_obj ) if( !p_obj )
......
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