Backed out changeset 6b264cf230a0 (bug 1200208) for Windows bustage.
CLOSED TREE
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user