Skip to content

Commit

Permalink
Merge upstream/master into master
Browse files Browse the repository at this point in the history
  • Loading branch information
CI Bot committed Jan 19, 2025
2 parents 7cce0b6 + 11ad831 commit 9745995
Show file tree
Hide file tree
Showing 26 changed files with 206 additions and 74 deletions.
1 change: 1 addition & 0 deletions pjlib/src/pjlib-test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ int test_inner(int argc, char *argv[])

pj_log_set_level(3);
pj_log_set_decor(test_app.param_log_decor);
pj_bzero(&stat, sizeof(pj_test_stat));

rc = pj_init();
if (rc != 0) {
Expand Down
9 changes: 9 additions & 0 deletions pjmedia/include/pjmedia-audiodev/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ PJ_BEGIN_DECL
* @{
*/

/**
* This setting controls the maximum number of supported audio devices.
*
* Default: 64
*/
#ifndef PJMEDIA_AUD_DEV_MAX_DEVS
# define PJMEDIA_AUD_DEV_MAX_DEVS 64
#endif

/**
* This setting controls the buffer length of audio device name.
*
Expand Down
3 changes: 1 addition & 2 deletions pjmedia/include/pjmedia/audiodev.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ typedef pj_int32_t pjmedia_aud_dev_index;
#define PJMEDIA_AUD_INVALID_DEV -3

#define PJMEDIA_AUD_MAX_DRIVERS 16
#define PJMEDIA_AUD_MAX_DEVS 64


/** Forward declaration for pjmedia_aud_stream */
Expand Down Expand Up @@ -117,7 +116,7 @@ typedef struct pjmedia_aud_subsys
pjmedia_aud_driver drv[PJMEDIA_AUD_MAX_DRIVERS];/* Array of drivers. */

unsigned dev_cnt; /* Total number of devices. */
pj_uint32_t dev_list[PJMEDIA_AUD_MAX_DEVS];/* Array of dev IDs. */
pj_uint32_t dev_list[PJMEDIA_AUD_DEV_MAX_DEVS];/* Array dev IDs.*/

} pjmedia_aud_subsys;

Expand Down
2 changes: 1 addition & 1 deletion pjmedia/src/pjmedia-audiodev/alsa_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define ALSASOUND_CAPTURE 2
#define MAX_SOUND_CARDS 5
#define MAX_SOUND_DEVICES_PER_CARD 5
#define MAX_DEVICES 32
#define MAX_DEVICES PJMEDIA_AUD_DEV_MAX_DEVS
#define MAX_MIX_NAME_LEN 64

/* Set to 1 to enable tracing */
Expand Down
6 changes: 3 additions & 3 deletions pjmedia/src/pjmedia/audiodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ PJ_DEF(pj_status_t) pjmedia_aud_driver_init(unsigned drv_idx,

/* Get number of devices */
dev_cnt = f->op->get_dev_count(f);
if (dev_cnt + aud_subsys.dev_cnt > PJMEDIA_AUD_MAX_DEVS) {
if (dev_cnt + aud_subsys.dev_cnt > PJMEDIA_AUD_DEV_MAX_DEVS) {
PJ_LOG(4,(THIS_FILE, "%d device(s) cannot be registered because"
" there are too many devices",
aud_subsys.dev_cnt + dev_cnt -
PJMEDIA_AUD_MAX_DEVS));
dev_cnt = PJMEDIA_AUD_MAX_DEVS - aud_subsys.dev_cnt;
PJMEDIA_AUD_DEV_MAX_DEVS));
dev_cnt = PJMEDIA_AUD_DEV_MAX_DEVS - aud_subsys.dev_cnt;
}

/* enabling this will cause pjsua-lib initialization to fail when there
Expand Down
59 changes: 59 additions & 0 deletions pjmedia/src/pjmedia/conference.c
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,65 @@ PJ_DEF(pj_status_t) pjmedia_conf_remove_port( pjmedia_conf *conf,
goto on_return;
}

/* If port is new, remove it synchronously */
if (conf_port->is_new) {
pj_bool_t found = PJ_FALSE;

/* Find & cancel the add-op.
* Also cancel all following ops involving the slot.
* Note that after removed, the slot may be reused by another port
* so if not cancelled, those following ops may be applied to the
* wrong port.
*/
ope = conf->op_queue->next;
while (ope != conf->op_queue) {
op_entry* cancel_op;

cancel_op = NULL;
if (ope->type == OP_ADD_PORT && ope->param.add_port.port == port)
{
found = PJ_TRUE;
cancel_op = ope;
} else if (found && ope->type == OP_CONNECT_PORTS &&
(ope->param.connect_ports.src == port ||
ope->param.connect_ports.sink == port))
{
cancel_op = ope;
} else if (found && ope->type == OP_DISCONNECT_PORTS &&
(ope->param.disconnect_ports.src == port ||
ope->param.disconnect_ports.sink == port))
{
cancel_op = ope;
}

ope = ope->next;

/* Cancel op */
if (cancel_op) {
pj_list_erase(cancel_op);
cancel_op->type = OP_UNKNOWN;
pj_list_push_back(conf->op_queue_free, cancel_op);
}
}

/* If the add-op is not found, it may be being executed,
* do not remove it synchronously to avoid race condition.
*/
if (found) {
op_param prm;

/* Release mutex to avoid deadlock */
pj_mutex_unlock(conf->mutex);

/* Remove it */
prm.remove_port.port = port;
op_remove_port(conf, &prm);

pj_log_pop_indent();
return PJ_SUCCESS;
}
}

/* Queue the operation */
ope = get_free_op_entry(conf);
if (ope) {
Expand Down
70 changes: 56 additions & 14 deletions pjmedia/src/test/mips_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,8 @@ struct test_entry
void (*custom_run)(struct test_entry*);
void (*custom_deinit)(struct test_entry*);

void *pdata[4];
unsigned idata[4];
void *pdata[2*16+1];
// unsigned idata[4];
};


Expand Down Expand Up @@ -465,6 +465,22 @@ static pjmedia_port* gen_port_test_init(pj_pool_t *pool,


/***************************************************************************/

static void conf_port_custom_deinit(struct test_entry *te)
{
unsigned i;
pjmedia_conf *conf = (pjmedia_conf *)te->pdata[0];

if (conf)
pjmedia_conf_destroy(conf);

for (i = 1; i < PJ_ARRAY_SIZE(te->pdata); i++) {
if (!te->pdata[i])
break;
pjmedia_port_destroy((pjmedia_port *)te->pdata[i]);
}
}

static pjmedia_port* init_conf_port(unsigned nb_participant,
pj_pool_t *pool,
unsigned clock_rate,
Expand All @@ -474,18 +490,21 @@ static pjmedia_port* init_conf_port(unsigned nb_participant,
struct test_entry *te)
{
pjmedia_conf *conf;
unsigned i;
unsigned i, nport = 1;
pj_status_t status;

PJ_UNUSED_ARG(flags);
PJ_UNUSED_ARG(te);

te->custom_deinit = &conf_port_custom_deinit;
pj_bzero(te->pdata, sizeof(te->pdata));

/* Create conf */
status = pjmedia_conf_create(pool, 2+nb_participant*2, clock_rate,
channel_count, samples_per_frame, 16,
PJMEDIA_CONF_NO_DEVICE, &conf);
if (status != PJ_SUCCESS)
return NULL;
te->pdata[0] = conf;

for (i=0; i<nb_participant; ++i) {
pjmedia_port *gen_port, *null_port;
Expand All @@ -496,6 +515,7 @@ static pjmedia_port* init_conf_port(unsigned nb_participant,
samples_per_frame, 100 / nb_participant);
if (!gen_port)
return NULL;
te->pdata[nport++] = gen_port;

/* Add port */
status = pjmedia_conf_add_port(conf, pool, gen_port, NULL, &slot1);
Expand All @@ -512,6 +532,7 @@ static pjmedia_port* init_conf_port(unsigned nb_participant,
samples_per_frame, 16, &null_port);
if (status != PJ_SUCCESS)
return NULL;
te->pdata[nport++] = null_port;

/* add null port */
status = pjmedia_conf_add_port(conf, pool, null_port, NULL, &slot2);
Expand Down Expand Up @@ -727,9 +748,11 @@ static pj_status_t codec_on_destroy(struct pjmedia_port *this_port)
{
struct codec_port *cp = (struct codec_port*)this_port;

pjmedia_codec_close(cp->codec);
pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
cp->codec);
if (cp->codec) {
pjmedia_codec_close(cp->codec);
pjmedia_codec_mgr_dealloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
cp->codec);
}
cp->codec_deinit();
pjmedia_endpt_destroy2(cp->endpt);
return PJ_SUCCESS;
Expand Down Expand Up @@ -770,33 +793,37 @@ static pjmedia_port* codec_encode_decode( pj_pool_t *pool,

status = codec_init(cp->endpt);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

count = 1;
status = pjmedia_codec_mgr_find_codecs_by_id(pjmedia_endpt_get_codec_mgr(cp->endpt),
&codec_id, &count, ci, NULL);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

status = pjmedia_codec_mgr_alloc_codec(pjmedia_endpt_get_codec_mgr(cp->endpt),
ci[0], &cp->codec);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

status = pjmedia_codec_mgr_get_default_param(pjmedia_endpt_get_codec_mgr(cp->endpt),
ci[0], &codec_param);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

status = pjmedia_codec_init(cp->codec, pool);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

status = pjmedia_codec_open(cp->codec, &codec_param);
if (status != PJ_SUCCESS)
return NULL;
goto on_error;

return &cp->base;

on_error:
codec_on_destroy(&cp->base);
return NULL;
}
#endif

Expand Down Expand Up @@ -1346,6 +1373,16 @@ static pjmedia_port* wsola_discard_50(pj_pool_t *pool,

/***************************************************************************/

static void ec_custom_deinit(struct test_entry *te)
{
unsigned i;

for (i = 0; i < PJ_ARRAY_SIZE(te->pdata); i++) {
if (!te->pdata[i]) break;
pjmedia_port_destroy((pjmedia_port *)te->pdata[i]);
}
}

static pjmedia_port* ec_create(unsigned ec_tail_msec,
pj_pool_t *pool,
unsigned clock_rate,
Expand All @@ -1357,17 +1394,20 @@ static pjmedia_port* ec_create(unsigned ec_tail_msec,
pjmedia_port *gen_port, *ec_port;
pj_status_t status;

PJ_UNUSED_ARG(te);
te->custom_deinit = &ec_custom_deinit;
pj_bzero(te->pdata, sizeof(te->pdata));

gen_port = create_gen_port(pool, clock_rate, channel_count,
samples_per_frame, 100);
if (gen_port == NULL)
return NULL;
te->pdata[0] = gen_port;

status = pjmedia_echo_port_create(pool, gen_port, ec_tail_msec, 0,
flags, &ec_port);
if (status != PJ_SUCCESS)
return NULL;
te->pdata[1] = ec_port;

return ec_port;
}
Expand Down Expand Up @@ -2386,6 +2426,8 @@ static pj_timestamp run_entry(unsigned clock_rate, struct test_entry *e)

pj_sub_timestamp(&t1, &t0);

pjmedia_port_destroy(gen_port);

if (e->custom_deinit)
e->custom_deinit(e);
else
Expand Down
6 changes: 4 additions & 2 deletions pjmedia/src/test/vid_codec_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ static int encode_decode_test(pj_pool_t *pool, const char *codec_id,
pjmedia_vid_dev_info cdi;

status = pjmedia_vid_dev_get_info(i, &cdi);
if (status != PJ_SUCCESS)
rc = 211; goto on_return;
if (status != PJ_SUCCESS) {
rc = 211;
goto on_return;
}

/* Only interested with render device */
if ((cdi.dir & PJMEDIA_DIR_RENDER) != 0) {
Expand Down
7 changes: 5 additions & 2 deletions pjnath/src/pjnath-test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ pj_status_t create_stun_config(app_sess_t *app_sess)
{ status=PJ_ENOMEM; goto on_error;});

PJ_TEST_SUCCESS(pj_ioqueue_create(app_sess->pool, 64, &ioqueue), NULL,
goto on_error);
{status = tmp_status_; goto on_error;});
PJ_TEST_SUCCESS(pj_timer_heap_create(app_sess->pool, 256, &timer_heap),
NULL, goto on_error);
NULL, {status = tmp_status_; goto on_error;});

pj_lock_create_recursive_mutex(app_sess->pool, NULL, &lock);
pj_timer_heap_set_lock(timer_heap, lock, PJ_TRUE);
Expand All @@ -82,8 +82,11 @@ pj_status_t create_stun_config(app_sess_t *app_sess)
pj_ioqueue_destroy(ioqueue);
if (timer_heap)
pj_timer_heap_destroy(timer_heap);
// Lock should have been destroyed by timer heap.
/*
if (lock)
pj_lock_destroy(lock);
*/
if (app_sess->pool)
pj_pool_release(app_sess->pool);
pj_caching_pool_destroy(&app_sess->cp);
Expand Down
Loading

0 comments on commit 9745995

Please sign in to comment.