Backed out changeset 6b264cf230a0 (bug 1200208) for Windows bustage.

CLOSED TREE
This commit is contained in:
Ryan VanderMeulen 2015-08-31 14:11:58 -04:00
parent 1fd49e2d20
commit 851115d952
4 changed files with 17 additions and 143 deletions

View File

@ -267,8 +267,6 @@ support-files =
skip-if = buildapp == 'mulet'
[test_audioNotificationStopOnNavigation.html]
skip-if = buildapp == 'mulet'
[test_audioNotificationWithEarlyPlay.html]
skip-if = buildapp == 'mulet'
[test_bug1091883.html]
[test_bug116083.html]
[test_bug793311.html]

View File

@ -1,73 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for audio controller in windows</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<pre id="test">
</pre>
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
var expectedNotification = null;
var observer = {
observe: function(subject, topic, data) {
is(topic, "audio-playback", "audio-playback received");
is(data, expectedNotification, "This is the right notification");
runTest();
}
};
var observerService = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
.getService(SpecialPowers.Ci.nsIObserverService);
var audio = new Audio();
audio.loop = true;
audio.preload = "metadata";
var tests = [
function() {
observerService.addObserver(observer, "audio-playback", false);
ok(true, "Observer set");
runTest();
},
function() {
expectedNotification = 'active';
audio.src = "audio.ogg";
audio.play();
},
function() {
expectedNotification = 'inactive';
audio.pause();
},
function() {
observerService.removeObserver(observer, "audio-playback");
ok(true, "Observer removed");
runTest();
}
];
function runTest() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
runTest();
</script>
</body>
</html>

View File

@ -3184,47 +3184,11 @@ void HTMLMediaElement::ProcessMediaFragmentURI()
}
}
class MOZ_STACK_CLASS AutoNotifyAudioChannelAgent
{
nsRefPtr<HTMLMediaElement> mElement;
bool mShouldNotify;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER;
public:
AutoNotifyAudioChannelAgent(HTMLMediaElement* aElement,
bool aNotify
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mElement(aElement)
, mShouldNotify(aNotify)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (mShouldNotify) {
mElement->NotifyAudioChannelAgent(false);
}
}
~AutoNotifyAudioChannelAgent()
{
if (mShouldNotify) {
// The audio channel agent is destroyed at this point.
if (mElement->MaybeCreateAudioChannelAgent()) {
mElement->NotifyAudioChannelAgent(true);
}
}
}
};
void HTMLMediaElement::MetadataLoaded(const MediaInfo* aInfo,
nsAutoPtr<const MetadataTags> aTags)
{
MOZ_ASSERT(NS_IsMainThread());
// If the element is gaining or losing an audio track, we need to notify
// the audio channel agent so that the correct audio-playback events will
// get dispatched.
bool audioTrackChanging = mMediaInfo.HasAudio() != aInfo->HasAudio();
AutoNotifyAudioChannelAgent autoNotify(this,
audioTrackChanging &&
mPlayingThroughTheAudioChannel);
mMediaInfo = *aInfo;
mIsEncrypted = aInfo->IsEncrypted()
#ifdef MOZ_EME
@ -4524,25 +4488,7 @@ nsresult HTMLMediaElement::UpdateChannelMuteState(float aVolume, bool aMuted)
return NS_OK;
}
bool
HTMLMediaElement::MaybeCreateAudioChannelAgent()
{
if (!mAudioChannelAgent) {
nsresult rv;
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
MOZ_ASSERT(mAudioChannelAgent);
mAudioChannelAgent->InitWithWeakCallback(OwnerDoc()->GetInnerWindow(),
static_cast<int32_t>(mAudioChannel),
this);
}
return true;
}
void
HTMLMediaElement::UpdateAudioChannelPlayingState()
void HTMLMediaElement::UpdateAudioChannelPlayingState()
{
bool playingThroughTheAudioChannel =
(!mPaused &&
@ -4560,9 +4506,18 @@ HTMLMediaElement::UpdateAudioChannelPlayingState()
return;
}
if (MaybeCreateAudioChannelAgent()) {
NotifyAudioChannelAgent(mPlayingThroughTheAudioChannel);
if (!mAudioChannelAgent) {
nsresult rv;
mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1", &rv);
if (!mAudioChannelAgent) {
return;
}
mAudioChannelAgent->InitWithWeakCallback(OwnerDoc()->GetInnerWindow(),
static_cast<int32_t>(mAudioChannel),
this);
}
NotifyAudioChannelAgent(mPlayingThroughTheAudioChannel);
}
}

View File

@ -35,6 +35,10 @@
// Define to output information on decoding and painting framerate
/* #define DEBUG_FRAME_RATE 1 */
class nsIChannel;
class nsIHttpChannel;
class nsILoadGroup;
typedef uint16_t nsMediaNetworkState;
typedef uint16_t nsMediaReadyState;
@ -52,13 +56,9 @@ class MediaTrack;
} // namespace dom
} // namespace mozilla
class AutoNotifyAudioChannelAgent;
class nsIChannel;
class nsIHttpChannel;
class nsILoadGroup;
class nsIRunnable;
class nsITimer;
class nsRange;
class nsIRunnable;
namespace mozilla {
namespace dom {
@ -78,8 +78,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
public MediaDecoderOwner,
public nsIAudioChannelAgentCallback
{
friend class AutoNotifyAudioChannelAgent;
public:
typedef mozilla::TimeStamp TimeStamp;
typedef mozilla::layers::ImageContainer ImageContainer;
@ -1052,10 +1050,6 @@ protected:
// Notifies the audio channel agent when the element starts or stops playing.
void NotifyAudioChannelAgent(bool aPlaying);
// Creates the audio channel agent if needed. Returns true if the audio
// channel agent is ready to be used.
bool MaybeCreateAudioChannelAgent();
class nsAsyncEventRunner;
using nsGenericHTMLElement::DispatchEvent;
// For nsAsyncEventRunner.