Closed Bug 1251202 Opened 8 years ago Closed 8 years ago

Implement Default Audio Device Notifications for NPAPI plugins on Windows.

Categories

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

All
Windows
enhancement

Tracking

(firefox52 fixed)

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: bobowen, Assigned: handyman)

References

Details

(Whiteboard: sbwn1)

Attachments

(2 files, 1 obsolete file)

Implement:

https://wiki.mozilla.org/NPAPI:DefaultAudioDeviceNotification

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: https://wiki.mozilla.org/NPAPI:DefaultAudioDeviceNotification

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.

EXPECTED RESULT:

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

ACTUAL RESULT:

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:

MOZ_LOG=IPCPlugins:4,plugin:4

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,{0.0.0.00000000}.{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
Status: NEW → ASSIGNED
(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.

TESTS:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=b5e38f20429b


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 cbook@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e7b723418cf1
Implement Default Audio Device Notifications for NPAPI plugins on Windows. r=jimm
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/e7b723418cf1
Status: ASSIGNED → RESOLVED
Closed: 8 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.

Attachment

General

Created:
Updated:
Size: