Bool gf_filter_all_sinks_done(GF_Filter *filter)
{
	u32 i, count;
	Bool res = GF_TRUE;
	if (!filter || filter->session->in_final_flush || (filter->session->run_status==GF_EOS)	)
		return GF_TRUE;

	gf_mx_p(filter->session->filters_mx);
	count = gf_list_count(filter->session->filters);
	for (i=0; i<count; i++) {
		u32 j;
		GF_Filter *f = gf_list_get(filter->session->filters, i);
		if (f->num_output_pids) continue;
		gf_mx_p(f->tasks_mx);
		for (j=0; j<f->num_input_pids; j++) {
			GF_FilterPidInst *pidi = gf_list_get(f->input_pids, j);
			if (pidi->pid->is_playing && !pidi->is_end_of_stream) {
				res = GF_FALSE;
				gf_mx_v(f->tasks_mx);
				goto exit;
			}
		}
		gf_mx_v(f->tasks_mx);
	}
exit:
	gf_mx_v(filter->session->filters_mx);
	return res;
}
Bool gf_filter_all_sinks_done(GF_Filter *filter)
{
	u32 i, count;
	Bool res = GF_TRUE;
	if (!filter || filter->session->in_final_flush || (filter->session->run_status==GF_EOS)	)
		return GF_TRUE;

	gf_mx_p(filter->session->filters_mx);
	count = gf_list_count(filter->session->filters);
	for (i=0; i<count; i++) {
		u32 j;
		GF_Filter *f = gf_list_get(filter->session->filters, i);
		if (f->num_output_pids) continue;
		gf_mx_p(f->tasks_mx);
		for (j=0; j<f->num_input_pids; j++) {
			GF_FilterPidInst *pidi = gf_list_get(f->input_pids, j);
			if (pidi->pid->is_playing && !pidi->is_end_of_stream) {
				res = GF_FALSE;
				gf_mx_v(f->tasks_mx);
				goto exit;
			}
		}
		gf_mx_v(f->tasks_mx);
	}
exit:
	gf_mx_v(filter->session->filters_mx);
	return res;
}