Bug 1319529 - notify audible state changed for nsNPAPI. r=baku

When the nsNPAPI is muted by AudioChannelService, we should notify our audible state changed.

MozReview-Commit-ID: 1YHGZiyIRvI

--HG--
extra : rebase_source : c097fbdeb1d65a979b3a7d82442433ac1c7928e7
This commit is contained in:
Alastor Wu 2016-12-16 17:12:41 +08:00
parent 68a9f20e40
commit 4e144a06a3
3 changed files with 21 additions and 3 deletions

View File

@ -75,15 +75,23 @@ var tests = [
},
function() {
info("=== Mute plugin ===");
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
iframe.contentWindow.toggleMuteState(true);
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
iframe.contentWindow.toggleMuteState(false);
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
runTest();
expectedNotification = 'inactive-nonaudible';
},
function() {
info("=== unmute plugin ==");
ok(iframe.contentWindow.pluginMuted(), "Plugin should be muted");
iframe.contentWindow.toggleMuteState(false);
ok(!iframe.contentWindow.pluginMuted(), "Plugin should not be muted");
expectedNotification = 'active';
},
function() {
info("=== stop audio ==");
expectedNotification = 'inactive-pause';
iframe.contentWindow.stopAudio();
},

View File

@ -139,6 +139,7 @@ nsNPAPIPluginInstance::nsNPAPIPluginInstance()
, mCachedParamLength(0)
, mCachedParamNames(nullptr)
, mCachedParamValues(nullptr)
, mMuted(false)
{
mNPP.pdata = nullptr;
mNPP.ndata = this;
@ -1794,6 +1795,14 @@ nsNPAPIPluginInstance::WindowVolumeChanged(float aVolume, bool aMuted)
// We just support mute/unmute
nsresult rv = SetMuted(aMuted);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetMuted failed");
if (mMuted != aMuted) {
mMuted = aMuted;
AudioChannelService::AudibleState audible = aMuted ?
AudioChannelService::AudibleState::eNotAudible :
AudioChannelService::AudibleState::eAudible;
mAudioChannelAgent->NotifyStartedAudible(audible,
AudioChannelService::AudibleChangedReasons::eVolumeChanged);
}
return rv;
}

View File

@ -430,6 +430,7 @@ private:
char **mCachedParamValues;
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
bool mMuted;
};
// On Android, we need to guard against plugin code leaking entries in the local