Commit b92dd074 authored by Jean-Paul Saman's avatar Jean-Paul Saman

decoder chain: handle unused PSI tables in dvbpsi_chain_demux_delete()

If a dvbpsi_t handle was created but the attached PSI table demuxer was
never triggered because the table is not present in the stream, then the
function dvbpsi_chain_demux_delete() would not free its resources properly.
This caused dvbpsi_delete() on the dvbpsi_t handle to fail.

The function dvbpsi_chain_demux_delete() is changed to handle this situation
properly.
parent 48d5e912
......@@ -111,21 +111,26 @@ bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi)
{
dvbpsi_decoder_t *p_demux = p_dvbpsi->p_decoder;
dvbpsi_decoder_t *p = p_demux->p_next; /* First subtable decoder */
if (!p) return false;
if (!p_demux) return false;
/* Get first subtable decoder */
dvbpsi_decoder_t *p = p_demux->p_next;
if (!p) goto out;
/* Walk linked list */
/* FIXME: p->pf_del() calls eventually the dvbpsi_XXX_detach() function
* which walks the list again. This is a waste of time and needs improvement
* on the mechanism on how to create/delete and attach/detach a subtable decoder.
*/
while (p) {
dvbpsi_decoder_t *p_dec = p;
p = p_dec->p_next;
if (p_dec->pf_del)
p_dec->pf_del(p_dvbpsi, p_dec->i_table_id, p_dec->i_extension);
/* FIXME: p->pf_del() calls eventually the dvbpsi_XXX_detach() function
* which walks the list again. This is a waste of time and needs improvement
* on the mechanism on how to create/delete and attach/detach a subtable decoder.
*/
else dvbpsi_decoder_delete(p_dec);
}
out:
/* Delete demux decoder */
dvbpsi_decoder_delete(p_demux);
p_dvbpsi->p_decoder = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment