VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
objects.c File Reference

This file contains the functions to handle the vlc_object_t type. More...

Include dependency graph for objects.c:

Macros

#define MYCASE(type, nice)

Functions

static int DumpCommand (vlc_object_t *, char const *, vlc_value_t, vlc_value_t, void *)
static vlc_object_tFindName (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 vlc_list_tNewList (int)
static void vlc_object_destroy (vlc_object_t *p_this)
 Destroys a VLC object once it has no more references.
static void libvlc_lock (libvlc_int_t *p_libvlc)
static void libvlc_unlock (libvlc_int_t *p_libvlc)
void * vlc_custom_create (((vlc_object_t *)(vlc_object_t *parent)), size_t length, const char *typename)
void * vlc_object_create (((vlc_object_t *)(vlc_object_t *p_this)), size_t i_size)
 Allocates and initializes a vlc object.
void vlc_object_set_destructor (((vlc_object_t *)(vlc_object_t *p_this)), vlc_destructor_t pf_destructor)
 Set the destructor of a vlc object.
int vlc_object_set_name (((vlc_object_t *)(vlc_object_t *obj)), const char *name)
char * vlc_object_get_name (((vlc_object_t *)(const vlc_object_t *obj)))
int vlc_object_waitpipe (vlc_object_t *obj)
 Returns the readable end of a pipe that becomes readable once termination of the object is requested (vlc_object_kill()).
void vlc_object_kill (((vlc_object_t *)(vlc_object_t *p_this)))
 Requests termination of an object, cancels the object thread, and make the object wait pipe (if it exists) readable.
vlc_object_tvlc_object_find_name (((vlc_object_t *)(vlc_object_t *p_this)), const char *psz_name)
 Finds a named object and increment its reference count.
void * vlc_object_hold (((vlc_object_t *)(vlc_object_t *p_this)))
 Increment an object reference counter.
void vlc_object_release (((vlc_object_t *)(vlc_object_t *p_this)))
 Drops a reference to an object (decrements the reference count).
bool vlc_object_alive (((vlc_object_t *)(vlc_object_t *obj)))
 This function returns true, except when it returns false.
vlc_list_tvlc_list_children (((vlc_object_t *)(vlc_object_t *obj)))
 Gets the list of children of an objects, and increment their reference count.
static void DumpVariable (const void *data, const VISIT which, const int depth)
void vlc_list_release (vlc_list_t *p_list)

Variables

static vlc_mutex_t name_lock = PTHREAD_MUTEX_INITIALIZER
static vlc_mutex_t pipe_lock = PTHREAD_MUTEX_INITIALIZER

Detailed Description

This file contains the functions to handle the vlc_object_t type.

Unless otherwise stated, functions in this file are not cancellation point. All functions in this file are safe w.r.t. deferred cancellation.

Macro Definition Documentation

#define MYCASE (   type,
  nice 
)
Value:
case VLC_VAR_ ## type: \
psz_type = nice; \
break;

Referenced by DumpVariable().

Function Documentation

static int DumpCommand ( vlc_object_t p_this,
char const *  psz_cmd,
vlc_value_t  oldval,
vlc_value_t  newval,
void *  p_data 
)
static
static void DumpStructure ( vlc_object_internals_t priv,
unsigned  i_level,
char *  psz_foo 
)
static
static void DumpVariable ( const void *  data,
const VISIT  which,
const int  depth 
)
static
static vlc_object_t * FindName ( vlc_object_internals_t priv,
const char *  name 
)
static
static void libvlc_lock ( libvlc_int_t p_libvlc)
static
static void libvlc_unlock ( libvlc_int_t p_libvlc)
static
static vlc_list_t * NewList ( int  i_count)
static
static void PrintObject ( vlc_object_internals_t priv,
const char *  psz_prefix 
)
static
void* vlc_custom_create ( ((vlc_object_t *)(vlc_object_t *parent))  ,
size_t  length,
const char *  typename 
)
vlc_list_t* vlc_list_children ( ((vlc_object_t *)(vlc_object_t *obj))  )

Gets the list of children of an objects, and increment their reference count.

