Changeset 8a0dc31dcad18b36c9545910c0e09b22a4c6c020

Show
Ignore:
Timestamp:
13/05/08 12:15:42 (5 months ago)
Author:
Rafaël Carré <funman@videolan.org>
git-committer:
Rafaël Carré <funman@videolan.org> 1210673742 +0200
git-parent:

[6ba2378ea683a7cbab6739cb18b64324ba56a377]

git-author:
Rafaël Carré <funman@videolan.org> 1210673742 +0200
Message:

Fix cyclic dependancy between input and "sout stream" description

Files:

Legend:

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

    rff9f9ff r8a0dc31  
    5858struct sout_stream_sys_t 
    5959{ 
    60     int            i_id; 
    6160    input_thread_t *p_input; 
    6261 
     
    8281    p_sys = p_stream->p_sys = malloc(sizeof(sout_stream_sys_t)); 
    8382 
    84     p_sys->i_id = 0; 
    8583    p_sys->p_input = NULL; 
    8684 
     
    9896    sout_stream_sys_t *p_sys = p_stream->p_sys; 
    9997 
    100     msg_Dbg( p_this, "description: Closing the module" ); 
    101  
    102     /* It can happen only if buggy */ 
    103     assert( !p_sys->p_input ); 
     98    msg_Dbg( p_this, "Closing" ); 
    10499 
    105100    free( p_sys ); 
     
    113108    input_item_t *p_item; 
    114109 
    115     msg_Dbg( p_stream, "description: Adding a stream" ); 
     110    msg_Dbg( p_stream, "Adding a stream" ); 
    116111 
    117112    if( !p_sys->p_input ) 
    118         p_sys->p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, FIND_PARENT ); 
    119     if( !p_sys->p_input ) 
    120         return NULL; 
     113    { 
     114        p_sys->p_input = vlc_object_find( p_stream, VLC_OBJECT_INPUT, 
     115                FIND_PARENT ); 
     116        /* This module is a children of the input object 
     117         * We don't want to keep a reference on it, because we will be alive 
     118         * as long as the input is alive. 
     119         * 
     120         * Since vlc_object_find() increments the reference count, 
     121         * we release the input just after finding it. 
     122         * */ 
     123        assert( p_sys->p_input ); 
     124        vlc_object_release( p_sys->p_input ); 
     125    } 
    121126  
    122127    p_item = input_GetItem(p_sys->p_input); 
     
    129134    vlc_mutex_unlock( &p_item->lock ); 
    130135 
    131     p_sys->i_id++; 
    132136    if( p_sys->i_stream_start <= 0 ) 
    133137        p_sys->i_stream_start = mdate(); 
     
    142146    sout_stream_sys_t *p_sys = p_stream->p_sys; 
    143147 
    144     msg_Dbg( p_stream, "description: Removing a stream (id:%d)", p_sys->i_id ); 
    145  
    146     p_sys->i_id--; 
    147     if( p_sys->i_id <= 0 ) 
    148     { 
    149         vlc_object_release( p_sys->p_input ); 
    150         p_sys->p_input = NULL; 
    151     } 
     148    msg_Dbg( p_stream, "Removing a stream" ); 
    152149 
    153150    free( id );