- Timestamp:
- May 5, 2010 4:23:27 AM (15 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia-audiodev/audiodev.h
r2506 r3159 40 40 */ 41 41 42 /** 42 /** 43 43 * Type for device index. 44 44 */ … … 429 429 typedef struct pjmedia_aud_dev_factory pjmedia_aud_dev_factory; 430 430 431 /* typedef for factory creation function */ 432 typedef pjmedia_aud_dev_factory* 433 (*pjmedia_aud_dev_factory_create_func_ptr)(pj_pool_factory*); 434 435 431 436 /** 432 437 * Get string info for the specified capability. … … 508 513 */ 509 514 PJ_DECL(pj_status_t) pjmedia_aud_subsys_shutdown(void); 515 516 517 /** 518 * Register a supported audio device factory to the audio subsystem. This 519 * function can only be called after calling #pjmedia_aud_subsys_init(). 520 * 521 * @param adf The audio device factory. 522 * 523 * @return PJ_SUCCESS on successful operation or the appropriate 524 * error code. 525 */ 526 PJ_DECL(pj_status_t) 527 pjmedia_aud_register_factory(pjmedia_aud_dev_factory_create_func_ptr adf); 528 529 530 /** 531 * Unregister an audio device factory from the audio subsystem. This 532 * function can only be called after calling #pjmedia_aud_subsys_init(). 533 * Devices from this factory will be unlisted. If a device from this factory 534 * is currently in use, then the behavior is undefined. 535 * 536 * @param adf The audio device factory. 537 * 538 * @return PJ_SUCCESS on successful operation or the appropriate 539 * error code. 540 */ 541 PJ_DECL(pj_status_t) 542 pjmedia_aud_unregister_factory(pjmedia_aud_dev_factory_create_func_ptr adf); 510 543 511 544 -
pjproject/trunk/pjmedia/src/pjmedia-audiodev/audiodev.c
r3102 r3159 98 98 #define MAX_DEVS 64 99 99 100 /* typedef for factory creation function */101 typedef pjmedia_aud_dev_factory* (*create_func_ptr)(pj_pool_factory*);102 100 103 101 /* driver structure */ 104 102 struct driver 105 103 { 106 create_func_ptr create; /* Creation function. */ 107 pjmedia_aud_dev_factory *f; /* Factory instance. */ 104 /* Creation function */ 105 pjmedia_aud_dev_factory_create_func_ptr create; 106 /* Factory instance */ 107 pjmedia_aud_dev_factory *f; 108 108 char name[32]; /* Driver name */ 109 109 unsigned dev_cnt; /* Number of devices */ … … 409 409 410 410 return aud_subsys.dev_cnt ? PJ_SUCCESS : status; 411 } 412 413 /* API: register an audio device factory to the audio subsystem. */ 414 PJ_DEF(pj_status_t) 415 pjmedia_aud_register_factory(pjmedia_aud_dev_factory_create_func_ptr adf) 416 { 417 pj_status_t status; 418 419 if (aud_subsys.init_count == 0) 420 return PJMEDIA_EAUD_INIT; 421 422 aud_subsys.drv[aud_subsys.drv_cnt].create = adf; 423 status = init_driver(aud_subsys.drv_cnt); 424 if (status == PJ_SUCCESS) { 425 aud_subsys.drv_cnt++; 426 } else { 427 deinit_driver(aud_subsys.drv_cnt); 428 } 429 430 return status; 431 } 432 433 /* API: unregister an audio device factory from the audio subsystem. */ 434 PJ_DEF(pj_status_t) 435 pjmedia_aud_unregister_factory(pjmedia_aud_dev_factory_create_func_ptr adf) 436 { 437 unsigned i, j; 438 439 if (aud_subsys.init_count == 0) 440 return PJMEDIA_EAUD_INIT; 441 442 for (i=0; i<aud_subsys.drv_cnt; ++i) { 443 struct driver *drv = &aud_subsys.drv[i]; 444 445 if (drv->create == adf) { 446 for (j = drv->start_idx; j < drv->start_idx + drv->dev_cnt; j++) 447 { 448 aud_subsys.dev_list[j] = PJMEDIA_AUD_INVALID_DEV; 449 } 450 451 deinit_driver(i); 452 pj_bzero(drv, sizeof(*drv)); 453 return PJ_SUCCESS; 454 } 455 } 456 457 return PJMEDIA_EAUD_ERR; 411 458 } 412 459
Note: See TracChangeset
for help on using the changeset viewer.