Julius 4.2
msvc/portaudio/pa_mac_core.h
00001 #ifndef PA_MAC_CORE_H
00002 #define PA_MAC_CORE_H
00003 /*
00004  * PortAudio Portable Real-Time Audio Library
00005  * Macintosh Core Audio specific extensions
00006  * portaudio.h should be included before this file.
00007  *
00008  * Copyright (c) 2005-2006 Bjorn Roche
00009  *
00010  * Permission is hereby granted, free of charge, to any person obtaining
00011  * a copy of this software and associated documentation files
00012  * (the "Software"), to deal in the Software without restriction,
00013  * including without limitation the rights to use, copy, modify, merge,
00014  * publish, distribute, sublicense, and/or sell copies of the Software,
00015  * and to permit persons to whom the Software is furnished to do so,
00016  * subject to the following conditions:
00017  *
00018  * The above copyright notice and this permission notice shall be
00019  * included in all copies or substantial portions of the Software.
00020  *
00021  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00025  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00026  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00027  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00028  */
00029 
00030 /*
00031  * The text above constitutes the entire PortAudio license; however, 
00032  * the PortAudio community also makes the following non-binding requests:
00033  *
00034  * Any person wishing to distribute modifications to the Software is
00035  * requested to send the modifications to the original developer so that
00036  * they can be incorporated into the canonical version. It is also 
00037  * requested that these non-binding requests be included along with the 
00038  * license above.
00039  */
00040 
00041 #include <AudioUnit/AudioUnit.h>
00042 //#include <AudioToolbox/AudioToolbox.h>
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 
00049 /*
00050  * A pointer to a paMacCoreStreamInfo may be passed as
00051  * the hostApiSpecificStreamInfo in the PaStreamParameters struct
00052  * when opening a stream or querying the format. Use NULL, for the
00053  * defaults. Note that for duplex streams, flags for input and output
00054  * should be the same or behaviour is undefined.
00055  */
00056 typedef struct
00057 {
00058     unsigned long size;           
00059     PaHostApiTypeId hostApiType;  
00060     unsigned long version;        
00061     unsigned long flags;          /* flags to modify behaviour */
00062     SInt32 const * channelMap;    /* Channel map for HAL channel mapping , if not needed, use NULL;*/ 
00063     unsigned long channelMapSize; /* Channel map size for HAL channel mapping , if not needed, use 0;*/ 
00064 } PaMacCoreStreamInfo;
00065 
00066 /*
00067  * Functions
00068  */
00069 
00070 
00071 /* Use this function to initialize a paMacCoreStreamInfo struct
00072  * using the requested flags. Note that channel mapping is turned
00073  * off after a call to this function.
00074  * @param data The datastructure to initialize
00075  * @param flags The flags to initialize the datastructure with.
00076 */
00077 void PaMacCore_SetupStreamInfo( PaMacCoreStreamInfo *data, unsigned long flags );
00078 
00079 /* call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
00080  * @param data The stream info structure to assign a channel mapping to
00081  * @param channelMap The channel map array, as described in notes.txt. This array pointer will be used directly (ie the underlying data will not be copied), so the caller should not free the array until after the stream has been opened.
00082  * @param channelMapSize The size of the channel map array.
00083  */
00084 void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const channelMap, unsigned long channelMapSize );
00085 
00086 /*
00087  * Retrieve the AudioDeviceID of the input device assigned to an open stream
00088  *
00089  * @param s The stream to query.
00090  *
00091  * @return A valid AudioDeviceID, or NULL if an error occurred.
00092  */
00093 AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
00094  
00095 /*
00096  * Retrieve the AudioDeviceID of the output device assigned to an open stream
00097  *
00098  * @param s The stream to query.
00099  *
00100  * @return A valid AudioDeviceID, or NULL if an error occurred.
00101  */
00102 AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
00103 
00104 /*
00105  * Returns a statically allocated string with the device's name
00106  * for the given channel. NULL will be returned on failure.
00107  *
00108  * This function's implemenation is not complete!
00109  *
00110  * @param device The PortAudio device index.
00111  * @param channel The channel number who's name is requested.
00112  * @return a statically allocated string with the name of the device.
00113  *         Because this string is statically allocated, it must be
00114  *         coppied if it is to be saved and used by the user after
00115  *         another call to this function.
00116  *
00117  */
00118 const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
00119 
00120 /*
00121  * Flags
00122  */
00123 
00124 /*
00125  * The following flags alter the behaviour of PA on the mac platform.
00126  * they can be ORed together. These should work both for opening and
00127  * checking a device.
00128  */
00129 
00130 /* Allows PortAudio to change things like the device's frame size,
00131  * which allows for much lower latency, but might disrupt the device
00132  * if other programs are using it, even when you are just Querying
00133  * the device. */
00134 #define paMacCoreChangeDeviceParameters (0x01)
00135 
00136 /* In combination with the above flag,
00137  * causes the stream opening to fail, unless the exact sample rates
00138  * are supported by the device. */
00139 #define paMacCoreFailIfConversionRequired (0x02)
00140 
00141 /* These flags set the SR conversion quality, if required. The wierd ordering
00142  * allows Maximum Quality to be the default.*/
00143 #define paMacCoreConversionQualityMin    (0x0100)
00144 #define paMacCoreConversionQualityMedium (0x0200)
00145 #define paMacCoreConversionQualityLow    (0x0300)
00146 #define paMacCoreConversionQualityHigh   (0x0400)
00147 #define paMacCoreConversionQualityMax    (0x0000)
00148 
00149 /*
00150  * Here are some "preset" combinations of flags (above) to get to some
00151  * common configurations. THIS IS OVERKILL, but if more flags are added
00152  * it won't be.
00153  */
00154 
00155 /*This is the default setting: do as much sample rate conversion as possible
00156  * and as little mucking with the device as possible. */
00157 #define paMacCorePlayNice                    (0x00)
00158 /*This setting is tuned for pro audio apps. It allows SR conversion on input
00159   and output, but it tries to set the appropriate SR on the device.*/
00160 #define paMacCorePro                         (0x01)
00161 /*This is a setting to minimize CPU usage and still play nice.*/
00162 #define paMacCoreMinimizeCPUButPlayNice      (0x0100)
00163 /*This is a setting to minimize CPU usage, even if that means interrupting the device. */
00164 #define paMacCoreMinimizeCPU                 (0x0101)
00165 
00166 
00167 #ifdef __cplusplus
00168 }
00169 #endif /* __cplusplus */
00170 
00171 #endif /* PA_MAC_CORE_H */