Jamoma API  0.6.0.a19
AUDebugDispatcher.h
1 /* Copyright 2007 Apple Inc. All Rights Reserved.
2 
3  Disclaimer: IMPORTANT: This Apple software is supplied to you by
4  Apple Inc. ("Apple") in consideration of your agreement to the
5  following terms, and your use, installation, modification or
6  redistribution of this Apple software constitutes acceptance of these
7  terms. If you do not agree with these terms, please do not use,
8  install, modify or redistribute this Apple software.
9 
10  In consideration of your agreement to abide by the following terms, and
11  subject to these terms, Apple grants you a personal, non-exclusive
12  license, under Apple's copyrights in this original Apple software (the
13  "Apple Software"), to use, reproduce, modify and redistribute the Apple
14  Software, with or without modifications, in source and/or binary forms;
15  provided that if you redistribute the Apple Software in its entirety and
16  without modifications, you must retain this notice and the following
17  text and disclaimers in all such redistributions of the Apple Software.
18  Neither the name, trademarks, service marks or logos of Apple Inc.
19  may be used to endorse or promote products derived from the Apple
20  Software without specific prior written permission from Apple. Except
21  as expressly stated in this notice, no other rights or licenses, express
22  or implied, are granted by Apple herein, including but not limited to
23  any patent rights that may be infringed by your derivative works or by
24  other works in which the Apple Software may be incorporated.
25 
26  The Apple Software is provided by Apple on an "AS IS" basis. APPLE
27  MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
28  THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
29  FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
30  OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
31 
32  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
33  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35  INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
36  MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
37  AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
38  STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
39  POSSIBILITY OF SUCH DAMAGE.
40 */
41 /*=============================================================================
42  * AUDebugDispatcher.h
43  * CAServices
44 
45  =============================================================================*/
46 
47 #ifndef __AUDebugDispatcher_h__
48 #define __AUDebugDispatcher_h__
49 
50 #if AU_DEBUG_DISPATCHER
51 
52 #include "CAHostTimeBase.h"
53 #include "CAMutex.h"
54 #include "AUBase.h"
55 
56 
57 class AUDebugDispatcher {
58 public:
59  AUDebugDispatcher (AUBase *au, FILE* file = stdout);
60  ~AUDebugDispatcher();
61 
62 // these are the AU API calls
63  void Initialize (UInt64 nowTime, OSStatus result);
64 
65  void Uninitialize (UInt64 nowTime, OSStatus result);
66 
67  void GetPropertyInfo (UInt64 nowTime,
68  OSStatus result,
69  AudioUnitPropertyID inID,
70  AudioUnitScope inScope,
71  AudioUnitElement inElement,
72  UInt32 *outDataSize,
73  Boolean *outWritable);
74 
75  void GetProperty ( UInt64 nowTime,
76  OSStatus result,
77  AudioUnitPropertyID inID,
78  AudioUnitScope inScope,
79  AudioUnitElement inElement,
80  UInt32 *ioDataSize,
81  void *outData);
82 
83  void SetProperty ( UInt64 nowTime,
84  OSStatus result,
85  AudioUnitPropertyID inID,
86  AudioUnitScope inScope,
87  AudioUnitElement inElement,
88  const void * inData,
89  UInt32 inDataSize);
90 
91  void Render ( UInt64 nowTime,
92  OSStatus result,
93  AudioUnitRenderActionFlags * inRenderFlags,
94  const AudioTimeStamp * inTimeStamp,
95  UInt32 inOutputBusNumber,
96  UInt32 inNumFrames,
97  AudioBufferList * inIOData);
98 
99 private:
100  AUBase* mAUBase;
101  UInt64 mFirstTime;
102  FILE* mFile;
103  bool mHaveDoneProperty;
104  CAMutex mPrintMutex;
105 
106 
107  OSStatus mHostCB1_Result;
108  OSStatus mHostCB2_Result;
109  OSStatus mHostCB3_Result;
110  int mHostCB_WhenToPrint;
111  int mHostCB_WasPlaying;
112 
113  double SecsSinceStart(UInt64 inNowTime)
114  {
115  UInt64 nanos = CAHostTimeBase::ConvertToNanos(inNowTime - mFirstTime);
116  return nanos * 1.0e-9;
117  }
118 
119  unsigned int RecordDispatch (UInt64 inStartTime, OSStatus result, const char* inMethod);
120 
121  void PrintHeaderString (UInt64 inNowTime, unsigned int inThread, const char* inMethod);
122 
123  unsigned int AU() const { return (unsigned int)mAUBase->GetComponentInstance(); }
124 
125  void PrintProperty (AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement);
126 
127  void RenderActions_HostCallbacks ();
128 };
129 
130 #endif // AU_DEBUG_DISPATCHER
131 #endif //__AUDebugDispatcher_h__