« Previous - Version 7/14 (diff) - Next » - Current version
Adrian Georgescu, 07/25/2010 02:22 pm


= Audio Device Detection =

<acronym title="Design*, AudioDeviceDetection, depth=1">TOC</acronym>

Introduction

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.

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.

Goal

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].

Schematic Overview

[[Image(wiki:AudioDeviceDetection:SipSimpleAudioDevicesChange.png, width=800)]]

Required Modifications

After a first analysis of the SIP SIMPLE client SDK, these are the necessary code modifications:

=== PortAudio modifications ===

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. * Currently, this is already achieved in Mac OS X through the `AudioHardwareAddPropertyListener` function in Core Audio API. * In Windows platforms (under `WMME` hostapi), `WM_DEVICECHANGE` notification or similar methods may be used (proper research of `mmsystem` API is pending). * Each of the rest of platforms (or corresponding hostapis) will need their own implementations too.

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. * Mac OS X hostapi, Audiocore, already updates its internal devices list with `RescanDevices()`. * 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. * The rest of platforms will need their own implementations too.

=== SIP SIMPLE client modifications ===

The Windows version of SIP SIMPLE client SDK may need some very minor tweaks.

At first sight, `AudioDevicesDidChange` and `DefaultAudioDeviceDidChange` observers have to be added to `Application` implementation.

SipSimpleAudioDevicesChange.svg - Audio Device Detection diagram (452.5 kB) , 07/25/2010 12:03 pm

SipSimpleAudioDevicesChange.png - Audio Device Detection diagram (69.6 kB) , 07/25/2010 12:22 pm

runtime_device_change_detection_wmme.patch - Runtime Device Change Detection with WMME hostapi (17.8 kB) , 08/14/2010 12:35 pm