Jamoma API  0.6.0.a19
CAComponentDescription.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 #ifndef __CAComponentDescription_h__
42 #define __CAComponentDescription_h__
43 
44 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
45  #include <AudioUnit/AudioUnit.h>
46 #else
47  #include <ConditionalMacros.h>
48  #include <AudioUnit.h>
49 #endif
50 
51 #include "CACFDictionary.h"
52 #include <stdio.h>
53 #include <string.h>
54 
55 void CAShowComponentDescription(const AudioComponentDescription *desc);
56 
57 // ____________________________________________________________________________
58 //
59 // CAComponentDescription
60 class CAComponentDescription : public AudioComponentDescription {
61 public:
62  CAComponentDescription() { memset (this, 0, sizeof (AudioComponentDescription)); }
63 
64  CAComponentDescription (OSType inType, OSType inSubtype = 0, OSType inManu = 0);
65 
66  CAComponentDescription(const AudioComponentDescription& desc) { memcpy (this, &desc, sizeof (AudioComponentDescription)); }
67 
68  // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
69  //
70  // interrogation
71 
72  bool IsAU () const;
73 
74  bool IsAUFX() const { return componentType == kAudioUnitType_Effect; }
75  bool IsAUFM() const { return componentType == kAudioUnitType_MusicEffect; }
76 
77  bool IsEffect () const { return IsAUFX() || IsAUFM() || IsPanner(); }
78 
79  bool IsOffline () const { return componentType == 'auol'; }
80 
81  bool IsFConv () const { return componentType == kAudioUnitType_FormatConverter; }
82 
83  bool IsPanner () const { return componentType == kAudioUnitType_Panner; }
84 
85  bool IsMusicDevice () const { return componentType == kAudioUnitType_MusicDevice; }
86 
87 #ifndef MAC_OS_X_VERSION_10_4
88  bool IsGenerator () const { return componentType =='augn'; }
89 #else
90  bool IsGenerator () const { return componentType ==kAudioUnitType_Generator; }
91 #endif
92 
93  bool IsOutput () const { return componentType == kAudioUnitType_Output; }
94 
95  bool IsSource () const { return IsMusicDevice() || IsGenerator(); }
96 
97  OSType Type () const { return componentType; }
98  OSType SubType () const { return componentSubType; }
99  OSType Manu () const { return componentManufacturer; }
100 
101  int Count() const { return AudioComponentCount(const_cast<CAComponentDescription*>(this)); }
102 
103  // does a semantic match where "wild card" values for type, subtype, manu will match
104  bool Matches (const AudioComponentDescription &desc) const;
105 
106  // _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
107  //
108  // other
109 
110  void Print(FILE* file = stdout) const { _CAShowComponentDescription (this, file); }
111 
112  OSStatus Save (CFPropertyListRef *outData) const;
113  OSStatus Restore (CFPropertyListRef &inData);
114 
115 private:
116  static void _CAShowComponentDescription (const AudioComponentDescription *desc, FILE* file);
117  friend void CAShowComponentDescription (const AudioComponentDescription *desc);
118 };
119 
120 inline bool operator< (const AudioComponentDescription& x, const AudioComponentDescription& y)
121 {
122  return memcmp (&x, &y, offsetof (AudioComponentDescription, componentFlags)) < 0;
123 }
124 
125 inline bool operator== (const AudioComponentDescription& x, const AudioComponentDescription& y)
126 {
127  return !memcmp (&x, &y, offsetof (AudioComponentDescription, componentFlags));
128 }
129 
130 inline bool operator!= (const AudioComponentDescription& x, const AudioComponentDescription& y)
131 {
132  return !(x == y);
133 }
134 
135 #endif
bool TTFOUNDATION_EXPORT operator!=(const TTObject &anObject, const TTObject &anotherObject)
Compare two objects for inequality.
Definition: TTObject.cpp:173
bool TTFOUNDATION_EXPORT operator==(const TTObject &anObject, const TTObject &anotherObject)
Compare two objects for equality.
Definition: TTObject.cpp:167