AudioDeviceDetection » History » Version 6
Adrian Georgescu, 07/25/2010 02:21 PM
1 | 1 | Adrian Georgescu | = Audio Device Detection = |
---|---|---|---|
2 | 2 | Adrian Georgescu | |
3 | 3 | Adrian Georgescu | [[TOC(Design*, AudioDeviceDetection, depth=1)]] |
4 | 4 | Adrian Georgescu | |
5 | == Introduction == |
||
6 | |||
7 | The idea behind audio device detection is to allow SIP users to switch headphones, speakers or microphones as they are plugged or unplugged from the computer. |
||
8 | |||
9 | Many SIP applications allow this. Some require to restart the application, while others can detect it while running. SIP SIMPLE client can currently detect hotplugged devices in Mac OS X platforms. |
||
10 | |||
11 | |||
12 | == Goal == |
||
13 | |||
14 | The ultimate goal is to enable SIP SIMPLE client applications to detect audio device changes on the fly in all currently supported platforms, with the most immediate priority being [ticket:117 Windows platform]. |
||
15 | |||
16 | |||
17 | == Schematic Overview == |
||
18 | |||
19 | 6 | Adrian Georgescu | [[Image(wiki:AudioDeviceDetection:SipSimpleAudioDevicesChange.png width=800)]] |
20 | 4 | Adrian Georgescu | |
21 | |||
22 | == Required Modifications == |
||
23 | |||
24 | After a first analysis of the SIP SIMPLE client SDK, these are the necessary code modifications: |
||
25 | |||
26 | === PortAudio modifications === |
||
27 | |||
28 | First, it's necessary to hook up into the host OS multimedia system in order to get notified when new devices are added or old ones removed. If the OS doesn't provide a notification API, a poll loop with sensible frequency settings will need to be used. |
||
29 | * Currently, this is already achieved in Mac OS X through the `AudioHardwareAddPropertyListener` function in Core Audio API. |
||
30 | * In Windows platforms (under `WMME` hostapi), `WM_DEVICECHANGE` notification or similar methods may be used (proper research of `mmsystem` API is pending). |
||
31 | * Each of the rest of platforms (or corresponding hostapis) will need their own implementations too. |
||
32 | |||
33 | Second, the hostapi needs to react to the `DevicesChanged` notification, by updating the internal audio devices data (after which PortAudio will proceed to notify upper layers about the availability of a new devices list). This is achieved through the `RescanDevices` function. |
||
34 | * Mac OS X hostapi, Audiocore, already updates its internal devices list with `RescanDevices()`. |
||
35 | * Windows platform lacks such a function. [http://osdir.com/ml/audio.portaudio.devel/2007-02/msg00094.html Partial implementations] have been provided in PortAudio mailing list, but have not yet been integrated into SIP SIMPLE client official releases. |
||
36 | * The rest of platforms will need their own implementations too. |
||
37 | |||
38 | === SIP SIMPLE client modifications === |
||
39 | |||
40 | The Windows version of SIP SIMPLE client SDK may need some very minor tweaks. |
||
41 | |||
42 | At first sight, `AudioDevicesDidChange` and `DefaultAudioDeviceDidChange` observers have to be added to `Application` implementation. |