1 /* Copyright: © Copyright 2005 Apple Computer, Inc. All rights reserved.
3 Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
4 ("Apple") in consideration of your agreement to the following terms, and your
5 use, installation, modification or redistribution of this Apple software
6 constitutes acceptance of these terms. If you do not agree with these terms,
7 please do not use, install, modify or redistribute this Apple software.
9 In consideration of your agreement to abide by the following terms, and subject
10 to these terms, Apple grants you a personal, non-exclusive license, under AppleÕs
11 copyrights in this original Apple software (the "Apple Software"), to use,
12 reproduce, modify and redistribute the Apple Software, with or without
13 modifications, in source and/or binary forms; provided that if you redistribute
14 the Apple Software in its entirety and without modifications, you must retain
15 this notice and the following text and disclaimers in all such redistributions of
16 the Apple Software. Neither the name, trademarks, service marks or logos of
17 Apple Computer, Inc. may be used to endorse or promote products derived from the
18 Apple Software without specific prior written permission from Apple. Except as
19 expressly stated in this notice, no other rights or licenses, express or implied,
20 are granted by Apple herein, including but not limited to any patent rights that
21 may be infringed by your derivative works or by other works in which the Apple
22 Software may be incorporated.
24 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
25 WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
26 WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
28 COMBINATION WITH YOUR PRODUCTS.
30 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
31 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
34 OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
35 (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
36 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 /*=============================================================================
41 =============================================================================*/
43 #ifndef __AUOutputBL_h__
44 #define __AUOutputBL_h__
46 #include "CAStreamBasicDescription.h"
47 #if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
48 #include <CoreServices/CoreServices.h>
50 #include <AssertMacros.h>
53 // ____________________________________________________________________________
55 // AUOutputBL - Simple Buffer List wrapper targetted to use with retrieving AU output
56 // Works in one of two ways (both adjustable)... Can use it with NULL pointers, or allocate
57 // memory to receive the data in.
59 // Before using this with any call to AudioUnitRender, it needs to be Prepared
60 // as some calls to AudioUnitRender can reset the ABL
65 // you CANNOT use one of these - it will crash!
68 // this is the constructor that you use
69 // it can't be reset once you've constructed it
70 AUOutputBL (const CAStreamBasicDescription
&inDesc
, UInt32 inDefaultNumFrames
= 512);
78 // this version can throw if this is an allocted ABL and inNumFrames is > AllocatedFrames()
79 // you can set the bool to true if you want a NULL buffer list even if allocated
80 // inNumFrames must be a valid number (will throw if inNumFrames is 0)
81 void Prepare (UInt32 inNumFrames
, bool inWantNullBufferIfAllocated
= false);
83 AudioBufferList
* ABL() { return mBufferList
; }
85 // You only need to call this if you want to allocate a buffer list
86 // if you want an empty buffer list, just call Prepare()
87 // if you want to dispose previously allocted memory, pass in 0
88 // then you either have an empty buffer list, or you can re-allocate
89 // Memory is kept around if an Allocation request is less than what is currently allocated
90 void Allocate (UInt32 inNumberFrames
);
92 UInt32
AllocatedFrames() const { return mFrames
; }
94 const CAStreamBasicDescription
& GetFormat() const { return mFormat
; }
101 UInt32
AllocatedBytes () const { return (mBufferSize
* mNumberBuffers
); }
103 CAStreamBasicDescription mFormat
;
105 AudioBufferList
* mBufferList
;
106 UInt32 mNumberBuffers
;
110 // don't want to copy these.. can if you want, but more code to write!
111 AUOutputBL (const AUOutputBL
&) {}
112 AUOutputBL
& operator= (const AUOutputBL
&) { return *this; }
115 #endif // __AUOutputBL_h__