Returns
a list (possibly empty) or NULL in case of error.

References count, libvlc_lock(), libvlc_unlock(), likely, NewList(), vlc_object_internals::next, vlc_object_t::p_libvlc, vlc_value_t::p_object, vlc_list_t::p_values, vlc_externals, vlc_internals, and vlc_object_hold.

bool vlc_object_alive ( ((vlc_object_t *)(vlc_object_t *obj))  )

This function returns true, except when it returns false.

Warning
Do not use this function. Ever. You were warned.

References vlc_object_internals::alive, and vlc_internals.

void* vlc_object_create ( ((vlc_object_t *)(vlc_object_t *p_this))  ,
size_t  i_size 
)

Allocates and initializes a vlc object.

Parameters
i_sizeobject byte size
Returns
the new object, or NULL on error.

References vlc_custom_create.

static void vlc_object_destroy ( vlc_object_t p_this)
static
vlc_object_t* vlc_object_find_name ( ((vlc_object_t *)(vlc_object_t *p_this))  ,
const char *  psz_name 
)

Finds a named object and increment its reference count.

Beware that objects found in this manner can be "owned" by another thread, be of any type, and be attached to any module (if any). With such an object reference, you can set or get object variables, emit log messages, and read write-once object parameters (psz_object_type, etc). You CANNOT cast the object to a more specific object type, and you definitely cannot invoke object type-specific callbacks with this.

Parameters
p_thisobject to search from
psz_namename of the object to search for
Returns
a matching object (must be released by the caller), or NULL on error.

References FindName(), libvlc_lock(), libvlc_unlock(), msg_Err, name_lock, vlc_object_t::p_libvlc, vlc_internals, vlc_mutex_lock(), and vlc_mutex_unlock().

char* vlc_object_get_name ( ((vlc_object_t *)(const vlc_object_t *obj))  )
void* vlc_object_hold ( ((vlc_object_t *)(vlc_object_t *p_this))  )

Increment an object reference counter.

References vlc_object_internals::refs, and vlc_internals.

void vlc_object_kill ( ((vlc_object_t *)(vlc_object_t *p_this))  )

Requests termination of an object, cancels the object thread, and make the object wait pipe (if it exists) readable.

Not a cancellation point.

References vlc_object_internals::alive, msg_Dbg, pipe_lock, vlc_object_internals::pipes, vlc_internals, vlc_mutex_lock(), vlc_mutex_unlock(), vlc_restorecancel(), and vlc_savecancel().

void vlc_object_release ( ((vlc_object_t *)(vlc_object_t *p_this))  )
void vlc_object_set_destructor ( ((vlc_object_t *)(vlc_object_t *p_this))  ,
vlc_destructor_t  pf_destructor 
)

Set the destructor of a vlc object.

This function sets the destructor of the vlc object. It will be called when the object is destroyed when the its refcount reaches 0. (It is called by the internal function vlc_object_destroy())

References vlc_object_internals::pf_destructor, and vlc_internals.

int vlc_object_set_name ( ((vlc_object_t *)(vlc_object_t *obj))  ,
const char *  name 
)
int vlc_object_waitpipe ( vlc_object_t obj)

Returns the readable end of a pipe that becomes readable once termination of the object is requested (vlc_object_kill()).

This can be used to wake-up out of a select() or poll() event loop, such typically when doing network I/O.

Note that the pipe will remain the same for the lifetime of the object. DO NOT read the pipe nor close it yourself. Ever.

Parameters
objobject that would be "killed"
Returns
a readable pipe descriptor, or -1 on error.

References vlc_object_internals::alive, msg_Dbg, vlc_object_internals::pipes, vlc_internals, vlc_mutex_lock(), vlc_pipe(), vlc_restorecancel(), and vlc_savecancel().

Referenced by httpd_HostCreate(), net_Accept(), net_Connect(), net_Read(), and net_Write().

Variable Documentation

vlc_mutex_t name_lock = PTHREAD_MUTEX_INITIALIZER
static
vlc_mutex_t pipe_lock = PTHREAD_MUTEX_INITIALIZER
static

Referenced by vlc_object_kill().