1 /*
2  * Copyright (C) 2010, Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1.  Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2.  Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
23  * DAMAGE.
24  */
25 
26 #ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_CHANNEL_SPLITTER_NODE_H_
27 #define THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_CHANNEL_SPLITTER_NODE_H_
28 
29 #include "base/memory/scoped_refptr.h"
30 #include "third_party/blink/renderer/modules/webaudio/audio_node.h"
31 
32 namespace blink {
33 
34 class BaseAudioContext;
35 class ChannelSplitterOptions;
36 
37 class ChannelSplitterHandler final : public AudioHandler {
38  public:
39   static scoped_refptr<ChannelSplitterHandler>
40   Create(AudioNode&, float sample_rate, unsigned number_of_outputs);
41 
42   // AudioHandler
43   void Process(uint32_t frames_to_process) override;
44   void SetChannelCount(unsigned, ExceptionState&) final;
45   void SetChannelCountMode(const String&, ExceptionState&) final;
46   void SetChannelInterpretation(const String&, ExceptionState&) final;
47 
TailTime()48   double TailTime() const override { return 0; }
LatencyTime()49   double LatencyTime() const override { return 0; }
RequiresTailProcessing()50   bool RequiresTailProcessing() const final { return false; }
51 
52  private:
53   ChannelSplitterHandler(AudioNode&,
54                          float sample_rate,
55                          unsigned number_of_outputs);
56 };
57 
58 class ChannelSplitterNode final : public AudioNode {
59   DEFINE_WRAPPERTYPEINFO();
60 
61  public:
62   static ChannelSplitterNode* Create(BaseAudioContext&, ExceptionState&);
63   static ChannelSplitterNode* Create(BaseAudioContext&,
64                                      unsigned number_of_outputs,
65                                      ExceptionState&);
66   static ChannelSplitterNode* Create(BaseAudioContext*,
67                                      const ChannelSplitterOptions*,
68                                      ExceptionState&);
69 
70   ChannelSplitterNode(BaseAudioContext&, unsigned number_of_outputs);
71 
72   // InspectorHelperMixin
73   void ReportDidCreate() final;
74   void ReportWillBeDestroyed() final;
75 };
76 
77 }  // namespace blink
78 
79 #endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_WEBAUDIO_CHANNEL_SPLITTER_NODE_H_
80