Jamoma API  0.6.0.a19
CAComponent.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 __CAComponent_h__
42 #define __CAComponent_h__
43 
44 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
45 #else
46  #include <ConditionalMacros.h>
47 #endif
48 
49 #include "CAComponentDescription.h"
50 
51 class CAComponent
52 {
53 public:
54  CAComponent ()
55  : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0) {}
56 
57  // if next is specifed that is used to find the next component after that one
58  CAComponent (const AudioComponentDescription& inDesc, CAComponent* next = 0);
59 
60  CAComponent (const CAComponent& y)
61  : mComp (0), mDesc(), mManuName(0), mAUName(0), mCompName(0) { *this = y; }
62 
63  CAComponent (const AudioComponent& comp);
64 
65  CAComponent (const AudioComponentInstance& compInst);
66 
67  CAComponent (OSType inType, OSType inSubtype = 0, OSType inManu = 0);
68 
69  ~CAComponent ();
70 
71  CAComponent& operator= (const CAComponent& y);
72 
73  // returns true if this object references a valid component
74  bool IsValid () const { return Comp() != 0; }
75 
76  bool HasAUStrings() const { SetCompNames (); return mManuName != 0; }
77 
78  // CFStringRef should be retained by caller if needed beyond lifetime of this object
79 
80  // Can return NULL if component doesn't follow AU naming conventions
81  CFStringRef GetAUManu () const { SetCompNames (); return mManuName; }
82  CFStringRef GetAUName () const { SetCompNames (); return mAUName ? mAUName : mCompName; }
83 
84  // Return value of NULL indicates a problem getting that information from the component
85  CFStringRef GetCompName () const { SetCompNames(); return mCompName; }
86 
87  const CAComponentDescription& Desc () const { return mDesc; }
88 
89  OSStatus Open (AudioComponentInstance& outInst) const
90  {
91  return AudioComponentInstanceNew (Comp(), &outInst);
92  }
93 
94  OSStatus GetVersion (UInt32 &outVersion) const;
95 
96  const AudioComponent& Comp() const { return mComp; }
97 
98  void Print(FILE* file = stdout) const;
99 
100  OSStatus Save (CFPropertyListRef *outData) const;
101 
102  OSStatus Restore (CFPropertyListRef &inData);
103 
104 private:
105  AudioComponent mComp;
106  CAComponentDescription mDesc;
107 
108  CFStringRef mManuName, mAUName, mCompName;
109 
110  void SetCompNames () const;
111  void SetCompInfo () const;
112  void Clear ();
113 };
114 
115 #endif