Closed Bug 1251202 Opened 7 years ago Closed 6 years ago

Implement Default Audio Device Notifications for NPAPI plugins on Windows.


(Core Graveyard :: Plug-ins, enhancement, P2)



(firefox52 fixed)

Tracking Status
firefox52 --- fixed


(Reporter: bobowen, Assigned: handyman)



(Whiteboard: sbwn1)


(2 files, 1 obsolete file)


This proposal is to allow plugins instances that are running within a low integrity process on Windows 10 to still receive default audio device notifications.
Whiteboard: sbwn1
Blocks: 1253261
Would like to request status update and an ETA for this feature, if available.
Priority: -- → P3
Setting priority P2 because this bug blocks P2 bug 1253261.
Priority: P3 → P2
This plugin logs default audio events that it receives using the API spec'ed here:

Written as an STR:

0. Install this test plugin by building npaudiotest.sln to generate npaudiotest.dll or simply copying ntaudiotest.dll (a debug build) from the zip archive.  Place the dll in your profile's plugins folder.  (Press <WindowsKey>-R and enter %appdata%\Mozilla\Firefox\Profiles\ -- then find the relevant profile folder and access or create a 'plugins' subfolder there).

1. Launch Firefox 32-bit from the command line.

2. Open test.html (from the zip archive) in the browser.

3. Insert/remove a device that changes the default audio - e.g. a USB microphone.


The plugin will log the details of the new audio device to the console.


Nothing since the API isn't implemented.


The plugin just printfs the default audio device changes to the console.  In order to see it register/unregister with the OS for these notifications, you need to turn on more logging.  Run Firefox with the log environment variable set for plugins:


When the plugin starts, it logs a message like this:

[Main Thread]: D/IPCPlugins Registered for plugin audio device notification.

When the OS generates a new audio device notification, Firefox logs a message like this:

[Main Thread]: D/IPCPlugins Notifying 1 plugins of audio device change.

And the plugin itself writes a message like this:

NPAUDIOTEST: Received Default Audio Device Change Notification: (0,0,{}.{df007fef-8548-4c8c-8b37-8903d2c5e0cd})

Finally, when the plugin is unregistered, we get a message like this:

[Main Thread]: D/IPCPlugins Unregistering for plugin audio device notification.
Assignee: nobody → davidp99
(Bob, maybe another reviewer is appropriate as you already have one from me...?)

This implements the API.  Rather than bounce the message to the content process via the PluginInstanceParent/Child, it sends it to the chrome proc using the PluginModuleParent/Child.  This is because we may not want audio on the content proc in the future.


Each interested plugin instance registers with its PluginModuleChild in its plugin process.  When the PMC has greater-than-zero registered instances, it tells its PluginModuleParent to register with a singleton that monitors the audio devices.  When no instances are registered then the singleton is destroyed to avoid overheard, as written in the spec.
Attachment #8792549 - Flags: review?(bobowen.code)
Attachment #8792549 - Flags: review?(bobowen.code) → review?(jmathies)
Comment on attachment 8792549 [details] [diff] [review]
Implement default audio notification spec

Review of attachment 8792549 [details] [diff] [review]:

::: dom/plugins/ipc/PluginInstanceChild.cpp
@@ +885,5 @@
> +    if (!mPluginIface->setvalue) {
> +        return NPERR_GENERIC_ERROR;
> +    }
> +    return mPluginIface->setvalue(GetNPP(), NPNVaudioDeviceChangeDetails, (void*)&details);
> +    NS_RUNTIMEABORT("NPP_SetValue_NPNVaudioDeviceChangeDetails is a Windows-only message");

nit - missing an #else here for other platforms

::: dom/plugins/ipc/PluginModuleChild.cpp
@@ +2571,5 @@
> +                          PluginInstanceChild* aInstance,
> +                          NPBool aShouldRegister)
> +{
> +#ifdef XP_WIN
> +  // Maintain a set of PluginInstanceChildren that we need to tell when the

nit - this file is double spaced indent

::: dom/plugins/ipc/PluginUtilsWin.cpp
@@ +89,5 @@
> +
> +    // Make sure that plugin is notified on the main thread.
> +    RefPtr<AudioDeviceChangedRunnable> runnable =
> +      new AudioDeviceChangedRunnable(&mAudioNotificationSet, changeDetails);
> +    NS_DispatchToMainThread(runnable);

do we expect this to show up on non main threads?

@@ +162,5 @@
> +    mIsRegistered = false;
> +  }
> +
> +  /*
> +   * True iff the notification server is set to report events to this object.

nit - iff
Attachment #8792549 - Flags: review?(jmathies) → review+
r+ed in comment 5
tests in comment 4
Attachment #8792549 - Attachment is obsolete: true
Keywords: checkin-needed
Pushed by
Implement Default Audio Device Notifications for NPAPI plugins on Windows. r=jimm
Keywords: checkin-needed
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
Adobe confirmed that Audio Device Notifications support will ship in the Flash Player's March release ("Webster").
(In reply to Marco from comment #13)
> I have to wait from now to march for can record online in flash application?

This microphone bug only affects 64-bit Firefox and Flash. In the meantime, you can 32-bit Firefox and Flash.
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.