Changes between Version 105 and Version 106 of FAQ


Ignore:
Timestamp:
Dec 3, 2010 6:55:38 AM (14 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • FAQ

    v105 v106  
    531531=== How can I support new audio device that is plugged-in after the application is running?  === #snd-hot-plug 
    532532 
    533 PJSIP currently does not detect new audio devices that are plugged-in after the library has been initialized. The sound device list simply will not update itself. 
    534  
    535 To support these new audio devices, you'd need to do the following. 
     533PJSIP currently does not support hot-plugging of audio devices while the application is running. Hot-plugging can be supported in the application though. To support this, the app would need to capture the hot-plug event and reinitialize the audio subsytem once the event is detected. 
    536534 
    537535First you need to detect that new sound device has been inserted into the system. The methods vary, and it is outside the scope of PJSIP (for now). For Windows XP for example, you can follow the generic hardware detection procedure in http://www.codeproject.com/KB/system/HwDetect.aspx, replacing the device interface class ID with audio device interface below (you can use any of it):  
     
    542540}}} 
    543541 
    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()}}}.  
     542The 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()}}}.  
    549543 
    550544----