Commit 2d3fb64a authored by Jean-Paul Saman's avatar Jean-Paul Saman

demux: use new utility functions.

Use new utility functions to replace common code blocks. Moving
code to demux.c instead of repeating them in the subtable functions.
This reduces the amount of code in subtable files and reduces the risk
of introducing errors in future for this code.
parent 7beb890c
...@@ -92,8 +92,6 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -92,8 +92,6 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_atsc_eit_decoder_t* p_eit_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -103,26 +101,22 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -103,26 +101,22 @@ bool dvbpsi_atsc_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); dvbpsi_atsc_eit_decoder_t* p_eit_decoder;
if (p_subdec == NULL)
return false;
p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)malloc(sizeof(dvbpsi_atsc_eit_decoder_t)); p_eit_decoder = (dvbpsi_atsc_eit_decoder_t*)malloc(sizeof(dvbpsi_atsc_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
return false;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_atsc_DetachEIT,
dvbpsi_atsc_GatherEITSections, p_eit_decoder);
if (p_subdec == NULL)
{ {
free(p_subdec); free(p_eit_decoder);
return false; return false;
} }
/* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_atsc_GatherEITSections;
p_subdec->p_cb_data = p_eit_decoder;
p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension;
p_subdec->pf_detach = dvbpsi_atsc_DetachEIT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* EIT decoder information */ /* EIT decoder information */
p_eit_decoder->pf_eit_callback = pf_callback; p_eit_decoder->pf_eit_callback = pf_callback;
...@@ -148,8 +142,6 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -148,8 +142,6 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -175,13 +167,10 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -175,13 +167,10 @@ void dvbpsi_atsc_DetachEIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -99,8 +99,6 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -99,8 +99,6 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_atsc_ett_decoder_t* p_ett_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -110,26 +108,23 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e ...@@ -110,26 +108,23 @@ bool dvbpsi_atsc_AttachETT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, uint16_t i_e
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); dvbpsi_atsc_ett_decoder_t* p_ett_decoder;
if(p_subdec == NULL) p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)malloc(sizeof(dvbpsi_atsc_ett_decoder_t));
if (p_ett_decoder == NULL)
return false; return false;
p_ett_decoder = (dvbpsi_atsc_ett_decoder_t*)malloc(sizeof(dvbpsi_atsc_ett_decoder_t)); /* PSI decoder configuration */
if(p_ett_decoder == NULL) dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_atsc_DetachETT,
dvbpsi_atsc_GatherETTSections, p_ett_decoder);
if (p_subdec == NULL)
{ {
free(p_subdec); free(p_ett_decoder);
return false; return false;
} }
/* PSI decoder configuration */
p_subdec->pf_gather = &dvbpsi_atsc_GatherETTSections;
p_subdec->p_cb_data = p_ett_decoder;
p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension;
p_subdec->pf_detach = dvbpsi_atsc_DetachETT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* ETT decoder information */ /* ETT decoder information */
p_ett_decoder->pf_ett_callback = pf_callback; p_ett_decoder->pf_ett_callback = pf_callback;
...@@ -150,9 +145,7 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -150,9 +145,7 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -176,13 +169,10 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -176,13 +169,10 @@ void dvbpsi_atsc_DetachETT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -96,7 +96,6 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -96,7 +96,6 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t *p_subdec;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -106,27 +105,22 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -106,27 +105,22 @@ bool dvbpsi_atsc_AttachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t));
if (p_subdec == NULL)
return false;
dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder; dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder;
p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)malloc(sizeof(dvbpsi_atsc_mgt_decoder_t)); p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)malloc(sizeof(dvbpsi_atsc_mgt_decoder_t));
if(p_mgt_decoder == NULL) if(p_mgt_decoder == NULL)
return false;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_atsc_DetachMGT,
dvbpsi_atsc_GatherMGTSections, p_mgt_decoder);
if (p_subdec == NULL)
{ {
free(p_subdec); free(p_mgt_decoder);
return false; return false;
} }
/* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_atsc_GatherMGTSections;
p_subdec->p_cb_data = p_mgt_decoder;
p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension;
p_subdec->pf_detach = dvbpsi_atsc_DetachMGT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* MGT decoder information */ /* MGT decoder information */
p_mgt_decoder->pf_mgt_callback = pf_callback; p_mgt_decoder->pf_mgt_callback = pf_callback;
...@@ -150,10 +144,9 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -150,10 +144,9 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -166,28 +159,23 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -166,28 +159,23 @@ void dvbpsi_atsc_DetachMGT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder; dvbpsi_atsc_mgt_decoder_t* p_mgt_decoder;
p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_subdec->p_cb_data; p_mgt_decoder = (dvbpsi_atsc_mgt_decoder_t*)p_subdec->p_cb_data;
if(!p_mgt_decoder) if (!p_mgt_decoder)
return; return;
if (p_mgt_decoder->p_building_mgt) if (p_mgt_decoder->p_building_mgt)
{
free(p_mgt_decoder->p_building_mgt); free(p_mgt_decoder->p_building_mgt);
}
for (unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if(p_mgt_decoder->ap_sections[i]) if (p_mgt_decoder->ap_sections[i])
dvbpsi_DeletePSISections(p_mgt_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_mgt_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -68,15 +68,13 @@ static void dvbpsi_atsc_DecodeSTTSections(dvbpsi_atsc_stt_t* p_stt, ...@@ -68,15 +68,13 @@ static void dvbpsi_atsc_DecodeSTTSections(dvbpsi_atsc_stt_t* p_stt,
***************************************************************************** *****************************************************************************
* Initialize a STT subtable decoder. * Initialize a STT subtable decoder.
*****************************************************************************/ *****************************************************************************/
bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data) dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data)
{ {
assert(p_dvbpsi); assert(p_dvbpsi);
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_atsc_stt_decoder_t* p_stt_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0))
{ {
...@@ -86,26 +84,23 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -86,26 +84,23 @@ bool dvbpsi_atsc_AttachSTT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); dvbpsi_atsc_stt_decoder_t* p_stt_decoder;
if(p_subdec == NULL) p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)malloc(sizeof(dvbpsi_atsc_stt_decoder_t));
if (p_stt_decoder == NULL)
return false; return false;
p_stt_decoder = (dvbpsi_atsc_stt_decoder_t*)malloc(sizeof(dvbpsi_atsc_stt_decoder_t)); /* subtable decoder configuration */
if(p_stt_decoder == NULL) dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_atsc_DetachSTT,
dvbpsi_atsc_GatherSTTSections, p_stt_decoder);
if (p_subdec == NULL)
{ {
free(p_subdec); free(p_stt_decoder);
return false; return false;
} }
/* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_atsc_GatherSTTSections;
p_subdec->p_cb_data = p_stt_decoder;
p_subdec->i_id = (uint32_t)i_table_id << 16;
p_subdec->pf_detach = dvbpsi_atsc_DetachSTT;
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* STT decoder information */ /* STT decoder information */
p_stt_decoder->pf_stt_callback = pf_stt_callback; p_stt_decoder->pf_stt_callback = pf_stt_callback;
...@@ -125,10 +120,10 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -125,10 +120,10 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, 0); i_extension = 0;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
dvbpsi_error(p_dvbpsi, "STT Decoder", dvbpsi_error(p_dvbpsi, "STT Decoder",
...@@ -144,13 +139,10 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -144,13 +139,10 @@ void dvbpsi_atsc_DetachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return; return;
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -71,11 +71,12 @@ typedef void (* dvbpsi_atsc_stt_callback)(void* p_cb_data, dvbpsi_atsc_stt_t* p_ ...@@ -71,11 +71,12 @@ typedef void (* dvbpsi_atsc_stt_callback)(void* p_cb_data, dvbpsi_atsc_stt_t* p_
* \brief Creation and initialization of a STT decoder. * \brief Creation and initialization of a STT decoder.
* \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached * \param p_dvbpsi dvbpsi handle to Subtable demultiplexor to which the decoder is attached
* \param i_table_id Table ID, 0xCD. * \param i_table_id Table ID, 0xCD.
* \param i_extension Table ID extension, here it should be 0.
* \param pf_stt_callback function to call back on new STT. * \param pf_stt_callback function to call back on new STT.
* \param p_cb_data private data given in argument to the callback. * \param p_cb_data private data given in argument to the callback.
* \return true if everything went ok else false * \return true if everything went ok else false
*/ */
bool dvbpsi_atsc_AttachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, bool dvbpsi_atsc_AttachSTT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extension,
dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data); dvbpsi_atsc_stt_callback pf_stt_callback, void* p_cb_data);
/***************************************************************************** /*****************************************************************************
......
...@@ -104,8 +104,6 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -104,8 +104,6 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_atsc_vct_decoder_t* p_vct_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -116,26 +114,23 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -116,26 +114,23 @@ bool dvbpsi_atsc_AttachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_atsc_vct_decoder_t* p_vct_decoder;
if (p_subdec == NULL)
return false;
p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)calloc(1, sizeof(dvbpsi_atsc_vct_decoder_t)); p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)calloc(1, sizeof(dvbpsi_atsc_vct_decoder_t));
if (p_vct_decoder == NULL) if (p_vct_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_atsc_GatherVCTSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_vct_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_atsc_DetachVCT,
p_subdec->i_id = ((uint32_t)i_table_id << 16) | i_extension; dvbpsi_atsc_GatherVCTSections, p_vct_decoder);
p_subdec->pf_detach = dvbpsi_atsc_DetachVCT; if (p_subdec == NULL)
{
free(p_vct_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* VCT decoder information */ /* VCT decoder information */
p_vct_decoder->pf_vct_callback = pf_vct_callback; p_vct_decoder->pf_vct_callback = pf_vct_callback;
...@@ -161,10 +156,8 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -161,10 +156,8 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_atsc_vct_decoder_t* p_vct_decoder;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_subdec == NULL) if(p_subdec == NULL)
{ {
...@@ -175,25 +168,22 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex ...@@ -175,25 +168,22 @@ void dvbpsi_atsc_DetachVCT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_ex
return; return;
} }
dvbpsi_atsc_vct_decoder_t* p_vct_decoder;
p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_subdec->p_cb_data; p_vct_decoder = (dvbpsi_atsc_vct_decoder_t*)p_subdec->p_cb_data;
if(!p_vct_decoder) if (!p_vct_decoder)
return; return;
free(p_vct_decoder->p_building_vct); free(p_vct_decoder->p_building_vct);
for(unsigned int i = 0; i < 256; i++) for (unsigned int i = 0; i < 256; i++)
{ {
if (p_vct_decoder->ap_sections[i]) if (p_vct_decoder->ap_sections[i])
dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_vct_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = NULL;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -62,8 +62,6 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -62,8 +62,6 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_bat_decoder_t* p_bat_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -74,26 +72,23 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -74,26 +72,23 @@ bool dvbpsi_AttachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_bat_decoder_t* p_bat_decoder;
if (p_subdec == NULL)
return false;
p_bat_decoder = (dvbpsi_bat_decoder_t*)calloc(1, sizeof(dvbpsi_bat_decoder_t)); p_bat_decoder = (dvbpsi_bat_decoder_t*)calloc(1, sizeof(dvbpsi_bat_decoder_t));
if (p_bat_decoder == NULL) if (p_bat_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherBATSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_bat_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachBAT,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; dvbpsi_GatherBATSections, p_bat_decoder);
p_subdec->pf_detach = dvbpsi_DetachBAT; if (p_subdec == NULL)
{
free(p_bat_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* BAT decoder information */ /* BAT decoder information */
p_bat_decoder->pf_bat_callback = pf_callback; p_bat_decoder->pf_bat_callback = pf_callback;
...@@ -119,10 +114,8 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -119,10 +114,8 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_bat_decoder_t* p_bat_decoder;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -133,6 +126,7 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -133,6 +126,7 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return; return;
} }
dvbpsi_bat_decoder_t* p_bat_decoder;
p_bat_decoder = (dvbpsi_bat_decoder_t*)p_subdec->p_cb_data; p_bat_decoder = (dvbpsi_bat_decoder_t*)p_subdec->p_cb_data;
free(p_bat_decoder->p_building_bat); free(p_bat_decoder->p_building_bat);
...@@ -142,14 +136,10 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -142,14 +136,10 @@ void dvbpsi_DetachBAT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_bat_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = NULL;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -61,8 +61,6 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -61,8 +61,6 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_eit_decoder_t* p_eit_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension) != NULL) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension) != NULL)
{ {
...@@ -73,26 +71,23 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -73,26 +71,23 @@ bool dvbpsi_AttachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_eit_decoder_t* p_eit_decoder;
if (p_subdec == NULL)
return false;
p_eit_decoder = (dvbpsi_eit_decoder_t*)calloc(1, sizeof(dvbpsi_eit_decoder_t)); p_eit_decoder = (dvbpsi_eit_decoder_t*)calloc(1, sizeof(dvbpsi_eit_decoder_t));
if (p_eit_decoder == NULL) if (p_eit_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherEITSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_eit_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachEIT,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; dvbpsi_GatherEITSections, p_eit_decoder);
p_subdec->pf_detach = dvbpsi_DetachEIT; if (p_subdec == NULL)
{
free(p_eit_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* EIT decoder information */ /* EIT decoder information */
p_eit_decoder->pf_eit_callback = pf_callback; p_eit_decoder->pf_eit_callback = pf_callback;
...@@ -118,10 +113,8 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -118,10 +113,8 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_eit_decoder_t* p_eit_decoder;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -132,6 +125,7 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -132,6 +125,7 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
return; return;
} }
dvbpsi_eit_decoder_t* p_eit_decoder;
p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_cb_data; p_eit_decoder = (dvbpsi_eit_decoder_t*)p_subdec->p_cb_data;
free(p_eit_decoder->p_building_eit); free(p_eit_decoder->p_building_eit);
...@@ -141,14 +135,10 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -141,14 +135,10 @@ void dvbpsi_DetachEIT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_eit_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
while(*pp_prev_subdec != p_subdec) dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = NULL;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -63,8 +63,6 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -63,8 +63,6 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_nit_decoder_t* p_nit_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -75,26 +73,23 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -75,26 +73,23 @@ bool dvbpsi_AttachNIT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_nit_decoder_t* p_nit_decoder;
if (p_subdec == NULL)
return false;
p_nit_decoder = (dvbpsi_nit_decoder_t*)calloc(1, sizeof(dvbpsi_nit_decoder_t)); p_nit_decoder = (dvbpsi_nit_decoder_t*)calloc(1, sizeof(dvbpsi_nit_decoder_t));
if (p_nit_decoder == NULL) if (p_nit_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherNITSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_nit_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachNIT,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; dvbpsi_GatherNITSections, p_nit_decoder);
p_subdec->pf_detach = dvbpsi_DetachNIT; if (p_subdec == NULL)
{
free(p_nit_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* NIT decoder information */ /* NIT decoder information */
p_nit_decoder->i_network_id = i_extension; p_nit_decoder->i_network_id = i_extension;
...@@ -118,10 +113,8 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -118,10 +113,8 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
uint16_t i_extension) uint16_t i_extension)
{ {
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_nit_decoder_t* p_nit_decoder;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if(p_demux == NULL) if(p_demux == NULL)
{ {
...@@ -132,6 +125,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -132,6 +125,7 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
return; return;
} }
dvbpsi_nit_decoder_t* p_nit_decoder;
p_nit_decoder = (dvbpsi_nit_decoder_t*)p_subdec->p_cb_data; p_nit_decoder = (dvbpsi_nit_decoder_t*)p_subdec->p_cb_data;
free(p_nit_decoder->p_building_nit); free(p_nit_decoder->p_building_nit);
...@@ -141,14 +135,11 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id, ...@@ -141,14 +135,11 @@ void dvbpsi_DetachNIT(dvbpsi_t * p_dvbpsi, uint8_t i_table_id,
dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[i]); dvbpsi_DeletePSISections(p_nit_decoder->ap_sections[i]);
} }
free(p_subdec->p_cb_data); free(p_subdec->p_cb_data);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec; /* Free demux sub table decoder */
while(*pp_prev_subdec != p_subdec) dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
pp_prev_subdec = &(*pp_prev_subdec)->p_next; dvbpsi_DeleteDemuxSubDecoder(p_subdec);
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = NULL;
} }
/**************************************************************************** /****************************************************************************
......
...@@ -60,8 +60,6 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -60,8 +60,6 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_sdt_decoder_t* p_sdt_decoder;
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
{ {
...@@ -72,26 +70,23 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -72,26 +70,23 @@ bool dvbpsi_AttachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_sdt_decoder_t* p_sdt_decoder;
if(p_subdec == NULL)
return false;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)calloc(1, sizeof(dvbpsi_sdt_decoder_t)); p_sdt_decoder = (dvbpsi_sdt_decoder_t*)calloc(1, sizeof(dvbpsi_sdt_decoder_t));
if (p_sdt_decoder == NULL) if (p_sdt_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherSDTSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_sdt_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachSDT,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; dvbpsi_GatherSDTSections, p_sdt_decoder);
p_subdec->pf_detach = &dvbpsi_DetachSDT; if (p_subdec == NULL)
{
free(p_sdt_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* SDT decoder information */ /* SDT decoder information */
p_sdt_decoder->pf_sdt_callback = pf_callback; p_sdt_decoder->pf_sdt_callback = pf_callback;
...@@ -117,10 +112,8 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -117,10 +112,8 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
dvbpsi_sdt_decoder_t* p_sdt_decoder;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_subdec == NULL) if (p_subdec == NULL)
{ {
...@@ -131,6 +124,9 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -131,6 +124,9 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return; return;
} }
assert(p_subdec->p_cb_data);
dvbpsi_sdt_decoder_t* p_sdt_decoder;
p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_cb_data; p_sdt_decoder = (dvbpsi_sdt_decoder_t*)p_subdec->p_cb_data;
free(p_sdt_decoder->p_building_sdt); free(p_sdt_decoder->p_building_sdt);
...@@ -142,15 +138,10 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -142,15 +138,10 @@ void dvbpsi_DetachSDT(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
p_sdt_decoder->ap_sections[i] = NULL; p_sdt_decoder->ap_sections[i] = NULL;
} }
} }
free(p_subdec->p_cb_data);
pp_prev_subdec = &p_demux->p_first_subdec;
while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next; /* Free sub table decoder */
free(p_subdec); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
p_subdec = NULL; dvbpsi_DeleteDemuxSubDecoder(p_subdec);
} }
/***************************************************************************** /*****************************************************************************
...@@ -228,7 +219,7 @@ dvbpsi_sdt_service_t *dvbpsi_SDTAddService(dvbpsi_sdt_t* p_sdt, ...@@ -228,7 +219,7 @@ dvbpsi_sdt_service_t *dvbpsi_SDTAddService(dvbpsi_sdt_t* p_sdt,
bool b_free_ca) bool b_free_ca)
{ {
dvbpsi_sdt_service_t * p_service; dvbpsi_sdt_service_t * p_service;
p_service = (dvbpsi_sdt_service_t*)malloc(sizeof(dvbpsi_sdt_service_t)); p_service = (dvbpsi_sdt_service_t*)calloc(1, sizeof(dvbpsi_sdt_service_t));
if (p_service == NULL) if (p_service == NULL)
return NULL; return NULL;
......
...@@ -60,8 +60,6 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -60,8 +60,6 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_sis_decoder_t* p_sis_decoder;
i_extension = 0; i_extension = 0;
...@@ -74,26 +72,23 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -74,26 +72,23 @@ bool dvbpsi_AttachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)malloc(sizeof(dvbpsi_demux_subdec_t)); dvbpsi_sis_decoder_t* p_sis_decoder;
if (p_subdec == NULL)
return false;
p_sis_decoder = (dvbpsi_sis_decoder_t*)malloc(sizeof(dvbpsi_sis_decoder_t)); p_sis_decoder = (dvbpsi_sis_decoder_t*)malloc(sizeof(dvbpsi_sis_decoder_t));
if (p_sis_decoder == NULL) if (p_sis_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherSISSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_sis_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachSIS,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)i_extension; dvbpsi_GatherSISSections, p_sis_decoder);
p_subdec->pf_detach = dvbpsi_DetachSIS; if (p_subdec == NULL)
{
free(p_sis_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* SIS decoder information */ /* SIS decoder information */
p_sis_decoder->pf_sis_callback = pf_callback; p_sis_decoder->pf_sis_callback = pf_callback;
...@@ -114,11 +109,9 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -114,11 +109,9 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *) p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
i_extension = 0; i_extension = 0;
dvbpsi_demux_subdec_t* p_subdec;
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
if (p_demux == NULL) if (p_demux == NULL)
{ {
...@@ -129,18 +122,8 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id, ...@@ -129,18 +122,8 @@ void dvbpsi_DetachSIS(dvbpsi_t *p_dvbpsi, uint8_t i_table_id,
return; return;
} }
dvbpsi_sis_decoder_t* p_sis_decoder; dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
p_sis_decoder = (dvbpsi_sis_decoder_t*)p_subdec->p_cb_data; dvbpsi_DeleteDemuxSubDecoder(p_subdec);
free(p_sis_decoder);
p_subdec->p_cb_data = NULL;
pp_prev_subdec = &p_demux->p_first_subdec;
while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = NULL;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -62,8 +62,6 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -62,8 +62,6 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
assert(p_dvbpsi->p_private); assert(p_dvbpsi->p_private);
dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private; dvbpsi_demux_t* p_demux = (dvbpsi_demux_t*)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_tot_decoder_t* p_tot_decoder;
i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */ i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */
if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension)) if (dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension))
...@@ -75,26 +73,23 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi ...@@ -75,26 +73,23 @@ bool dvbpsi_AttachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, uint16_t i_extensi
return false; return false;
} }
p_subdec = (dvbpsi_demux_subdec_t*)calloc(1, sizeof(dvbpsi_demux_subdec_t)); dvbpsi_tot_decoder_t* p_tot_decoder;
if(p_subdec == NULL)
return false;
p_tot_decoder = (dvbpsi_tot_decoder_t*)calloc(1, sizeof(dvbpsi_tot_decoder_t)); p_tot_decoder = (dvbpsi_tot_decoder_t*)calloc(1, sizeof(dvbpsi_tot_decoder_t));
if (p_tot_decoder == NULL) if (p_tot_decoder == NULL)
{
free(p_subdec);
return false; return false;
}
/* subtable decoder configuration */ /* subtable decoder configuration */
p_subdec->pf_gather = &dvbpsi_GatherTOTSections; dvbpsi_demux_subdec_t* p_subdec;
p_subdec->p_cb_data = p_tot_decoder; p_subdec = dvbpsi_NewDemuxSubDecoder(i_table_id, i_extension, dvbpsi_DetachTOT,
p_subdec->i_id = (uint32_t)i_table_id << 16 | (uint32_t)0; dvbpsi_GatherTOTSections, p_tot_decoder);
p_subdec->pf_detach = dvbpsi_DetachTOT; if (p_subdec == NULL)
{
free(p_tot_decoder);
return false;
}
/* Attach the subtable decoder to the demux */ /* Attach the subtable decoder to the demux */
p_subdec->p_next = p_demux->p_first_subdec; dvbpsi_AttachDemuxSubDecoder(p_demux, p_subdec);
p_demux->p_first_subdec = p_subdec;
/* TDT/TOT decoder information */ /* TDT/TOT decoder information */
p_tot_decoder->pf_tot_callback = pf_callback; p_tot_decoder->pf_tot_callback = pf_callback;
...@@ -116,7 +111,6 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -116,7 +111,6 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private; dvbpsi_demux_t *p_demux = (dvbpsi_demux_t *)p_dvbpsi->p_private;
dvbpsi_demux_subdec_t* p_subdec; dvbpsi_demux_subdec_t* p_subdec;
dvbpsi_demux_subdec_t** pp_prev_subdec;
i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */ i_extension = 0; /* NOTE: force to 0 when handling TDT/TOT */
p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension); p_subdec = dvbpsi_demuxGetSubDec(p_demux, i_table_id, i_extension);
...@@ -129,15 +123,8 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id, ...@@ -129,15 +123,8 @@ void dvbpsi_DetachTOT(dvbpsi_t* p_dvbpsi, uint8_t i_table_id,
return; return;
} }
free(p_subdec->p_cb_data); dvbpsi_DetachDemuxSubDecoder(p_demux, p_subdec);
dvbpsi_DeleteDemuxSubDecoder(p_subdec);
pp_prev_subdec = &p_demux->p_first_subdec;
while(*pp_prev_subdec != p_subdec)
pp_prev_subdec = &(*pp_prev_subdec)->p_next;
*pp_prev_subdec = p_subdec->p_next;
free(p_subdec);
p_subdec = 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