2012-09-18 16:07:33 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2012-10-30 14:39:38 -07:00
|
|
|
#ifndef AudioNode_h_
|
|
|
|
#define AudioNode_h_
|
2012-09-18 16:07:33 -07:00
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "EnableWebAudioCheck.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2012-09-24 20:31:58 -07:00
|
|
|
#include "nsTArray.h"
|
2012-09-18 16:07:33 -07:00
|
|
|
#include "AudioContext.h"
|
|
|
|
|
|
|
|
struct JSContext;
|
|
|
|
|
|
|
|
namespace mozilla {
|
2012-09-24 20:31:58 -07:00
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
2012-09-18 16:07:33 -07:00
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class AudioNode : public nsISupports,
|
|
|
|
public EnableWebAudioCheck
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AudioNode(AudioContext* aContext);
|
2013-01-23 16:50:18 -08:00
|
|
|
virtual ~AudioNode();
|
2012-09-18 16:07:33 -07:00
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2013-01-23 16:50:18 -08:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(AudioNode)
|
2012-09-18 16:07:33 -07:00
|
|
|
|
|
|
|
AudioContext* GetParentObject() const
|
|
|
|
{
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioContext* Context() const
|
|
|
|
{
|
|
|
|
return mContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Connect(AudioNode& aDestination, uint32_t aOutput,
|
2012-09-24 20:31:58 -07:00
|
|
|
uint32_t aInput, ErrorResult& aRv);
|
|
|
|
|
|
|
|
void Disconnect(uint32_t aOutput, ErrorResult& aRv);
|
|
|
|
|
|
|
|
// The following two virtual methods must be implemented by each node type
|
2013-01-23 16:50:18 -08:00
|
|
|
// to provide their number of input and output ports. These numbers are
|
|
|
|
// constant for the lifetime of the node. Both default to 1.
|
|
|
|
virtual uint32_t NumberOfInputs() const { return 1; }
|
|
|
|
virtual uint32_t NumberOfOutputs() const { return 1; }
|
|
|
|
|
|
|
|
struct InputNode {
|
|
|
|
// Strong reference.
|
|
|
|
// May be null if the source node has gone away.
|
|
|
|
nsRefPtr<AudioNode> mInputNode;
|
|
|
|
// The index of the input port this node feeds into.
|
|
|
|
uint32_t mInputPort;
|
|
|
|
// The index of the output port this node comes out of.
|
|
|
|
uint32_t mOutputPort;
|
2012-09-24 20:31:58 -07:00
|
|
|
};
|
2012-09-18 16:07:33 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<AudioContext> mContext;
|
2013-01-23 16:50:18 -08:00
|
|
|
|
|
|
|
// For every InputNode, there is a corresponding entry in mOutputNodes of the
|
|
|
|
// InputNode's mInputNode.
|
|
|
|
nsTArray<InputNode> mInputNodes;
|
|
|
|
// For every mOutputNode entry, there is a corresponding entry in mInputNodes
|
|
|
|
// of the mOutputNode entry. We won't necessarily be able to identify the
|
|
|
|
// exact matching entry, since mOutputNodes doesn't include the port
|
|
|
|
// identifiers and the same node could be connected on multiple ports.
|
|
|
|
nsTArray<nsRefPtr<AudioNode> > mOutputNodes;
|
2012-09-18 16:07:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-30 14:39:38 -07:00
|
|
|
#endif
|