Backed out changeset b607cc162c2c (bug 874508) for causing perma orange b2g-crashtest failures

This commit is contained in:
Carsten "Tomcat" Book 2013-10-04 16:31:02 +02:00
parent 47e2956ad0
commit c2d9983719
3 changed files with 10 additions and 136 deletions

View File

@ -17,12 +17,13 @@ namespace mozilla {
/**
* An AudioNodeStream produces a single audio track with ID
* AUDIO_TRACK. This track has rate AudioContext::sIdealAudioRate
* AUDIO_NODE_STREAM_TRACK_ID. This track has rate AudioContext::sIdealAudioRate
* for regular audio contexts, and the rate requested by the web content
* for offline audio contexts.
* Each chunk in the track is a single block of WEBAUDIO_BLOCK_SIZE samples.
* Note: This must be a different value than MEDIA_STREAM_DEST_TRACK_ID
*/
static const int AUDIO_NODE_STREAM_TRACK_ID = 1;
AudioNodeStream::~AudioNodeStream()
{
@ -408,7 +409,7 @@ AudioNodeStream::ProduceOutput(GraphTime aFrom, GraphTime aTo)
FinishOutput();
}
EnsureTrack(AUDIO_TRACK, mSampleRate);
EnsureTrack(AUDIO_NODE_STREAM_TRACK_ID, mSampleRate);
uint16_t outputCount = std::max(uint16_t(1), mEngine->OutputCount());
mLastChunks.SetLength(outputCount);
@ -440,7 +441,7 @@ AudioNodeStream::ProduceOutput(GraphTime aFrom, GraphTime aTo)
}
}
if (mDisabledTrackIDs.Contains(static_cast<TrackID>(AUDIO_TRACK))) {
if (mDisabledTrackIDs.Contains(AUDIO_NODE_STREAM_TRACK_ID)) {
for (uint32_t i = 0; i < mLastChunks.Length(); ++i) {
mLastChunks[i].SetNull(WEBAUDIO_BLOCK_SIZE);
}
@ -452,7 +453,7 @@ AudioNodeStream::ProduceOutput(GraphTime aFrom, GraphTime aTo)
void
AudioNodeStream::AdvanceOutputSegment()
{
StreamBuffer::Track* track = EnsureTrack(AUDIO_TRACK, mSampleRate);
StreamBuffer::Track* track = EnsureTrack(AUDIO_NODE_STREAM_TRACK_ID, mSampleRate);
AudioSegment* segment = track->Get<AudioSegment>();
if (mKind == MediaStreamGraph::EXTERNAL_STREAM) {
@ -466,7 +467,7 @@ AudioNodeStream::AdvanceOutputSegment()
AudioChunk copyChunk = mLastChunks[0];
AudioSegment tmpSegment;
tmpSegment.AppendAndConsumeChunk(&copyChunk);
l->NotifyQueuedTrackChanges(Graph(), AUDIO_TRACK,
l->NotifyQueuedTrackChanges(Graph(), AUDIO_NODE_STREAM_TRACK_ID,
mSampleRate, segment->GetDuration(), 0,
tmpSegment);
}
@ -475,7 +476,7 @@ AudioNodeStream::AdvanceOutputSegment()
TrackTicks
AudioNodeStream::GetCurrentPosition()
{
return EnsureTrack(AUDIO_TRACK, mSampleRate)->Get<AudioSegment>()->GetDuration();
return EnsureTrack(AUDIO_NODE_STREAM_TRACK_ID, mSampleRate)->Get<AudioSegment>()->GetDuration();
}
void
@ -485,14 +486,14 @@ AudioNodeStream::FinishOutput()
return;
}
StreamBuffer::Track* track = EnsureTrack(AUDIO_TRACK, mSampleRate);
StreamBuffer::Track* track = EnsureTrack(AUDIO_NODE_STREAM_TRACK_ID, mSampleRate);
track->SetEnded();
FinishOnGraphThread();
for (uint32_t j = 0; j < mListeners.Length(); ++j) {
MediaStreamListener* l = mListeners[j];
AudioSegment emptySegment;
l->NotifyQueuedTrackChanges(Graph(), AUDIO_TRACK,
l->NotifyQueuedTrackChanges(Graph(), AUDIO_NODE_STREAM_TRACK_ID,
mSampleRate,
track->GetSegment()->GetDuration(),
MediaStreamListener::TRACK_EVENT_ENDED, emptySegment);

View File

@ -6,15 +6,10 @@
#include "AudioDestinationNode.h"
#include "mozilla/dom/AudioDestinationNodeBinding.h"
#include "mozilla/Preferences.h"
#include "AudioChannelAgent.h"
#include "AudioNodeEngine.h"
#include "AudioNodeStream.h"
#include "MediaStreamGraph.h"
#include "OfflineAudioCompletionEvent.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsIDocShell.h"
#include "nsIDocument.h"
namespace mozilla {
namespace dom {
@ -218,55 +213,7 @@ private:
float mVolume;
};
class AudioChannelAgentCallback MOZ_FINAL : public nsIAudioChannelAgentCallback
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(AudioChannelAgentCallback)
explicit AudioChannelAgentCallback(AudioDestinationNode* aNode)
: mNode(aNode)
{
}
~AudioChannelAgentCallback()
{
}
NS_IMETHODIMP
CanPlayChanged(int32_t aCanPlay)
{
mNode->SetCanPlay(aCanPlay == AudioChannelState::AUDIO_CHANNEL_STATE_NORMAL);
return NS_OK;
}
private:
nsRefPtr<AudioDestinationNode> mNode;
};
NS_IMPL_CYCLE_COLLECTION_1(AudioChannelAgentCallback, mNode)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(AudioChannelAgentCallback)
NS_INTERFACE_MAP_ENTRY(nsIAudioChannelAgentCallback)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(AudioChannelAgentCallback)
NS_IMPL_CYCLE_COLLECTING_RELEASE(AudioChannelAgentCallback)
static bool UseAudioChannelService()
{
return Preferences::GetBool("media.useAudioChannelService");
}
NS_IMPL_CYCLE_COLLECTION_INHERITED_1(AudioDestinationNode, AudioNode,
mAudioChannelAgent)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(AudioDestinationNode)
NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
NS_INTERFACE_MAP_END_INHERITING(AudioNode)
NS_IMPL_ADDREF_INHERITED(AudioDestinationNode, AudioNode)
NS_IMPL_RELEASE_INHERITED(AudioDestinationNode, AudioNode)
NS_IMPL_ISUPPORTS_INHERITED0(AudioDestinationNode, AudioNode)
AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
bool aIsOffline,
@ -288,30 +235,6 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
static_cast<AudioNodeEngine*>(new DestinationNodeEngine(this));
mStream = graph->CreateAudioNodeStream(engine, MediaStreamGraph::EXTERNAL_STREAM);
if (!aIsOffline && UseAudioChannelService()) {
mAudioChannelAgent = new AudioChannelAgent();
mAudioChannelAgent->Init(nsIAudioChannelAgent::AUDIO_AGENT_CHANNEL_NORMAL,
new AudioChannelAgentCallback(this));
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
if (target) {
target->AddSystemEventListener(NS_LITERAL_STRING("visibilitychange"), this,
/* useCapture = */ true,
/* wantsUntrusted = */ false);
}
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(GetOwner());
if (docshell) {
bool isActive = false;
docshell->GetIsActive(&isActive);
mAudioChannelAgent->SetVisibilityState(isActive);
}
int32_t state = 0;
mAudioChannelAgent->StartPlaying(&state);
SetCanPlay(state == AudioChannelState::AUDIO_CHANNEL_STATE_NORMAL);
}
}
void
@ -325,18 +248,6 @@ AudioDestinationNode::DestroyMediaStream()
MediaStreamGraph::DestroyNonRealtimeInstance(graph);
}
AudioNode::DestroyMediaStream();
if (mAudioChannelAgent && !Context()->IsOffline()) {
mAudioChannelAgent->StopPlaying();
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(GetOwner());
NS_ENSURE_TRUE_VOID(target);
target->RemoveSystemEventListener(NS_LITERAL_STRING("visibilitychange"), this,
/* useCapture = */ true);
mAudioChannelAgent = nullptr;
}
}
uint32_t
@ -393,31 +304,5 @@ AudioDestinationNode::StartRendering()
mStream->Graph()->StartNonRealtimeProcessing(mFramesToProduce);
}
void
AudioDestinationNode::SetCanPlay(bool aCanPlay)
{
mStream->SetTrackEnabled(AudioNodeStream::AUDIO_TRACK, aCanPlay);
}
NS_IMETHODIMP
AudioDestinationNode::HandleEvent(nsIDOMEvent* aEvent)
{
nsAutoString type;
aEvent->GetType(type);
if (!type.EqualsLiteral("visibilitychange")) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDocShell> docshell = do_GetInterface(GetOwner());
NS_ENSURE_TRUE(docshell, NS_ERROR_FAILURE);
bool isActive = false;
docshell->GetIsActive(&isActive);
mAudioChannelAgent->SetVisibilityState(isActive);
return NS_OK;
}
}
}

View File

@ -8,16 +8,13 @@
#define AudioDestinationNode_h_
#include "AudioNode.h"
#include "nsIDOMEventListener.h"
namespace mozilla {
namespace dom {
class AudioContext;
class AudioChannelAgent;
class AudioDestinationNode : public AudioNode
, public nsIDOMEventListener
{
public:
// This node type knows what MediaStreamGraph to use based on
@ -31,7 +28,6 @@ public:
virtual void DestroyMediaStream() MOZ_OVERRIDE;
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioDestinationNode, AudioNode)
virtual JSObject* WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
@ -52,17 +48,9 @@ public:
void OfflineShutdown();
// nsIDOMEventListener
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
// Used by AudioChannelAgentCallback
void SetCanPlay(bool aCanPlay);
private:
SelfReference<AudioDestinationNode> mOfflineRenderingRef;
uint32_t mFramesToProduce;
nsRefPtr<AudioChannelAgent> mAudioChannelAgent;
};
}