Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/webaudio/ConvolverNode.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim:set ts=2 sw=2 sts=2 et cindent: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef ConvolverNode_h_
8
#define ConvolverNode_h_
9
10
#include "AudioNode.h"
11
#include "AudioBuffer.h"
12
13
namespace mozilla {
14
namespace dom {
15
16
class AudioContext;
17
struct ConvolverOptions;
18
19
class ConvolverNode final : public AudioNode
20
{
21
public:
22
  static already_AddRefed<ConvolverNode>
23
  Create(JSContext* aCx, AudioContext& aAudioContext,
24
         const ConvolverOptions& aOptions, ErrorResult& aRv);
25
26
  NS_DECL_ISUPPORTS_INHERITED
27
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ConvolverNode, AudioNode);
28
29
  static already_AddRefed<ConvolverNode>
30
  Constructor(const GlobalObject& aGlobal, AudioContext& aAudioContext,
31
              const ConvolverOptions& aOptions, ErrorResult& aRv)
32
  {
33
    return Create(aGlobal.Context(), aAudioContext, aOptions, aRv);
34
  }
35
36
  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
37
38
  AudioBuffer* GetBuffer(JSContext* aCx) const
39
  {
40
    return mBuffer;
41
  }
42
43
  void SetBuffer(JSContext* aCx, AudioBuffer* aBuffer, ErrorResult& aRv);
44
45
  bool Normalize() const
46
  {
47
    return mNormalize;
48
  }
49
50
  void SetNormalize(bool aNormal);
51
52
  void SetChannelCount(uint32_t aChannelCount, ErrorResult& aRv) override
53
0
  {
54
0
    if (aChannelCount > 2) {
55
0
      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
56
0
      return;
57
0
    }
58
0
    AudioNode::SetChannelCount(aChannelCount, aRv);
59
0
  }
60
  void SetChannelCountModeValue(ChannelCountMode aMode, ErrorResult& aRv) override
61
0
  {
62
0
    if (aMode == ChannelCountMode::Max) {
63
0
      aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
64
0
      return;
65
0
    }
66
0
    AudioNode::SetChannelCountModeValue(aMode, aRv);
67
0
  }
68
69
  const char* NodeType() const override
70
0
  {
71
0
    return "ConvolverNode";
72
0
  }
73
74
  size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
75
  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
76
77
private:
78
  explicit ConvolverNode(AudioContext* aContext);
79
0
  ~ConvolverNode() = default;
80
81
  RefPtr<AudioBuffer> mBuffer;
82
  bool mNormalize;
83
};
84
85
86
} //end namespace dom
87
} //end namespace mozilla
88
89
#endif