OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 26 matching lines...) Expand all Loading... |
37 #include "wtf/Vector.h" | 37 #include "wtf/Vector.h" |
38 #include <memory> | 38 #include <memory> |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class AudioBus; | 42 class AudioBus; |
43 class AudioDSPKernel; | 43 class AudioDSPKernel; |
44 class AudioProcessor; | 44 class AudioProcessor; |
45 | 45 |
46 // AudioDSPKernelProcessor processes one input -> one output (N channels each) | 46 // AudioDSPKernelProcessor processes one input -> one output (N channels each) |
47 // It uses one AudioDSPKernel object per channel to do the processing, thus ther
e is no cross-channel processing. | 47 // It uses one AudioDSPKernel object per channel to do the processing, thus |
48 // Despite this limitation it turns out to be a very common and useful type of p
rocessor. | 48 // there is no cross-channel processing. Despite this limitation it turns out |
| 49 // to be a very common and useful type of processor. |
49 | 50 |
50 class PLATFORM_EXPORT AudioDSPKernelProcessor : public AudioProcessor { | 51 class PLATFORM_EXPORT AudioDSPKernelProcessor : public AudioProcessor { |
51 public: | 52 public: |
52 // numberOfChannels may be later changed if object is not yet in an "initializ
ed" state | 53 // numberOfChannels may be later changed if object is not yet in an |
| 54 // "initialized" state |
53 AudioDSPKernelProcessor(float sampleRate, unsigned numberOfChannels); | 55 AudioDSPKernelProcessor(float sampleRate, unsigned numberOfChannels); |
54 | 56 |
55 // Subclasses create the appropriate type of processing kernel here. | 57 // Subclasses create the appropriate type of processing kernel here. |
56 // We'll call this to create a kernel for each channel. | 58 // We'll call this to create a kernel for each channel. |
57 virtual std::unique_ptr<AudioDSPKernel> createKernel() = 0; | 59 virtual std::unique_ptr<AudioDSPKernel> createKernel() = 0; |
58 | 60 |
59 // AudioProcessor methods | 61 // AudioProcessor methods |
60 void initialize() override; | 62 void initialize() override; |
61 void uninitialize() override; | 63 void uninitialize() override; |
62 void process(const AudioBus* source, | 64 void process(const AudioBus* source, |
63 AudioBus* destination, | 65 AudioBus* destination, |
64 size_t framesToProcess) override; | 66 size_t framesToProcess) override; |
65 void reset() override; | 67 void reset() override; |
66 void setNumberOfChannels(unsigned) override; | 68 void setNumberOfChannels(unsigned) override; |
67 unsigned numberOfChannels() const override { return m_numberOfChannels; } | 69 unsigned numberOfChannels() const override { return m_numberOfChannels; } |
68 | 70 |
69 double tailTime() const override; | 71 double tailTime() const override; |
70 double latencyTime() const override; | 72 double latencyTime() const override; |
71 | 73 |
72 protected: | 74 protected: |
73 Vector<std::unique_ptr<AudioDSPKernel>> m_kernels; | 75 Vector<std::unique_ptr<AudioDSPKernel>> m_kernels; |
74 mutable Mutex m_processLock; | 76 mutable Mutex m_processLock; |
75 bool m_hasJustReset; | 77 bool m_hasJustReset; |
76 }; | 78 }; |
77 | 79 |
78 } // namespace blink | 80 } // namespace blink |
79 | 81 |
80 #endif // AudioDSPKernelProcessor_h | 82 #endif // AudioDSPKernelProcessor_h |
OLD | NEW |