NPAPI:DefaultAudioDeviceNotification

From MozillaWiki
Jump to: navigation, search

Status

Under consideration.

Contributors

  • Last modified: February 24, 2016
  • Authors: Bob Owen (Mozilla Corporation)

Problem Summary

In Windows 10, Microsoft made a change to the permissions required for calls to IMMDeviceEnumerator::RegisterEndpointNotificationCallback [1], so that the call no longer works if a process is running at low integrity or lower.

This callback registration function is used by some plugins in order to be notified of default audio device changes.

Low integrity is used for sandboxing processes and so this means that plugins, which use it, lose this functionality when sandboxed.

Current Proposal

To create two new Windows only variables for NPN_SetVaue and NPP_SetValue, to allow a plugin instances to request and receive notifications of default audio device changes.

NPN_SetVaue - NPPVpluginRequiresAudioDeviceChanges = 4001

  • when true - request that the plugin host register via IMMDeviceEnumerator::RegisterEndpointNotificationCallback and deliver device notifications to the requesting plugin instance.
  • when false - remove plugin instance from the requires notification list. If the list is now empty call IMMDeviceEnumerator::UnregisterEndpointNotificationCallback [2].

NPP_SetValue - NPNVaudioDeviceChangeDetails = 4001

  • this would be used when OnDefaultDeviceChanged [3] is called on the registered IMMNotificationClient [4]. It would set a new structure (below) containing the two enums and const wchar_t* passed in OnDefaultDeviceChanged. This would be called for each instance in the requires notification list.
typedef struct _NPaudioDeviceChangeDetails
{
  int32_t flow;
  int32_t role;
  const wchar_t* defaultDevice;
} NPaudioDeviceChangeDetails;

Notes

  • The intention is for the registration and in particular the notifications for device changes to be asynchronous, so plugins would need to allow for this when attempting to interact with the default device.
  • These notifications would be on a per instance basis, so plugins only requiring plugin-level notification would need to work around this.

Open Issues

  • None