Changeset 479b697652a2b11aab07331e614b2e6dcc225f9b

Show
Ignore:
Timestamp:
25/02/07 12:48:39 (2 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1172404119 +0000
git-parent:

[da70bf94823d32dce1a40597c95aa130c545f50f]

git-author:
Laurent Aimar <fenrir@videolan.org> 1172404119 +0000
Message:

Fixed input_thread_t leak by description module for VLM.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/stream_out/description.c

    rd3fe7f2 r479b697  
    5555struct sout_stream_sys_t 
    5656{ 
     57    int            i_id; 
    5758    input_thread_t *p_input; 
     59 
    5860    mtime_t i_stream_start; 
    5961}; 
     
    7779    p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t)); 
    7880 
    79     p_sys->p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT )
    80     if( !p_sys->p_input ) return VLC_EGENERIC
     81    p_sys->i_id = 0
     82    p_sys->p_input = NULL
    8183 
    8284    p_sys->i_stream_start = 0; 
     
    9193{ 
    9294    sout_stream_t *p_stream = (sout_stream_t *)p_this; 
    93     vlc_object_release( p_stream->p_sys->p_input ); 
     95    sout_stream_sys_t *p_sys = p_stream->p_sys; 
     96 
     97    /* It can happen only if buggy */ 
     98    if( p_sys->p_input ) 
     99        vlc_object_release( p_sys->p_input ); 
    94100} 
    95101 
     
    98104    sout_stream_sys_t *p_sys = p_stream->p_sys; 
    99105    sout_stream_id_t *id; 
    100     es_format_t *p_fmt_copy = malloc(sizeof(es_format_t)); 
    101     input_item_t *p_item = input_GetItem(p_sys->p_input); 
     106    es_format_t *p_fmt_copy; 
     107    input_item_t *p_item; 
     108 
     109    if( !p_sys->p_input ) 
     110        p_sys->p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_PARENT ); 
     111    if( !p_sys->p_input ) 
     112        return NULL; 
     113     
     114    p_item = input_GetItem(p_sys->p_input); 
     115 
     116    p_fmt_copy = malloc(sizeof(es_format_t)); 
     117    es_format_Copy( p_fmt_copy, p_fmt ); 
     118 
     119    vlc_mutex_lock( &p_item->lock ); 
     120    TAB_APPEND( p_item->i_es, p_item->es, p_fmt_copy ); 
     121    vlc_mutex_unlock( &p_item->lock ); 
     122 
     123    p_sys->i_id++; 
     124    if( p_sys->i_stream_start <= 0 ) 
     125        p_sys->i_stream_start = mdate(); 
    102126 
    103127    id = malloc( sizeof( sout_stream_id_t ) ); 
    104128    id->i_d_u_m_m_y = 0; 
    105  
    106     es_format_Copy( p_fmt_copy, p_fmt ); 
    107  
    108     vlc_mutex_lock( &p_item->lock ); 
    109     TAB_APPEND( p_item->i_es, 
    110                 p_item->es, p_fmt_copy ); 
    111     vlc_mutex_unlock( &p_item->lock ); 
    112  
    113     if( p_sys->i_stream_start <= 0 ) p_sys->i_stream_start = mdate(); 
    114  
    115129    return id; 
    116130} 
     
    118132static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) 
    119133{ 
     134    sout_stream_sys_t *p_sys = p_stream->p_sys; 
     135 
     136    p_sys->i_id--; 
     137    if( p_sys->i_id <= 0 ) 
     138    { 
     139        vlc_object_release( p_sys->p_input ); 
     140        p_sys->p_input = NULL; 
     141    } 
     142 
    120143    free( id ); 
    121144    return VLC_SUCCESS; 
     
    129152    block_ChainRelease( p_buffer ); 
    130153 
    131     if( p_sys->i_stream_start + 1500000 < mdate() ) 
    132     { 
     154    if( p_sys->p_input && p_sys->i_stream_start + 1500000 < mdate() ) 
    133155        p_sys->p_input->b_eof = VLC_TRUE; 
    134     } 
    135156 
    136157    return VLC_SUCCESS;