Changeset d7bc817f72e44cacf0fc9468c7988ee1f4b565a7

Show
Ignore:
Timestamp:
26/02/07 20:27:35 (2 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1172518055 +0000
git-parent:

[f6b77b24afe7f73539125d178712b83b9bb4d771]

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

Force VLM stream to not use sout-keep.
Fixed race condition with sout-keep.
Fixed broken sout-keep behaviour (currently active sout can be used

twice or destroyed..., it might fixed segfaults reported by xxcv))

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/input/input.c

    r7196e8d rd7bc817  
    11871187            if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool ) 
    11881188            { 
     1189                playlist_t  *p_playlist = pl_Yield( p_input ); 
     1190 
    11891191                /* attach sout to the playlist */ 
    1190                 msg_Dbg( p_input, "keeping sout" ); 
    11911192                vlc_object_detach( p_input->p->p_sout ); 
    1192                 vlc_object_attach( p_input->p->p_sout, p_input->p_libvlc->p_playlist ); 
     1193                vlc_object_attach( p_input->p->p_sout, p_playlist ); 
     1194                pl_Release( p_input ); 
     1195                msg_Dbg( p_input, "kept sout" ); 
    11931196            } 
    11941197            else 
    11951198            { 
    1196                 msg_Dbg( p_input, "destroying sout" ); 
    11971199                sout_DeleteInstance( p_input->p->p_sout ); 
     1200                msg_Dbg( p_input, "destroyed sout" ); 
    11981201            } 
    11991202        } 
  • src/input/vlm.c

    re7bb450 rd7bc817  
    8888 
    8989        vlc_mutex_init( p_this->p_libvlc, &p_vlm->lock ); 
    90         p_vlm->i_media      = 0; 
    91         p_vlm->media        = NULL; 
    92         p_vlm->i_vod        = 0; 
    93         p_vlm->i_schedule   = 0; 
    94         p_vlm->schedule     = NULL; 
     90        TAB_INIT( p_vlm->i_media, p_vlm->media ); 
     91        TAB_INIT( p_vlm->i_schedule, p_vlm->schedule ); 
     92        p_vlm->i_vod = 0; 
     93        p_vlm->vod = NULL; 
    9594 
    9695        vlc_object_yield( p_vlm ); 
     
    11151114            char *psz_output; 
    11161115            char *psz_header; 
     1116            char *psz_dup; 
    11171117            int i; 
    11181118 
     
    11261126 
    11271127            media->item.psz_uri = strdup( media->input[0] ); 
    1128             media->item.ppsz_options = malloc( sizeof( char* ) ); 
    1129             asprintf( &media->item.ppsz_options[0], "sout=%s", psz_output); 
    1130             media->item.i_options = 1; 
     1128 
     1129            TAB_INIT( media->item.i_options, media->item.ppsz_options ); 
     1130 
     1131            asprintf( &psz_dup, "sout=%s", psz_output); 
     1132            TAB_APPEND( media->item.i_options, media->item.ppsz_options, psz_dup ); 
    11311133            for( i = 0; i < media->i_option; i++ ) 
    11321134            { 
    1133                 media->item.i_options++; 
    1134                 media->item.ppsz_options = 
    1135                     realloc( media->item.ppsz_options, 
    1136                              media->item.i_options * sizeof( char* ) ); 
    1137                 media->item.ppsz_options[ media->item.i_options - 1 ] = 
    1138                     strdup( media->option[i] ); 
    1139             } 
     1135                psz_dup = strdup( media->option[i] ); 
     1136                TAB_APPEND( media->item.i_options, media->item.ppsz_options, psz_dup ); 
     1137            } 
     1138            psz_dup = strdup( "no-sout-keep" ); 
     1139            TAB_APPEND( media->item.i_options, media->item.ppsz_options, psz_dup ); 
    11401140 
    11411141            asprintf( &psz_header, _("Media: %s"), media->psz_name ); 
     
    11441144                                              ) ) ) 
    11451145            { 
    1146                 while( !p_input->b_eof && !p_input->b_error ) msleep( 100000 ); 
     1146                while( !p_input->b_eof && !p_input->b_error ) 
     1147                    msleep( 100000 ); 
    11471148 
    11481149                input_StopThread( p_input ); 
     
    11961197        if( !p_instance ) 
    11971198        { 
     1199            char *psz_dup; 
     1200 
    11981201            p_instance = malloc( sizeof(vlm_media_instance_t) ); 
    1199             if( !p_instance ) return VLC_EGENERIC; 
     1202            if( !p_instance ) 
     1203                return VLC_ENOMEM; 
     1204 
    12001205            memset( p_instance, 0, sizeof(vlm_media_instance_t) ); 
     1206 
     1207            p_instance->psz_name = psz_id ? strdup( psz_id ) : NULL; 
    12011208            input_ItemInit( VLC_OBJECT(vlm), &p_instance->item ); 
    12021209            p_instance->p_input = NULL; 
    12031210 
    1204             if( ( media->psz_output != NULL ) || ( media->psz_vod_output != NULL ) ) 
    1205             { 
    1206                 p_instance->item.ppsz_options = malloc( sizeof( char* ) ); 
    1207                 asprintf( &p_instance->item.ppsz_options[0], "sout=%s%s%s", 
     1211            TAB_INIT( p_instance->item.i_options, p_instance->item.ppsz_options ); 
     1212 
     1213            if( media->psz_output != NULL || media->psz_vod_output != NULL ) 
     1214            { 
     1215                asprintf( &psz_dup, "sout=%s%s%s", 
    12081216                          media->psz_output ? media->psz_output : "", 
    1209                           (media->psz_output && media->psz_vod_output) ? 
    1210                           ":" : media->psz_vod_output ? "#" : "", 
     1217                          (media->psz_output && media->psz_vod_output) ? ":" : media->psz_vod_output ? "#" : "", 
    12111218                          media->psz_vod_output ? media->psz_vod_output : "" ); 
    1212                 p_instance->item.i_options = 1
     1219                TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, psz_dup )
    12131220            } 
    12141221 
    12151222            for( i = 0; i < media->i_option; i++ ) 
    12161223            { 
    1217                 p_instance->item.i_options++; 
    1218                 p_instance->item.ppsz_options = 
    1219                     realloc( p_instance->item.ppsz_options, 
    1220                              p_instance->item.i_options * sizeof( char* ) ); 
    1221                 p_instance->item.ppsz_options[p_instance->item.i_options - 1] = 
    1222                     strdup( media->option[i] ); 
    1223             } 
    1224  
    1225             p_instance->psz_name = psz_id ? strdup( psz_id ) : NULL; 
     1224                psz_dup = strdup( media->option[i] ); 
     1225                TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, psz_dup ); 
     1226            } 
     1227            psz_dup = strdup( "no-sout-keep" ); 
     1228            TAB_APPEND( p_instance->item.i_options, p_instance->item.ppsz_options, psz_dup ); 
     1229 
    12261230            TAB_APPEND( media->i_instance, media->instance, p_instance ); 
    12271231        } 
  • src/stream_output/stream_output.c

    raf518b8 rd7bc817  
    3535 
    3636#include <vlc_sout.h> 
     37#include <vlc_playlist.h> 
    3738 
    3839#include "stream_output.h" 
     
    7576    vlc_value_t keep; 
    7677 
    77     if( var_Get( p_parent, "sout-keep", &keep ) < 0 ) 
    78     { 
    79         msg_Warn( p_parent, "cannot get sout-keep value" ); 
    80         keep.b_bool = VLC_FALSE; 
    81     } 
    82     if( keep.b_bool ) 
    83     { 
    84         if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, 
    85                                         FIND_ANYWHERE ) ) != NULL ) 
     78    if( var_Get( p_parent, "sout-keep", &keep ) >= 0 && keep.b_bool ) 
     79    { 
     80        /* Remove the sout from the playlist garbage collector */ 
     81        playlist_t *p_playlist = pl_Yield( p_parent ); 
     82 
     83        vlc_mutex_lock( &p_playlist->gc_lock ); 
     84        p_sout = vlc_object_find( p_playlist, VLC_OBJECT_SOUT, FIND_CHILD ); 
     85        if( p_sout && p_sout->p_parent != (vlc_object_t *)p_playlist ) 
     86        { 
     87            vlc_object_release( p_sout ); 
     88            p_sout = NULL; 
     89        } 
     90        if( p_sout ) 
     91            vlc_object_detach( p_sout );    /* Remove it from the GC */ 
     92        vlc_mutex_unlock( &p_playlist->gc_lock ); 
     93 
     94        pl_Release( p_parent ); 
     95 
     96        /* */ 
     97 
     98        if( p_sout ) 
    8699        { 
    87100            if( !strcmp( p_sout->psz_sout, psz_dest ) ) 
     
    90103                msg_Dbg( p_parent, "sout keep: you probably want to use " 
    91104                          "gather stream_out" ); 
    92                 vlc_object_detach( p_sout ); 
    93105                vlc_object_attach( p_sout, p_parent ); 
    94106                vlc_object_release( p_sout ); 
    95107                return p_sout; 
    96108            } 
    97             else 
    98             { 
    99                 msg_Dbg( p_parent, "sout keep: destroying unusable sout" ); 
    100                 vlc_object_release( p_sout ); 
    101                 sout_DeleteInstance( p_sout ); 
    102             } 
    103         } 
    104     } 
    105     else if( !keep.b_bool ) 
    106     { 
    107         while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT, 
    108                                            FIND_PARENT ) ) != NULL ) 
    109         { 
    110             msg_Dbg( p_parent, "sout keep: destroying old sout" ); 
     109 
     110            msg_Dbg( p_parent, "sout keep: destroying unusable sout" ); 
    111111            vlc_object_release( p_sout ); 
    112112            sout_DeleteInstance( p_sout );