Changeset 56a0945078146cedcd3c9e33ce86caa24de79b2f
- Timestamp:
- 03/19/08 00:05:06
(5 months ago)
- Author:
- Pierre d'Herbemont <pdherbemont@free.fr>
- git-committer:
- Pierre d'Herbemont <pdherbemont@free.fr> 1205881506 +0100
- git-parent:
[879e3eb226c7df84db6868b25964830664f92ebb]
- git-author:
- Pierre d'Herbemont <pdherbemont@free.fr> 1205879003 +0100
- Message:
vlc_objects.h: Export and implement vlc_object_set_destructor().
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r55f3a9f |
r56a0945 |
|
| 84 | 84 | #define OBJECT_FLAGS_NOINTERACT 0x0004 |
|---|
| 85 | 85 | |
|---|
| | 86 | /* Types */ |
|---|
| | 87 | typedef void (*vlc_destructor_t)(struct vlc_object_t *); |
|---|
| | 88 | |
|---|
| | 89 | /* Constants */ |
|---|
| | 90 | VLC_PUBLIC_API const vlc_destructor_t kVLCDestructor; |
|---|
| | 91 | |
|---|
| 86 | 92 | /***************************************************************************** |
|---|
| 87 | 93 | * The vlc_object_t type. Yes, it's that simple :-) |
|---|
| … | … | |
| 97 | 103 | *****************************************************************************/ |
|---|
| 98 | 104 | VLC_EXPORT( void *, __vlc_object_create, ( vlc_object_t *, int ) ); |
|---|
| | 105 | VLC_EXPORT( void, __vlc_object_set_destructor, ( vlc_object_t *, vlc_destructor_t ) ); |
|---|
| 99 | 106 | VLC_EXPORT( void, __vlc_object_attach, ( vlc_object_t *, vlc_object_t * ) ); |
|---|
| 100 | 107 | VLC_EXPORT( void, __vlc_object_detach, ( vlc_object_t * ) ); |
|---|
| … | … | |
| 112 | 119 | __vlc_object_create( VLC_OBJECT(a), b ) |
|---|
| 113 | 120 | |
|---|
| | 121 | #define vlc_object_set_destructor(a,b) \ |
|---|
| | 122 | __vlc_object_set_destructor( VLC_OBJECT(a), b ) |
|---|
| | 123 | |
|---|
| 114 | 124 | #define vlc_object_detach(a) \ |
|---|
| 115 | 125 | __vlc_object_detach( VLC_OBJECT(a) ) |
|---|
| rb3a086f |
r56a0945 |
|
| 134 | 134 | |
|---|
| 135 | 135 | /* Objects management */ |
|---|
| 136 | | unsigned i_refcount; |
|---|
| 137 | | vlc_bool_t b_attached; |
|---|
| | 136 | unsigned i_refcount; |
|---|
| | 137 | vlc_destructor_t pf_destructor; |
|---|
| | 138 | vlc_bool_t b_attached; |
|---|
| 138 | 139 | }; |
|---|
| 139 | 140 | |
|---|
| r55f3a9f |
r56a0945 |
|
| 74 | 74 | |
|---|
| 75 | 75 | /***************************************************************************** |
|---|
| | 76 | * Constants |
|---|
| | 77 | *****************************************************************************/ |
|---|
| | 78 | |
|---|
| | 79 | const vlc_destructor_t kVLCDestructor = NULL; |
|---|
| | 80 | |
|---|
| | 81 | /***************************************************************************** |
|---|
| 76 | 82 | * Local prototypes |
|---|
| 77 | 83 | *****************************************************************************/ |
|---|
| … | … | |
| 194 | 200 | |
|---|
| 195 | 201 | p_priv->i_refcount = 1; |
|---|
| | 202 | p_priv->pf_destructor = kVLCDestructor; |
|---|
| 196 | 203 | p_new->p_parent = NULL; |
|---|
| 197 | 204 | p_new->pp_children = NULL; |
|---|
| … | … | |
| 355 | 362 | /** |
|---|
| 356 | 363 | **************************************************************************** |
|---|
| | 364 | * Set the destructor of a vlc object |
|---|
| | 365 | * |
|---|
| | 366 | * This function sets the destructor of the vlc object. It will be called |
|---|
| | 367 | * when the object is destroyed when the its refcount reaches 0. |
|---|
| | 368 | * (It is called by the internal function vlc_object_destroy()) |
|---|
| | 369 | *****************************************************************************/ |
|---|
| | 370 | void __vlc_object_set_destructor( vlc_object_t *p_this, |
|---|
| | 371 | vlc_destructor_t pf_destructor ) |
|---|
| | 372 | { |
|---|
| | 373 | vlc_object_internals_t *p_priv = vlc_internals(p_this ); |
|---|
| | 374 | |
|---|
| | 375 | vlc_mutex_lock( &structure_lock ); |
|---|
| | 376 | p_priv->pf_destructor = pf_destructor; |
|---|
| | 377 | vlc_mutex_unlock( &structure_lock ); |
|---|
| | 378 | } |
|---|
| | 379 | |
|---|
| | 380 | /** |
|---|
| | 381 | **************************************************************************** |
|---|
| 357 | 382 | * Destroy a vlc object (Internal) |
|---|
| 358 | 383 | * |
|---|
| … | … | |
| 400 | 425 | abort(); |
|---|
| 401 | 426 | } |
|---|
| | 427 | |
|---|
| | 428 | /* Call the custom "subclass" destructor */ |
|---|
| | 429 | if( p_priv->pf_destructor ) |
|---|
| | 430 | p_priv->pf_destructor( p_this ); |
|---|
| | 431 | |
|---|
| 402 | 432 | |
|---|
| 403 | 433 | /* Destroy the associated variables, starting from the end so that |
|---|