annotate src/portaudio/include/pa_mac_core.h @ 17:59685d5285b1

Merge
author Chris Cannam <chris.cannam@eecs.qmul.ac.uk>
date Mon, 25 Mar 2013 12:24:36 +0000
parents e13257ea84a4
children
rev   line source
Chris@4 1 #ifndef PA_MAC_CORE_H
Chris@4 2 #define PA_MAC_CORE_H
Chris@4 3 /*
Chris@4 4 * PortAudio Portable Real-Time Audio Library
Chris@4 5 * Macintosh Core Audio specific extensions
Chris@4 6 * portaudio.h should be included before this file.
Chris@4 7 *
Chris@4 8 * Copyright (c) 2005-2006 Bjorn Roche
Chris@4 9 *
Chris@4 10 * Permission is hereby granted, free of charge, to any person obtaining
Chris@4 11 * a copy of this software and associated documentation files
Chris@4 12 * (the "Software"), to deal in the Software without restriction,
Chris@4 13 * including without limitation the rights to use, copy, modify, merge,
Chris@4 14 * publish, distribute, sublicense, and/or sell copies of the Software,
Chris@4 15 * and to permit persons to whom the Software is furnished to do so,
Chris@4 16 * subject to the following conditions:
Chris@4 17 *
Chris@4 18 * The above copyright notice and this permission notice shall be
Chris@4 19 * included in all copies or substantial portions of the Software.
Chris@4 20 *
Chris@4 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Chris@4 22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Chris@4 23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Chris@4 24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
Chris@4 25 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
Chris@4 26 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
Chris@4 27 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Chris@4 28 */
Chris@4 29
Chris@4 30 /*
Chris@4 31 * The text above constitutes the entire PortAudio license; however,
Chris@4 32 * the PortAudio community also makes the following non-binding requests:
Chris@4 33 *
Chris@4 34 * Any person wishing to distribute modifications to the Software is
Chris@4 35 * requested to send the modifications to the original developer so that
Chris@4 36 * they can be incorporated into the canonical version. It is also
Chris@4 37 * requested that these non-binding requests be included along with the
Chris@4 38 * license above.
Chris@4 39 */
Chris@4 40
Chris@4 41 /** @file
Chris@4 42 * @ingroup public_header
Chris@4 43 * @brief CoreAudio-specific PortAudio API extension header file.
Chris@4 44 */
Chris@4 45
Chris@4 46 #include "portaudio.h"
Chris@4 47
Chris@4 48 #include <AudioUnit/AudioUnit.h>
Chris@4 49 //#include <AudioToolbox/AudioToolbox.h>
Chris@4 50
Chris@4 51 #ifdef __cplusplus
Chris@4 52 extern "C" {
Chris@4 53 #endif
Chris@4 54
Chris@4 55
Chris@4 56 /**
Chris@4 57 * A pointer to a paMacCoreStreamInfo may be passed as
Chris@4 58 * the hostApiSpecificStreamInfo in the PaStreamParameters struct
Chris@4 59 * when opening a stream or querying the format. Use NULL, for the
Chris@4 60 * defaults. Note that for duplex streams, flags for input and output
Chris@4 61 * should be the same or behaviour is undefined.
Chris@4 62 */
Chris@4 63 typedef struct
Chris@4 64 {
Chris@4 65 unsigned long size; /**size of whole structure including this header */
Chris@4 66 PaHostApiTypeId hostApiType; /**host API for which this data is intended */
Chris@4 67 unsigned long version; /**structure version */
Chris@4 68 unsigned long flags; /** flags to modify behaviour */
Chris@4 69 SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
Chris@4 70 unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
Chris@4 71 } PaMacCoreStreamInfo;
Chris@4 72
Chris@4 73 /**
Chris@4 74 * Functions
Chris@4 75 */
Chris@4 76
Chris@4 77
Chris@4 78 /** Use this function to initialize a paMacCoreStreamInfo struct
Chris@4 79 * using the requested flags. Note that channel mapping is turned
Chris@4 80 * off after a call to this function.
Chris@4 81 * @param data The datastructure to initialize
Chris@4 82 * @param flags The flags to initialize the datastructure with.
Chris@4 83 */
Chris@4 84 void PaMacCore_SetupStreamInfo( PaMacCoreStreamInfo *data, unsigned long flags );
Chris@4 85
Chris@4 86 /** call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
Chris@4 87 * @param data The stream info structure to assign a channel mapping to
Chris@4 88 * @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.
Chris@4 89 * @param channelMapSize The size of the channel map array.
Chris@4 90 */
Chris@4 91 void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const channelMap, unsigned long channelMapSize );
Chris@4 92
Chris@4 93 /**
Chris@4 94 * Retrieve the AudioDeviceID of the input device assigned to an open stream
Chris@4 95 *
Chris@4 96 * @param s The stream to query.
Chris@4 97 *
Chris@4 98 * @return A valid AudioDeviceID, or NULL if an error occurred.
Chris@4 99 */
Chris@4 100 AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
Chris@4 101
Chris@4 102 /**
Chris@4 103 * Retrieve the AudioDeviceID of the output device assigned to an open stream
Chris@4 104 *
Chris@4 105 * @param s The stream to query.
Chris@4 106 *
Chris@4 107 * @return A valid AudioDeviceID, or NULL if an error occurred.
Chris@4 108 */
Chris@4 109 AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
Chris@4 110
Chris@4 111 /**
Chris@4 112 * Returns a statically allocated string with the device's name
Chris@4 113 * for the given channel. NULL will be returned on failure.
Chris@4 114 *
Chris@4 115 * This function's implemenation is not complete!
Chris@4 116 *
Chris@4 117 * @param device The PortAudio device index.
Chris@4 118 * @param channel The channel number who's name is requested.
Chris@4 119 * @return a statically allocated string with the name of the device.
Chris@4 120 * Because this string is statically allocated, it must be
Chris@4 121 * coppied if it is to be saved and used by the user after
Chris@4 122 * another call to this function.
Chris@4 123 *
Chris@4 124 */
Chris@4 125 const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
Chris@4 126
Chris@4 127 /**
Chris@4 128 * Flags
Chris@4 129 */
Chris@4 130
Chris@4 131 /**
Chris@4 132 * The following flags alter the behaviour of PA on the mac platform.
Chris@4 133 * they can be ORed together. These should work both for opening and
Chris@4 134 * checking a device.
Chris@4 135 */
Chris@4 136
Chris@4 137 /** Allows PortAudio to change things like the device's frame size,
Chris@4 138 * which allows for much lower latency, but might disrupt the device
Chris@4 139 * if other programs are using it, even when you are just Querying
Chris@4 140 * the device. */
Chris@4 141 #define paMacCoreChangeDeviceParameters (0x01)
Chris@4 142
Chris@4 143 /** In combination with the above flag,
Chris@4 144 * causes the stream opening to fail, unless the exact sample rates
Chris@4 145 * are supported by the device. */
Chris@4 146 #define paMacCoreFailIfConversionRequired (0x02)
Chris@4 147
Chris@4 148 /** These flags set the SR conversion quality, if required. The wierd ordering
Chris@4 149 * allows Maximum Quality to be the default.*/
Chris@4 150 #define paMacCoreConversionQualityMin (0x0100)
Chris@4 151 #define paMacCoreConversionQualityMedium (0x0200)
Chris@4 152 #define paMacCoreConversionQualityLow (0x0300)
Chris@4 153 #define paMacCoreConversionQualityHigh (0x0400)
Chris@4 154 #define paMacCoreConversionQualityMax (0x0000)
Chris@4 155
Chris@4 156 /**
Chris@4 157 * Here are some "preset" combinations of flags (above) to get to some
Chris@4 158 * common configurations. THIS IS OVERKILL, but if more flags are added
Chris@4 159 * it won't be.
Chris@4 160 */
Chris@4 161
Chris@4 162 /**This is the default setting: do as much sample rate conversion as possible
Chris@4 163 * and as little mucking with the device as possible. */
Chris@4 164 #define paMacCorePlayNice (0x00)
Chris@4 165 /**This setting is tuned for pro audio apps. It allows SR conversion on input
Chris@4 166 and output, but it tries to set the appropriate SR on the device.*/
Chris@4 167 #define paMacCorePro (0x01)
Chris@4 168 /**This is a setting to minimize CPU usage and still play nice.*/
Chris@4 169 #define paMacCoreMinimizeCPUButPlayNice (0x0100)
Chris@4 170 /**This is a setting to minimize CPU usage, even if that means interrupting the device. */
Chris@4 171 #define paMacCoreMinimizeCPU (0x0101)
Chris@4 172
Chris@4 173
Chris@4 174 #ifdef __cplusplus
Chris@4 175 }
Chris@4 176 #endif /** __cplusplus */
Chris@4 177
Chris@4 178 #endif /** PA_MAC_CORE_H */