Changeset e0784be1ce6d3f6a1b34f7f3a47707e3a9887a4f
- Timestamp:
- 30/09/07 16:01:24
(1 year ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1191160884 +0000
- git-parent:
[02102ee36ffbd8d7adc243db38bd4856a29426db]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1191160884 +0000
- Message:
Hide object reference counter.
Good news is, no plugins used it anyway.
Bad news is, some parts of libvlc still use which is wrong (i_refcount is protected by the "structure lock", meaning only misc/objects.c functions can use it safely).
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r42327f3 |
re0784be |
|
| 577 | 577 | libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \ |
|---|
| 578 | 578 | \ |
|---|
| 579 | | volatile int i_refcount; /**< usage count */ \ |
|---|
| 580 | 579 | vlc_object_t * p_parent; /**< our parent */ \ |
|---|
| 581 | 580 | vlc_object_t ** pp_children; /**< our children */ \ |
|---|
| r145a649 |
re0784be |
|
| 53 | 53 | vlc_object_release( p_input_thread ); |
|---|
| 54 | 54 | |
|---|
| 55 | | should_destroy = p_input_thread->i_refcount == 1; |
|---|
| | 55 | should_destroy = p_input_thread->p_internals->i_refcount == 1; |
|---|
| 56 | 56 | |
|---|
| 57 | 57 | /* release for initial p_input_thread yield (see _new()) */ |
|---|
| r6ee1e19 |
re0784be |
|
| 168 | 168 | vlc_object_release( p_vlm ); |
|---|
| 169 | 169 | |
|---|
| 170 | | if( p_vlm->i_refcount > 0 ) |
|---|
| | 170 | if( p_vlm->p_internals->i_refcount > 0 ) |
|---|
| 171 | 171 | { |
|---|
| 172 | 172 | vlc_mutex_unlock( lockval.p_address ); |
|---|
| ra4cee8c |
re0784be |
|
| 113 | 113 | |
|---|
| 114 | 114 | /* Objects management */ |
|---|
| | 115 | unsigned i_refcount; |
|---|
| 115 | 116 | vlc_bool_t b_attached; |
|---|
| 116 | 117 | }; |
|---|
| r42327f3 |
re0784be |
|
| 178 | 178 | } |
|---|
| 179 | 179 | |
|---|
| 180 | | p_new->i_refcount = 0; |
|---|
| | 180 | p_priv->i_refcount = 0; |
|---|
| 181 | 181 | p_new->p_parent = NULL; |
|---|
| 182 | 182 | p_new->pp_children = NULL; |
|---|
| … | … | |
| 359 | 359 | } |
|---|
| 360 | 360 | |
|---|
| 361 | | while( p_this->i_refcount ) |
|---|
| | 361 | while( p_priv->i_refcount > 0 ) |
|---|
| 362 | 362 | { |
|---|
| 363 | 363 | i_delay++; |
|---|
| … | … | |
| 367 | 367 | { |
|---|
| 368 | 368 | msg_Warn( p_this, |
|---|
| 369 | | "refcount is %i, delaying before deletion (id=%d,type=%d)", |
|---|
| 370 | | p_this->i_refcount, p_this->i_object_id, |
|---|
| | 369 | "refcount is %u, delaying before deletion (id=%d,type=%d)", |
|---|
| | 370 | p_priv->i_refcount, p_this->i_object_id, |
|---|
| 371 | 371 | p_this->i_object_type ); |
|---|
| 372 | 372 | } |
|---|
| … | … | |
| 374 | 374 | { |
|---|
| 375 | 375 | msg_Err( p_this, |
|---|
| 376 | | "refcount is %i, delaying again (id=%d,type=%d)", |
|---|
| 377 | | p_this->i_refcount, p_this->i_object_id, |
|---|
| | 376 | "refcount is %u, delaying again (id=%d,type=%d)", |
|---|
| | 377 | p_priv->i_refcount, p_this->i_object_id, |
|---|
| 378 | 378 | p_this->i_object_type ); |
|---|
| 379 | 379 | } |
|---|
| … | … | |
| 559 | 559 | { |
|---|
| 560 | 560 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 561 | | pp_objects[i_middle+1]->i_refcount++; |
|---|
| | 561 | pp_objects[i_middle+1]->p_internals->i_refcount++; |
|---|
| 562 | 562 | return pp_objects[i_middle+1]; |
|---|
| 563 | 563 | } |
|---|
| … | … | |
| 568 | 568 | { |
|---|
| 569 | 569 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 570 | | pp_objects[i_middle]->i_refcount++; |
|---|
| | 570 | pp_objects[i_middle]->p_internals->i_refcount++; |
|---|
| 571 | 571 | return pp_objects[i_middle]; |
|---|
| 572 | 572 | } |
|---|
| … | … | |
| 600 | 600 | if( !(i_mode & FIND_STRICT) && p_this->i_object_type == i_type ) |
|---|
| 601 | 601 | { |
|---|
| 602 | | p_this->i_refcount++; |
|---|
| | 602 | p_this->p_internals->i_refcount++; |
|---|
| 603 | 603 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 604 | 604 | return p_this; |
|---|
| … | … | |
| 653 | 653 | && !strcmp( p_this->psz_object_name, psz_name ) ) |
|---|
| 654 | 654 | { |
|---|
| 655 | | p_this->i_refcount++; |
|---|
| | 655 | p_this->p_internals->i_refcount++; |
|---|
| 656 | 656 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 657 | 657 | return p_this; |
|---|
| … | … | |
| 695 | 695 | { |
|---|
| 696 | 696 | vlc_mutex_lock( &structure_lock ); |
|---|
| 697 | | p_this->i_refcount++; |
|---|
| | 697 | p_this->p_internals->i_refcount++; |
|---|
| 698 | 698 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 699 | 699 | } |
|---|
| 700 | 700 | |
|---|
| 701 | | /** |
|---|
| 702 | | **************************************************************************** |
|---|
| | 701 | static inline void Release( vlc_object_t *obj ) |
|---|
| | 702 | { |
|---|
| | 703 | assert( obj->p_internals->i_refcount > 0 ); |
|---|
| | 704 | obj->p_internals->i_refcount--; |
|---|
| | 705 | } |
|---|
| | 706 | |
|---|
| | 707 | /***************************************************************************** |
|---|
| 703 | 708 | * decrement an object refcount |
|---|
| 704 | 709 | *****************************************************************************/ |
|---|
| … | … | |
| 706 | 711 | { |
|---|
| 707 | 712 | vlc_mutex_lock( &structure_lock ); |
|---|
| 708 | | p_this->i_refcount--; |
|---|
| | 713 | Release( p_this ); |
|---|
| 709 | 714 | vlc_mutex_unlock( &structure_lock ); |
|---|
| 710 | 715 | } |
|---|
| … | … | |
| 1031 | 1036 | for( i_index = 0; i_index < p_list->i_count; i_index++ ) |
|---|
| 1032 | 1037 | { |
|---|
| 1033 | | p_list->p_values[i_index].p_object->i_refcount--; |
|---|
| | 1038 | Release( p_list->p_values[i_index].p_object ); |
|---|
| 1034 | 1039 | } |
|---|
| 1035 | 1040 | vlc_mutex_unlock( &structure_lock ); |
|---|
| … | … | |
| 1094 | 1099 | if( p_tmp->i_object_type == i_type ) |
|---|
| 1095 | 1100 | { |
|---|
| 1096 | | p_tmp->i_refcount++; |
|---|
| | 1101 | p_tmp->p_internals->i_refcount++; |
|---|
| 1097 | 1102 | return p_tmp; |
|---|
| 1098 | 1103 | } |
|---|
| … | … | |
| 1110 | 1115 | if( p_tmp->i_object_type == i_type ) |
|---|
| 1111 | 1116 | { |
|---|
| 1112 | | p_tmp->i_refcount++; |
|---|
| | 1117 | p_tmp->p_internals->i_refcount++; |
|---|
| 1113 | 1118 | return p_tmp; |
|---|
| 1114 | 1119 | } |
|---|
| … | … | |
| 1148 | 1153 | && !strcmp( p_tmp->psz_object_name, psz_name ) ) |
|---|
| 1149 | 1154 | { |
|---|
| 1150 | | p_tmp->i_refcount++; |
|---|
| | 1155 | p_tmp->p_internals->i_refcount++; |
|---|
| 1151 | 1156 | return p_tmp; |
|---|
| 1152 | 1157 | } |
|---|
| … | … | |
| 1165 | 1170 | && !strcmp( p_tmp->psz_object_name, psz_name ) ) |
|---|
| 1166 | 1171 | { |
|---|
| 1167 | | p_tmp->i_refcount++; |
|---|
| | 1172 | p_tmp->p_internals->i_refcount++; |
|---|
| 1168 | 1173 | return p_tmp; |
|---|
| 1169 | 1174 | } |
|---|
| … | … | |
| 1265 | 1270 | |
|---|
| 1266 | 1271 | psz_refcount[0] = '\0'; |
|---|
| 1267 | | if( p_this->i_refcount ) |
|---|
| 1268 | | snprintf( psz_refcount, 19, ", refcount %i", p_this->i_refcount ); |
|---|
| | 1272 | if( p_this->p_internals->i_refcount > 0 ) |
|---|
| | 1273 | snprintf( psz_refcount, 19, ", refcount %u", |
|---|
| | 1274 | p_this->p_internals->i_refcount ); |
|---|
| 1269 | 1275 | |
|---|
| 1270 | 1276 | psz_thread[0] = '\0'; |
|---|
| … | … | |
| 1365 | 1371 | } |
|---|
| 1366 | 1372 | |
|---|
| 1367 | | p_object->i_refcount++; |
|---|
| | 1373 | p_object->p_internals->i_refcount++; |
|---|
| 1368 | 1374 | |
|---|
| 1369 | 1375 | p_list->p_values[i_index].p_object = p_object; |
|---|
| … | … | |
| 1387 | 1393 | } |
|---|
| 1388 | 1394 | |
|---|
| 1389 | | p_object->i_refcount++; |
|---|
| | 1395 | p_object->p_internals->i_refcount++; |
|---|
| 1390 | 1396 | |
|---|
| 1391 | 1397 | p_list->p_values[p_list->i_count].p_object = p_object; |
|---|
| r6ee1e19 |
re0784be |
|
| 29 | 29 | #include <vlc_keys.h> |
|---|
| 30 | 30 | #include <vlc_osd.h> |
|---|
| | 31 | #include "libvlc.h" |
|---|
| 31 | 32 | |
|---|
| 32 | 33 | #undef OSD_MENU_DEBUG |
|---|
| … | … | |
| 131 | 132 | |
|---|
| 132 | 133 | vlc_object_release( p_osd ); |
|---|
| 133 | | if( p_osd->i_refcount > 0 ) |
|---|
| | 134 | if( p_osd->p_internals->i_refcount > 0 ) |
|---|
| 134 | 135 | { |
|---|
| 135 | 136 | vlc_mutex_unlock( lockval.p_address ); |
|---|