Fix #1777: Problem in audio device list refresh after unregistering an audio device factory.

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@4879 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
Nanang Izzuddin 2014-07-16 04:21:54 +00:00
parent b5411f5f4d
commit 67ce8287fb
1 changed files with 9 additions and 5 deletions

View File

@ -275,7 +275,7 @@ static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh)
unsigned i, dev_cnt;
pj_status_t status;
if (!refresh) {
if (!refresh && drv->create) {
/* Create the factory */
f = (*drv->create)(aud_subsys.pf);
if (!f)
@ -291,6 +291,9 @@ static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh)
f = drv->f;
}
if (!f)
return PJ_EUNKNOWN;
/* Get number of devices */
dev_cnt = f->op->get_dev_count(f);
if (dev_cnt + aud_subsys.dev_cnt > MAX_DEVS) {
@ -311,7 +314,8 @@ static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh)
*/
/* Fill in default devices */
drv->play_dev_idx = drv->rec_dev_idx = drv->dev_idx = -1;
drv->play_dev_idx = drv->rec_dev_idx =
drv->dev_idx = PJMEDIA_AUD_INVALID_DEV;
for (i=0; i<dev_cnt; ++i) {
pjmedia_aud_dev_info info;
@ -374,8 +378,9 @@ static void deinit_driver(unsigned drv_idx)
drv->f = NULL;
}
drv->dev_cnt = 0;
drv->play_dev_idx = drv->rec_dev_idx = drv->dev_idx = -1;
pj_bzero(drv, sizeof(*drv));
drv->play_dev_idx = drv->rec_dev_idx =
drv->dev_idx = PJMEDIA_AUD_INVALID_DEV;
}
/* API: Initialize the audio subsystem. */
@ -491,7 +496,6 @@ pjmedia_aud_unregister_factory(pjmedia_aud_dev_factory_create_func_ptr adf)
}
deinit_driver(i);
pj_bzero(drv, sizeof(*drv));
return PJ_SUCCESS;
}
}