@@ -62,13 +62,17 @@ void gf_filter_pid_inst_del(GF_FilterPidInst *pidinst)
6262 gf_list_del (pidinst -> pck_reassembly );
6363 if (pidinst -> props ) {
6464 assert (pidinst -> props -> reference_count );
65- if (safe_int_dec (& pidinst -> props -> reference_count ) == 0 ) {
66- //see \ref gf_filter_pid_merge_properties_internal for mutex
67- gf_mx_p (pidinst -> pid -> filter -> tasks_mx );
68- gf_list_del_item (pidinst -> pid -> properties , pidinst -> props );
69- gf_mx_v (pidinst -> pid -> filter -> tasks_mx );
70- gf_props_del (pidinst -> props );
65+ gf_mx_p (pidinst -> pid -> filter -> tasks_mx );
66+ //not in parent pid, may happen when reattaching a pid inst to a different pid
67+ //in this case do NOT delete the props
68+ if (gf_list_find (pidinst -> pid -> properties , pidinst -> props )>=0 ) {
69+ if (safe_int_dec (& pidinst -> props -> reference_count ) == 0 ) {
70+ //see \ref gf_filter_pid_merge_properties_internal for mutex
71+ gf_list_del_item (pidinst -> pid -> properties , pidinst -> props );
72+ gf_props_del (pidinst -> props );
73+ }
7174 }
75+ gf_mx_v (pidinst -> pid -> filter -> tasks_mx );
7276 }
7377 gf_free (pidinst );
7478}
@@ -1044,8 +1048,15 @@ static GF_Err gf_filter_pid_configure(GF_Filter *filter, GF_FilterPid *pid, GF_P
10441048 if (!target -> detached_pid_inst ) {
10451049 target -> detached_pid_inst = gf_list_new ();
10461050 }
1047- //detach props but don't delete them
1051+ //detach props
10481052 if (filter -> swap_pidinst_dst -> props ) {
1053+ GF_FilterPidInst * swap_pidi = filter -> swap_pidinst_dst ;
1054+ if (safe_int_dec (& swap_pidi -> props -> reference_count )== 0 ) {
1055+ gf_mx_p (swap_pidi -> pid -> filter -> tasks_mx );
1056+ gf_list_del_item (swap_pidi -> pid -> properties , pidinst -> props );
1057+ gf_mx_v (swap_pidi -> pid -> filter -> tasks_mx );
1058+ gf_props_del (pidinst -> props );
1059+ }
10491060 filter -> swap_pidinst_dst -> props = NULL ;
10501061 }
10511062 filter -> swap_pidinst_dst -> pid = NULL ;
@@ -1308,7 +1319,7 @@ void gf_filter_pid_detach_task(GF_FSTask *task)
13081319 //first connection of this PID to this filter
13091320 if (!pidinst ) {
13101321 GF_LOG (GF_LOG_ERROR , GF_LOG_FILTER , ("Trying to detach PID %s not present in filter %s inputs\n" , pid -> name , filter -> name ));
1311- //assert(!new_chain_input-> swap_pidinst_dst);
1322+ //when swaping encoder, we may have swap_pidinst_dst not NULL so only check swap_pidinst_src
13121323 assert (!new_chain_input -> swap_pidinst_src );
13131324 new_chain_input -> swap_needs_init = GF_FALSE ;
13141325 return ;
@@ -5943,7 +5954,7 @@ static GF_Err gf_filter_pid_merge_properties_internal(GF_FilterPid *dst_pid, GF_
59435954 }
59445955 src_props = pidi -> props ;
59455956 }
5946- //move to rela pid
5957+ //move to real pid
59475958 src_pid = src_pid -> pid ;
59485959 //this is a copy props on output pid
59495960 if (!src_props ) {
0 commit comments