Changeset d7bc817f72e44cacf0fc9468c7988ee1f4b565a7
- 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
| r7196e8d |
rd7bc817 |
|
| 1187 | 1187 | if( var_Get( p_input, "sout-keep", &keep ) >= 0 && keep.b_bool ) |
|---|
| 1188 | 1188 | { |
|---|
| | 1189 | playlist_t *p_playlist = pl_Yield( p_input ); |
|---|
| | 1190 | |
|---|
| 1189 | 1191 | /* attach sout to the playlist */ |
|---|
| 1190 | | msg_Dbg( p_input, "keeping sout" ); |
|---|
| 1191 | 1192 | 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" ); |
|---|
| 1193 | 1196 | } |
|---|
| 1194 | 1197 | else |
|---|
| 1195 | 1198 | { |
|---|
| 1196 | | msg_Dbg( p_input, "destroying sout" ); |
|---|
| 1197 | 1199 | sout_DeleteInstance( p_input->p->p_sout ); |
|---|
| | 1200 | msg_Dbg( p_input, "destroyed sout" ); |
|---|
| 1198 | 1201 | } |
|---|
| 1199 | 1202 | } |
|---|
| re7bb450 |
rd7bc817 |
|
| 88 | 88 | |
|---|
| 89 | 89 | 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; |
|---|
| 95 | 94 | |
|---|
| 96 | 95 | vlc_object_yield( p_vlm ); |
|---|
| … | … | |
| 1115 | 1114 | char *psz_output; |
|---|
| 1116 | 1115 | char *psz_header; |
|---|
| | 1116 | char *psz_dup; |
|---|
| 1117 | 1117 | int i; |
|---|
| 1118 | 1118 | |
|---|
| … | … | |
| 1126 | 1126 | |
|---|
| 1127 | 1127 | 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 ); |
|---|
| 1131 | 1133 | for( i = 0; i < media->i_option; i++ ) |
|---|
| 1132 | 1134 | { |
|---|
| 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 ); |
|---|
| 1140 | 1140 | |
|---|
| 1141 | 1141 | asprintf( &psz_header, _("Media: %s"), media->psz_name ); |
|---|
| … | … | |
| 1144 | 1144 | ) ) ) |
|---|
| 1145 | 1145 | { |
|---|
| 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 ); |
|---|
| 1147 | 1148 | |
|---|
| 1148 | 1149 | input_StopThread( p_input ); |
|---|
| … | … | |
| 1196 | 1197 | if( !p_instance ) |
|---|
| 1197 | 1198 | { |
|---|
| | 1199 | char *psz_dup; |
|---|
| | 1200 | |
|---|
| 1198 | 1201 | p_instance = malloc( sizeof(vlm_media_instance_t) ); |
|---|
| 1199 | | if( !p_instance ) return VLC_EGENERIC; |
|---|
| | 1202 | if( !p_instance ) |
|---|
| | 1203 | return VLC_ENOMEM; |
|---|
| | 1204 | |
|---|
| 1200 | 1205 | memset( p_instance, 0, sizeof(vlm_media_instance_t) ); |
|---|
| | 1206 | |
|---|
| | 1207 | p_instance->psz_name = psz_id ? strdup( psz_id ) : NULL; |
|---|
| 1201 | 1208 | input_ItemInit( VLC_OBJECT(vlm), &p_instance->item ); |
|---|
| 1202 | 1209 | p_instance->p_input = NULL; |
|---|
| 1203 | 1210 | |
|---|
| 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", |
|---|
| 1208 | 1216 | 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 ? "#" : "", |
|---|
| 1211 | 1218 | 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 ); |
|---|
| 1213 | 1220 | } |
|---|
| 1214 | 1221 | |
|---|
| 1215 | 1222 | for( i = 0; i < media->i_option; i++ ) |
|---|
| 1216 | 1223 | { |
|---|
| 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 | |
|---|
| 1226 | 1230 | TAB_APPEND( media->i_instance, media->instance, p_instance ); |
|---|
| 1227 | 1231 | } |
|---|
| raf518b8 |
rd7bc817 |
|
| 35 | 35 | |
|---|
| 36 | 36 | #include <vlc_sout.h> |
|---|
| | 37 | #include <vlc_playlist.h> |
|---|
| 37 | 38 | |
|---|
| 38 | 39 | #include "stream_output.h" |
|---|
| … | … | |
| 75 | 76 | vlc_value_t keep; |
|---|
| 76 | 77 | |
|---|
| 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 ) |
|---|
| 86 | 99 | { |
|---|
| 87 | 100 | if( !strcmp( p_sout->psz_sout, psz_dest ) ) |
|---|
| … | … | |
| 90 | 103 | msg_Dbg( p_parent, "sout keep: you probably want to use " |
|---|
| 91 | 104 | "gather stream_out" ); |
|---|
| 92 | | vlc_object_detach( p_sout ); |
|---|
| 93 | 105 | vlc_object_attach( p_sout, p_parent ); |
|---|
| 94 | 106 | vlc_object_release( p_sout ); |
|---|
| 95 | 107 | return p_sout; |
|---|
| 96 | 108 | } |
|---|
| 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" ); |
|---|
| 111 | 111 | vlc_object_release( p_sout ); |
|---|
| 112 | 112 | sout_DeleteInstance( p_sout ); |
|---|