2013-04-13 18:37:04 -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/. */
|
|
|
|
|
|
|
|
#ifndef ScriptProcessorNode_h_
|
|
|
|
#define ScriptProcessorNode_h_
|
|
|
|
|
|
|
|
#include "AudioNode.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class AudioContext;
|
|
|
|
class SharedBuffers;
|
|
|
|
|
|
|
|
class ScriptProcessorNode : public AudioNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ScriptProcessorNode(AudioContext* aContext,
|
|
|
|
uint32_t aBufferSize,
|
|
|
|
uint32_t aNumberOfInputChannels,
|
|
|
|
uint32_t aNumberOfOutputChannels);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(audioprocess)
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-04-13 18:37:04 -07:00
|
|
|
|
2013-04-22 18:23:54 -07:00
|
|
|
virtual void Connect(AudioNode& aDestination, uint32_t aOutput,
|
|
|
|
uint32_t aInput, ErrorResult& aRv) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
AudioNode::Connect(aDestination, aOutput, aInput, aRv);
|
|
|
|
if (!aRv.Failed()) {
|
2013-09-23 18:46:30 -07:00
|
|
|
MarkActive();
|
2013-04-22 18:23:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-01 15:59:02 -07:00
|
|
|
virtual void Connect(AudioParam& aDestination, uint32_t aOutput,
|
|
|
|
ErrorResult& aRv) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
AudioNode::Connect(aDestination, aOutput, aRv);
|
|
|
|
if (!aRv.Failed()) {
|
2013-09-23 18:46:30 -07:00
|
|
|
MarkActive();
|
2013-05-01 15:59:02 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-22 18:23:54 -07:00
|
|
|
virtual void Disconnect(uint32_t aOutput, ErrorResult& aRv) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
AudioNode::Disconnect(aOutput, aRv);
|
2013-09-23 18:46:30 -07:00
|
|
|
if (!aRv.Failed() && OutputNodes().IsEmpty() && OutputParams().IsEmpty()) {
|
|
|
|
MarkInactive();
|
2013-04-22 18:23:54 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 12:44:37 -07:00
|
|
|
virtual void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (aChannelCount != ChannelCount()) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
virtual void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv) MOZ_OVERRIDE
|
|
|
|
{
|
|
|
|
if (aMode != ChannelCountMode::Explicit) {
|
|
|
|
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-04-13 18:37:04 -07:00
|
|
|
uint32_t BufferSize() const
|
|
|
|
{
|
|
|
|
return mBufferSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedBuffers* GetSharedBuffers() const
|
|
|
|
{
|
|
|
|
return mSharedBuffers;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t NumberOfOutputChannels() const
|
|
|
|
{
|
|
|
|
return mNumberOfOutputChannels;
|
|
|
|
}
|
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
using DOMEventTargetHelper::DispatchTrustedEvent;
|
2013-04-13 18:37:04 -07:00
|
|
|
|
2014-04-13 11:08:10 -07:00
|
|
|
virtual const char* NodeType() const
|
|
|
|
{
|
|
|
|
return "ScriptProcessorNode";
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
|
|
|
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE;
|
|
|
|
|
2014-07-08 14:23:17 -07:00
|
|
|
protected:
|
|
|
|
virtual ~ScriptProcessorNode();
|
|
|
|
|
2013-04-13 18:37:04 -07:00
|
|
|
private:
|
|
|
|
nsAutoPtr<SharedBuffers> mSharedBuffers;
|
|
|
|
const uint32_t mBufferSize;
|
|
|
|
const uint32_t mNumberOfOutputChannels;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|