Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions pjmedia/src/pjmedia/splitcomb.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct splitcomb
struct reverse_port
{
pjmedia_port base;
pj_pool_t *pool;
struct splitcomb*parent;
unsigned ch_num;

Expand Down Expand Up @@ -323,7 +324,7 @@ PJ_DEF(pj_status_t) pjmedia_splitcomb_set_channel( pjmedia_port *splitcomb,
/*
* Create reverse phase port for the specified channel.
*/
PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool_,
pjmedia_port *splitcomb,
unsigned ch_num,
unsigned options,
Expand All @@ -336,25 +337,33 @@ PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
unsigned buf_options;
const pjmedia_audio_format_detail *sc_afd, *p_afd;
pjmedia_port *port;
pj_pool_t* pool;
pj_status_t status;

/* Sanity check */
PJ_ASSERT_RETURN(splitcomb, PJ_EINVAL);
PJ_UNUSED_ARG(pool);

/* Make sure this is really a splitcomb port */
PJ_ASSERT_RETURN(sc->base.info.signature == SIGNATURE, PJ_EINVAL);

/* Check the channel number */
PJ_ASSERT_RETURN(ch_num < PJMEDIA_PIA_CCNT(&sc->base.info), PJ_EINVAL);

/* Make sure that the channel has not been setup */
PJ_ASSERT_RETURN(sc->port_desc[ch_num].port==NULL, PJ_EINVALIDOP);

/* options is unused for now */
PJ_UNUSED_ARG(options);

sc_afd = pjmedia_format_get_audio_format_detail(&splitcomb->info.fmt, 1);

/* Create own pool */
pool = pj_pool_create(pool_->factory, "sc-revch", 500, 500, NULL);
PJ_ASSERT_RETURN(pool, PJ_ENOMEM);

/* Create the port */
rport = PJ_POOL_ZALLOC_T(sc->pool, struct reverse_port);
rport = PJ_POOL_ZALLOC_T(pool, struct reverse_port);
rport->pool = pool;
rport->parent = sc;
rport->ch_num = ch_num;

Expand Down Expand Up @@ -393,6 +402,7 @@ PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
buf_options,
&rport->buf[DIR_DOWNSTREAM].dbuf);
if (status != PJ_SUCCESS) {
rport_on_destroy(port);
return status;
}

Expand All @@ -405,7 +415,7 @@ PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
buf_options,
&rport->buf[DIR_UPSTREAM].dbuf);
if (status != PJ_SUCCESS) {
pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf);
rport_on_destroy(port);
return status;
}

Expand All @@ -419,9 +429,9 @@ PJ_DEF(pj_status_t) pjmedia_splitcomb_create_rev_channel( pj_pool_t *pool,
sc->port_desc[ch_num].reversed = PJ_TRUE;

/* Init group lock */
status = pjmedia_port_init_grp_lock(port, sc->pool, sc->base.grp_lock);
status = pjmedia_port_init_grp_lock(port, pool, sc->base.grp_lock);
if (status != PJ_SUCCESS) {
rport_on_destroy(&rport->base);
rport_on_destroy(port);
return status;
}

Expand Down Expand Up @@ -846,8 +856,13 @@ static pj_status_t rport_on_destroy(pjmedia_port *this_port)
{
struct reverse_port *rport = (struct reverse_port*) this_port;

pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf);
pjmedia_delay_buf_destroy(rport->buf[DIR_UPSTREAM].dbuf);
if (rport->buf[DIR_DOWNSTREAM].dbuf)
pjmedia_delay_buf_destroy(rport->buf[DIR_DOWNSTREAM].dbuf);

if (rport->buf[DIR_UPSTREAM].dbuf)
pjmedia_delay_buf_destroy(rport->buf[DIR_UPSTREAM].dbuf);

pj_pool_safe_release(&rport->pool);

return PJ_SUCCESS;
}
Expand Down