pa_mac_core.h 7.4 KB

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