1 /*
2 Copyright (C) 2016 Apple Inc. All Rights Reserved.
3 See LICENSE.txt for this sample’s licensing information
4 
5 Abstract:
6 Part of Core Audio AUBase Classes
7 */
8 
9 #ifndef __AUInput_h__
10 #define __AUInput_h__
11 
12 #include "AUScopeElement.h"
13 #include "AUBuffer.h"
14 
15 /*! @class AUInputElement */
16 class AUInputElement : public AUIOElement {
17 public:
18 
19 	/*! @ctor AUInputElement */
20 						AUInputElement(AUBase *audioUnit);
21 	/*! @dtor ~AUInputElement */
~AUInputElement()22 	virtual				~AUInputElement() { }
23 
24 	// AUElement override
25 	/*! @method SetStreamFormat */
26 	virtual OSStatus	SetStreamFormat(const CAStreamBasicDescription &desc);
27 	/*! @method NeedsBufferSpace */
NeedsBufferSpace()28 	virtual bool		NeedsBufferSpace() const { return IsCallback(); }
29 
30 	/*! @method SetConnection */
31 	void				SetConnection(const AudioUnitConnection &conn);
32 	/*! @method SetInputCallback */
33 	void				SetInputCallback(AURenderCallback proc, void *refCon);
34 
35 	/*! @method IsActive */
IsActive()36 	bool				IsActive() const { return mInputType != kNoInput; }
37 	/*! @method IsCallback */
IsCallback()38 	bool				IsCallback() const { return mInputType == kFromCallback; }
39 	/*! @method HasConnection */
HasConnection()40 	bool				HasConnection() const { return mInputType == kFromConnection; }
41 
42 	/*! @method PullInput */
43 	OSStatus			PullInput(	AudioUnitRenderActionFlags &  	ioActionFlags,
44 									const AudioTimeStamp &			inTimeStamp,
45 									AudioUnitElement				inElement,
46 									UInt32							inNumberFrames);
47 
48 	/*! @method PullInputWithBufferList */
49 	OSStatus			PullInputWithBufferList(	AudioUnitRenderActionFlags &  	ioActionFlags,
50 													const AudioTimeStamp &			inTimeStamp,
51 													AudioUnitElement				inElement,
52 													UInt32							nFrames,
53 													AudioBufferList *				inBufferList);
54 protected:
55 	/*! @method Disconnect */
56 	void				Disconnect();
57 
58 	enum EInputType { kNoInput, kFromConnection, kFromCallback };
59 
60 	/*! @var mInputType */
61 	EInputType					mInputType;
62 
63 	// if from callback:
64 	/*! @var mInputProc */
65 	AURenderCallback			mInputProc;
66 	/*! @var mInputProcRefCon */
67 	void *						mInputProcRefCon;
68 
69 	// if from connection:
70 	/*! @var mConnection */
71 	AudioUnitConnection			mConnection;
72 #if !CA_USE_AUDIO_PLUGIN_ONLY
73 	/*! @var mConnRenderProc */
74 	AudioUnitRenderProc			mConnRenderProc;
75 #endif
76 	/*! @var mConnInstanceStorage */
77 	void *						mConnInstanceStorage;		// for the input component
78 };
79 
80 
81 #endif // __AUInput_h__
82