1 /*
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef __JFXMedia__AVFKernelProcessor__
27 #define __JFXMedia__AVFKernelProcessor__
28
29 #include "AUEffectBase.h"
30
31
32 /*
33 * Instead of writing N components that all basically function the same (at the
34 * component level), we'll skip the complexity and just write one component that
35 * handles everything by use of a abstract base class.
36 */
37
38 /*
39 * Abstract base class used by the common AudioUnit to manage kernels. All
40 * processing states must be managed in this class, rather than using properties
41 * or parameters of the AudioUnit (since this is all private and in-process)
42 */
43 class AVFKernelProcessor {
44 public:
45 AVFKernelProcessor() :
46 mAudioUnit(NULL)
47 {}
48
63 */
64 virtual AUKernelBase *NewKernel() {
65 return NULL;
66 }
67
68 virtual OSStatus ProcessBufferLists(AudioUnitRenderActionFlags& ioActionFlags,
69 const AudioBufferList& inBuffer,
70 AudioBufferList& outBuffer,
71 UInt32 inFramesToProcess) {
72 return noErr;
73 }
74
75
76 virtual void StreamFormatChanged(const CAStreamBasicDescription &newFormat) {}
77
78 protected:
79 AUEffectBase *mAudioUnit;
80 };
81
82 /*
83 * Returns an instance of our common AudioUnit set up to use the given kernel
84 */
85 extern AudioUnit NewKernelProcessorUnit(AVFKernelProcessor *kernel);
86
87 #endif /* defined(__JFXMedia__AVFKernelProcessor__) */
|
1 /*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef __JFXMedia__AVFKernelProcessor__
27 #define __JFXMedia__AVFKernelProcessor__
28
29 #include <memory>
30
31 #include "AUEffectBase.h"
32
33
34 /*
35 * Instead of writing N components that all basically function the same (at the
36 * component level), we'll skip the complexity and just write one component that
37 * handles everything by use of a abstract base class.
38 */
39
40 /*
41 * Abstract base class used by the common AudioUnit to manage kernels. All
42 * processing states must be managed in this class, rather than using properties
43 * or parameters of the AudioUnit (since this is all private and in-process)
44 */
45 class AVFKernelProcessor {
46 public:
47 AVFKernelProcessor() :
48 mAudioUnit(NULL)
49 {}
50
65 */
66 virtual AUKernelBase *NewKernel() {
67 return NULL;
68 }
69
70 virtual OSStatus ProcessBufferLists(AudioUnitRenderActionFlags& ioActionFlags,
71 const AudioBufferList& inBuffer,
72 AudioBufferList& outBuffer,
73 UInt32 inFramesToProcess) {
74 return noErr;
75 }
76
77
78 virtual void StreamFormatChanged(const CAStreamBasicDescription &newFormat) {}
79
80 protected:
81 AUEffectBase *mAudioUnit;
82 };
83
84 /*
85 * Shared pointer that handles deleting the kernel when it's no longer in use.
86 * Please use this instead of raw pointers.
87 */
88
89 typedef std::shared_ptr<AVFKernelProcessor> AVFKernelProcessorPtr;
90
91 /*
92 * Returns an instance of our common AudioUnit set up to use the given kernel.
93 * Use static_pointer_cast<AVFKernelProcessor>(kernelPtr) when passing a subclass
94 */
95 AudioUnit NewKernelProcessorUnit(AVFKernelProcessorPtr kernel);
96
97 #endif /* defined(__JFXMedia__AVFKernelProcessor__) */
|