Changeset e0784be1ce6d3f6a1b34f7f3a47707e3a9887a4f

Show
Ignore:
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
  • include/vlc_common.h

    r42327f3 re0784be  
    577577    libvlc_int_t *p_libvlc;                  /**< (root of all evil) - 1 */ \ 
    578578                                                                            \ 
    579     volatile int    i_refcount;                         /**< usage count */ \ 
    580579    vlc_object_t *  p_parent;                            /**< our parent */ \ 
    581580    vlc_object_t ** pp_children;                       /**< our children */ \ 
  • src/control/media_instance.c

    r145a649 re0784be  
    5353    vlc_object_release( p_input_thread ); 
    5454 
    55     should_destroy = p_input_thread->i_refcount == 1; 
     55    should_destroy = p_input_thread->p_internals->i_refcount == 1; 
    5656 
    5757    /* release for initial p_input_thread yield (see _new()) */ 
  • src/input/vlm.c

    r6ee1e19 re0784be  
    168168    vlc_object_release( p_vlm ); 
    169169 
    170     if( p_vlm->i_refcount > 0 ) 
     170    if( p_vlm->p_internals->i_refcount > 0 ) 
    171171    { 
    172172        vlc_mutex_unlock( lockval.p_address ); 
  • src/libvlc.h

    ra4cee8c re0784be  
    113113 
    114114    /* Objects management */ 
     115    unsigned        i_refcount; 
    115116    vlc_bool_t      b_attached; 
    116117}; 
  • src/misc/objects.c

    r42327f3 re0784be  
    178178    } 
    179179 
    180     p_new->i_refcount = 0; 
     180    p_priv->i_refcount = 0; 
    181181    p_new->p_parent = NULL; 
    182182    p_new->pp_children = NULL; 
     
    359359    } 
    360360 
    361     while( p_this->i_refcount
     361    while( p_priv->i_refcount > 0
    362362    { 
    363363        i_delay++; 
     
    367367        { 
    368368            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, 
    371371                  p_this->i_object_type ); 
    372372        } 
     
    374374        { 
    375375            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, 
    378378                  p_this->i_object_type ); 
    379379        } 
     
    559559                { 
    560560                    vlc_mutex_unlock( &structure_lock ); 
    561                     pp_objects[i_middle+1]->i_refcount++; 
     561                    pp_objects[i_middle+1]->p_internals->i_refcount++; 
    562562                    return pp_objects[i_middle+1]; 
    563563                } 
     
    568568        { 
    569569            vlc_mutex_unlock( &structure_lock ); 
    570             pp_objects[i_middle]->i_refcount++; 
     570            pp_objects[i_middle]->p_internals->i_refcount++; 
    571571            return pp_objects[i_middle]; 
    572572        } 
     
    600600    if( !(i_mode & FIND_STRICT) && p_this->i_object_type == i_type ) 
    601601    { 
    602         p_this->i_refcount++; 
     602        p_this->p_internals->i_refcount++; 
    603603        vlc_mutex_unlock( &structure_lock ); 
    604604        return p_this; 
     
    653653        && !strcmp( p_this->psz_object_name, psz_name ) ) 
    654654    { 
    655         p_this->i_refcount++; 
     655        p_this->p_internals->i_refcount++; 
    656656        vlc_mutex_unlock( &structure_lock ); 
    657657        return p_this; 
     
    695695{ 
    696696    vlc_mutex_lock( &structure_lock ); 
    697     p_this->i_refcount++; 
     697    p_this->p_internals->i_refcount++; 
    698698    vlc_mutex_unlock( &structure_lock ); 
    699699} 
    700700 
    701 /** 
    702  **************************************************************************** 
     701static 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/***************************************************************************** 
    703708 * decrement an object refcount 
    704709 *****************************************************************************/ 
     
    706711{ 
    707712    vlc_mutex_lock( &structure_lock ); 
    708     p_this->i_refcount--
     713    Release( p_this )
    709714    vlc_mutex_unlock( &structure_lock ); 
    710715} 
     
    10311036    for( i_index = 0; i_index < p_list->i_count; i_index++ ) 
    10321037    { 
    1033         p_list->p_values[i_index].p_object->i_refcount--
     1038        Release( p_list->p_values[i_index].p_object )
    10341039    } 
    10351040    vlc_mutex_unlock( &structure_lock ); 
     
    10941099            if( p_tmp->i_object_type == i_type ) 
    10951100            { 
    1096                 p_tmp->i_refcount++; 
     1101                p_tmp->p_internals->i_refcount++; 
    10971102                return p_tmp; 
    10981103            } 
     
    11101115            if( p_tmp->i_object_type == i_type ) 
    11111116            { 
    1112                 p_tmp->i_refcount++; 
     1117                p_tmp->p_internals->i_refcount++; 
    11131118                return p_tmp; 
    11141119            } 
     
    11481153                && !strcmp( p_tmp->psz_object_name, psz_name ) ) 
    11491154            { 
    1150                 p_tmp->i_refcount++; 
     1155                p_tmp->p_internals->i_refcount++; 
    11511156                return p_tmp; 
    11521157            } 
     
    11651170                && !strcmp( p_tmp->psz_object_name, psz_name ) ) 
    11661171            { 
    1167                 p_tmp->i_refcount++; 
     1172                p_tmp->p_internals->i_refcount++; 
    11681173                return p_tmp; 
    11691174            } 
     
    12651270 
    12661271    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 ); 
    12691275 
    12701276    psz_thread[0] = '\0'; 
     
    13651371    } 
    13661372 
    1367     p_object->i_refcount++; 
     1373    p_object->p_internals->i_refcount++; 
    13681374 
    13691375    p_list->p_values[i_index].p_object = p_object; 
     
    13871393    } 
    13881394 
    1389     p_object->i_refcount++; 
     1395    p_object->p_internals->i_refcount++; 
    13901396 
    13911397    p_list->p_values[p_list->i_count].p_object = p_object; 
  • src/osd/osd.c

    r6ee1e19 re0784be  
    2929#include <vlc_keys.h> 
    3030#include <vlc_osd.h> 
     31#include "libvlc.h" 
    3132 
    3233#undef OSD_MENU_DEBUG 
     
    131132 
    132133    vlc_object_release( p_osd ); 
    133     if( p_osd->i_refcount > 0 ) 
     134    if( p_osd->p_internals->i_refcount > 0 ) 
    134135    { 
    135136        vlc_mutex_unlock( lockval.p_address );