Commit 3f0c670d authored by Jean-Paul Saman's avatar Jean-Paul Saman

decoder chain: rename dvbpsi_decoder_chain_new/delete to dvbpsi_chain_demux_new/delete

parent 66db4ffa
......@@ -253,7 +253,7 @@ int main(int i_argc, char* pa_argv[])
p_dvbpsi = dvbpsi_new(&message, DVBPSI_MSG_DEBUG);
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_decoder_chain_new(p_dvbpsi, NewSubtableBAT, DelSubtableBAT, NULL))
if (!dvbpsi_chain_demux_new(p_dvbpsi, NewSubtableBAT, DelSubtableBAT, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -271,7 +271,7 @@ int main(int i_argc, char* pa_argv[])
out:
if (p_dvbpsi)
{
if (!dvbpsi_decoder_chain_delete(p_dvbpsi))
if (!dvbpsi_chain_demux_delete(p_dvbpsi))
ret = 1;
dvbpsi_delete(p_dvbpsi);
}
......
......@@ -148,7 +148,7 @@ int main(int i_argc, char* pa_argv[])
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_decoder_chain_new(p_dvbpsi, AttachPAT, DetachPAT, NULL))
if (!dvbpsi_chain_demux_new(p_dvbpsi, AttachPAT, DetachPAT, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -165,7 +165,7 @@ int main(int i_argc, char* pa_argv[])
out:
if (p_dvbpsi)
{
if (!dvbpsi_decoder_chain_delete(p_dvbpsi))
if (!dvbpsi_chain_demux_delete(p_dvbpsi))
ret = 1;
dvbpsi_delete(p_dvbpsi);
}
......
......@@ -184,7 +184,7 @@ int main(int i_argc, char* pa_argv[])
if (p_dvbpsi == NULL)
goto out;
if (!dvbpsi_decoder_chain_new(p_dvbpsi, NewSubtable, DelSubtable, NULL))
if (!dvbpsi_chain_demux_new(p_dvbpsi, NewSubtable, DelSubtable, NULL))
goto out;
b_ok = ReadPacket(i_fd, data);
......@@ -202,7 +202,7 @@ int main(int i_argc, char* pa_argv[])
out:
if (p_dvbpsi)
{
if (!dvbpsi_decoder_chain_delete(p_dvbpsi))
if (!dvbpsi_chain_demux_delete(p_dvbpsi))
ret = 1;
dvbpsi_delete(p_dvbpsi);
}
......
......@@ -1950,7 +1950,7 @@ static void handle_atsc_MGT(void *p_data, dvbpsi_atsc_mgt_t *p_mgt)
p->pid->i_pid = p_table->i_table_type_pid;
p->p_next = NULL;
if (!dvbpsi_decoder_chain_new(p->handle, handle_subtable, DeleteTableDecoder, p_stream))
if (!dvbpsi_chain_demux_new(p->handle, handle_subtable, DeleteTableDecoder, p_stream))
{
fprintf(stderr, "dvbinfo: Failed to attach new ATSC EIT decoder\n");
dvbpsi_delete(p->handle);
......@@ -2416,7 +2416,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->pat.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->pat.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->pat.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->pat.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->pat.handle);
stream->pat.handle = NULL;
......@@ -2426,7 +2426,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->cat.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->cat.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->cat.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->cat.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->cat.handle);
stream->cat.handle = NULL;
......@@ -2436,7 +2436,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->sdt.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->sdt.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->sdt.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->sdt.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->sdt.handle);
stream->sdt.handle = NULL;
......@@ -2446,7 +2446,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->rst.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->rst.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->rst.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->rst.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->rst.handle);
stream->rst.handle = NULL;
......@@ -2456,7 +2456,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->eit.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->eit.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->eit.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->eit.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->eit.handle);
stream->eit.handle = NULL;
......@@ -2466,7 +2466,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->tdt.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->tdt.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->tdt.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->tdt.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->tdt.handle);
stream->tdt.handle = NULL;
......@@ -2477,7 +2477,7 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
stream->atsc.handle = dvbpsi_new(&dvbpsi_message, stream->level);
if (stream->atsc.handle == NULL)
goto error;
if (!dvbpsi_decoder_chain_new(stream->atsc.handle, handle_subtable, DeleteTableDecoder, stream))
if (!dvbpsi_chain_demux_new(stream->atsc.handle, handle_subtable, DeleteTableDecoder, stream))
{
dvbpsi_delete(stream->atsc.handle);
stream->atsc.handle = NULL;
......@@ -2499,19 +2499,19 @@ ts_stream_t *libdvbpsi_init(int debug, ts_stream_log_cb pf_log, void *cb_data)
return stream;
error:
if (dvbpsi_decoder_chain_delete(stream->pat.handle))
if (dvbpsi_chain_demux_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->cat.handle))
if (dvbpsi_chain_demux_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->sdt.handle))
if (dvbpsi_chain_demux_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->eit.handle))
if (dvbpsi_chain_demux_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->rst.handle))
if (dvbpsi_chain_demux_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->tdt.handle))
if (dvbpsi_chain_demux_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (dvbpsi_decoder_chain_delete(stream->atsc.handle))
if (dvbpsi_chain_demux_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle)
......@@ -2538,7 +2538,7 @@ void libdvbpsi_exit(ts_stream_t *stream)
{
summary(stdout, stream);
if (!dvbpsi_decoder_chain_delete(stream->pat.handle))
if (!dvbpsi_chain_demux_delete(stream->pat.handle))
fprintf(stderr, "dvbinfo: failed to delete PAT decoder chain! .. possibly leaking memory!!\n");
ts_pmt_t *p_pmt = stream->pmt;
......@@ -2546,7 +2546,7 @@ void libdvbpsi_exit(ts_stream_t *stream)
while (p_pmt)
{
dvbpsi_t *handle = p_pmt->handle;
if (!dvbpsi_decoder_chain_delete(handle))
if (!dvbpsi_chain_demux_delete(handle))
fprintf(stderr, "dvbinfo: failed to delete PMT decoder chain! .. possibly leaking memory!!\n");
dvbpsi_delete(p_pmt->handle);
......@@ -2563,7 +2563,7 @@ void libdvbpsi_exit(ts_stream_t *stream)
while (p_atsc_eit)
{
dvbpsi_t *handle = p_atsc_eit->handle;
if (!dvbpsi_decoder_chain_delete(handle))
if (!dvbpsi_chain_demux_delete(handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
dvbpsi_delete(p_atsc_eit->handle);
......@@ -2575,17 +2575,17 @@ void libdvbpsi_exit(ts_stream_t *stream)
free(p_atsc_prev);
}
if (!dvbpsi_decoder_chain_delete(stream->cat.handle))
if (!dvbpsi_chain_demux_delete(stream->cat.handle))
fprintf(stderr, "dvbinfo: failed to delete CAT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_decoder_chain_delete(stream->sdt.handle))
if (!dvbpsi_chain_demux_delete(stream->sdt.handle))
fprintf(stderr, "dvbinfo: failed to delete SDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_decoder_chain_delete(stream->eit.handle))
if (!dvbpsi_chain_demux_delete(stream->eit.handle))
fprintf(stderr, "dvbinfo: failed to delete EIT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_decoder_chain_delete(stream->rst.handle))
if (!dvbpsi_chain_demux_delete(stream->rst.handle))
fprintf(stderr, "dvbinfo: failed to delete RST decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_decoder_chain_delete(stream->tdt.handle))
if (!dvbpsi_chain_demux_delete(stream->tdt.handle))
fprintf(stderr, "dvbinfo: failed to delete TDT decoder chain! .. possibly leaking memory!!\n");
if (!dvbpsi_decoder_chain_delete(stream->atsc.handle))
if (!dvbpsi_chain_demux_delete(stream->atsc.handle))
fprintf(stderr, "dvbinfo: failed to delete ATSC decoder chain! .. possibly leaking memory!!\n");
if (stream->pat.handle)
......
......@@ -76,11 +76,11 @@ static void dvbpsi_decoder_chain_demux(dvbpsi_t *p_dvbpsi, dvbpsi_psi_section_t
}
/*****************************************************************************
* dvbpsi_decoder_chain_new
* dvbpsi_chain_demux_new
*****************************************************************************
* Create chain decoder
* Create chain demux decoder
*****************************************************************************/
bool dvbpsi_decoder_chain_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
dvbpsi_callback_del_t pf_del, void *p_data)
{
if (p_dvbpsi->p_decoder) {
......@@ -88,7 +88,6 @@ bool dvbpsi_decoder_chain_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
return false;
}
/* FIXME: We need an alternative for dvbpsi_Demux() !!!*/
dvbpsi_decoder_t *p_chain = (dvbpsi_decoder_t *)dvbpsi_decoder_new(&dvbpsi_decoder_chain_demux,
4096, true,
sizeof(dvbpsi_decoder_t));
......@@ -105,13 +104,14 @@ bool dvbpsi_decoder_chain_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
}
/*****************************************************************************
* dvbpsi_decoder_chain_delete
* dvbpsi_chain_demux_delete
*****************************************************************************
* Remove all decoders from list and free all resources.
*****************************************************************************/
bool dvbpsi_decoder_chain_delete(dvbpsi_t *p_dvbpsi)
bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi)
{
dvbpsi_decoder_t *p = p_dvbpsi->p_decoder;
dvbpsi_decoder_t *p_demux = p_dvbpsi->p_decoder;
dvbpsi_decoder_t *p = p_demux->p_next; /* First subtable decoder */
if (!p) return false;
while (p) {
......@@ -125,6 +125,9 @@ bool dvbpsi_decoder_chain_delete(dvbpsi_t *p_dvbpsi)
*/
else dvbpsi_decoder_delete(p_dec);
}
/* Delete demux decoder */
dvbpsi_decoder_delete(p_demux);
p_dvbpsi->p_decoder = NULL;
return true;
}
......@@ -185,6 +188,7 @@ bool dvbpsi_decoder_chain_remove(dvbpsi_t *p_dvbpsi, const dvbpsi_decoder_t *p_d
while (pp_prev) {
if ((p_decoder->i_table_id == (*pp_prev)->i_table_id) &&
(p_decoder->i_extension == (*pp_prev)->i_extension)) {
assert(*pp_prev == p_decoder);
*pp_prev = p_decoder->p_next;
/* NOTE: caller must call dvbpsi_decoder_delete(p_decoder) */
return true;
......
......@@ -40,12 +40,12 @@ extern "C" {
#endif
/*****************************************************************************
* dvbpsi_decoder_chain_new
* dvbpsi_chain_demux_new
*****************************************************************************/
/*!
* \fn bool dvbpsi_decoder_chain_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t *pf_new,
* \fn bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t *pf_new,
dvbpsi_callback_del_t *pf_del, void *p_data)
* \brief dvbpsi_decoder_chain_new creates a decoder for demuxing PSI tables and subtables.
* \brief dvbpsi_chain_demux_new creates a decoder for demuxing PSI tables and subtables.
* \param p_dvbpsi pointer to dvbpsi_t handle
* \param pf_new callback function for calling the specific PSI table/subtable attach function
* \param pf_del callback function for calling the specific PSI table/subtable detach function
......@@ -53,22 +53,22 @@ extern "C" {
* dvbpsi_xxx_attach() function
* \return true on success, false on failure
*/
bool dvbpsi_decoder_chain_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
bool dvbpsi_chain_demux_new(dvbpsi_t *p_dvbpsi, dvbpsi_callback_new_t pf_new,
dvbpsi_callback_del_t pf_del, void *p_data);
/*****************************************************************************
* dvbpsi_decoder_chain_delete
* dvbpsi_chain_demux_delete
*****************************************************************************/
/*!
* \fn bool dvbpsi_decoder_chain_delete(dvbpsi_t *p_dvbpsi)
* \brief dvbpsi_decoder_chain_delete walks the chain of PSI (sub-)table decoders
* \fn bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi)
* \brief dvbpsi_chain_demux_delete walks the chain of PSI (sub-)table decoders
* and removes them from the chain before calling its pf_detach callback. The pointers
* to the PSI (sub-)table decoders are no longer valid after this function has been called.
* Nor is the decoder chain list valid.
* \param p_dvbpsi pointer to dvbpsi_t handle
* \return true on success, false on failure
*/
bool dvbpsi_decoder_chain_delete(dvbpsi_t *p_dvbpsi);
bool dvbpsi_chain_demux_delete(dvbpsi_t *p_dvbpsi);
/*****************************************************************************
* dvbpsi_decoder_chain_add
......
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