544 | | The next task is to update the sound device list in pjmedia. As we currently do not have an API to do this, what we can do is to shutdown and reinitialize the audio subsystem (pjmedia_aud_subsys_shutdown() and pjmedia_aud_subsys_init()) to make the backends update their device list. But you should only do this when the sound device is not being used. You can check this by using {{{pjsua_snd_is_active()}}} API. Though having said that, I briefly checked our native WMME implementation to see if opened streams are affected if the audio subsystem is shutdown, and it doesn't appear to be so. But the general behavior is undefined. |
545 | | |
546 | | Alternatively, you can manage the sound device yourself, using {{{pjsua_set_no_snd_dev()}}} facility. Using this approach, you can even change the sound device on the fly even when the media is active! Just disconnect the sound device from the bridge's port, reinitialize audio subsystem, open the new sound device, reconnect to the bridge, and voila! The newly inserted sound device is active. |
547 | | |
548 | | As yet another alternative, and this is probably the best alternative, you can let PJSIP manage the sound device (the default behavior) so that it's automatically opened/closed on demand, and call {{{pjsua_set_no_snd_dev()}}} only when you're about to reinitialize the audio subsystem, to forcefully close the currently opened sound device (if any). Once the reinitialization is complete, you can tell PJSIP to manage the sound device again with {{{pjsua_set_snd_dev()}}}. |
| 542 | The next task is to update the sound device list in pjmedia. As we currently do not have an API to do this, what we can do is to shutdown and reinitialize the audio subsystem (pjmedia_aud_subsys_shutdown() and pjmedia_aud_subsys_init()) to make the backends update their device list. But you should only do this when the sound device is not being used. One way to do this is to call {{{pjsua_set_no_snd_dev()}}} to forcefully close the currently opened sound device (if any). Once the reinitialization is complete, you can tell PJSIP to manage the sound device again by calling {{{pjsua_set_snd_dev()}}}. |