- Timestamp:
- Jun 21, 2011 9:33:01 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjmedia/src/pjmedia-videodev/videodev.c
r3579 r3592 211 211 212 212 /* Internal: init driver */ 213 static pj_status_t init_driver(unsigned drv_idx )213 static pj_status_t init_driver(unsigned drv_idx, pj_bool_t refresh) 214 214 { 215 215 struct driver *drv = &vid_subsys.drv[drv_idx]; … … 218 218 pj_status_t status; 219 219 220 /* Create the factory */ 221 f = (*drv->create)(vid_subsys.pf); 222 if (!f) 223 return PJ_EUNKNOWN; 224 225 /* Call factory->init() */ 226 status = f->op->init(f); 227 if (status != PJ_SUCCESS) { 228 f->op->destroy(f); 229 return status; 220 if (!refresh) { 221 /* Create the factory */ 222 f = (*drv->create)(vid_subsys.pf); 223 if (!f) 224 return PJ_EUNKNOWN; 225 226 /* Call factory->init() */ 227 status = f->op->init(f); 228 if (status != PJ_SUCCESS) { 229 f->op->destroy(f); 230 return status; 231 } 232 } else { 233 f = drv->f; 230 234 } 231 235 … … 357 361 /* Initialize each factory and build the device ID list */ 358 362 for (i=0; i<vid_subsys.drv_cnt; ++i) { 359 status = init_driver(i );363 status = init_driver(i, PJ_FALSE); 360 364 if (status != PJ_SUCCESS) { 361 365 deinit_driver(i); … … 377 381 378 382 vid_subsys.drv[vid_subsys.drv_cnt].create = adf; 379 status = init_driver(vid_subsys.drv_cnt );383 status = init_driver(vid_subsys.drv_cnt, PJ_FALSE); 380 384 if (status == PJ_SUCCESS) { 381 385 vid_subsys.drv_cnt++; … … 439 443 440 444 vid_subsys.pf = NULL; 445 } 446 return PJ_SUCCESS; 447 } 448 449 /* API: Refresh the list of video devices installed in the system. */ 450 PJ_DEF(pj_status_t) pjmedia_vid_dev_refresh(void) 451 { 452 unsigned i; 453 454 vid_subsys.dev_cnt = 0; 455 for (i=0; i<vid_subsys.drv_cnt; ++i) { 456 struct driver *drv = &vid_subsys.drv[i]; 457 458 if (drv->f && drv->f->op->refresh) { 459 pj_status_t status = drv->f->op->refresh(drv->f); 460 if (status != PJ_SUCCESS) { 461 PJ_PERROR(4, (THIS_FILE, status, "Unable to refresh device " 462 "list for %s", drv->name)); 463 } 464 } 465 init_driver(i, PJ_TRUE); 441 466 } 442 467 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.