• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

pa_mac_core_internal.h

Go to the documentation of this file.
00001 /*
00002  * Internal interfaces for PortAudio Apple AUHAL implementation
00003  *
00004  * PortAudio Portable Real-Time Audio Library
00005  * Latest Version at: http://www.portaudio.com
00006  *
00007  * Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
00008  * Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
00009  *
00010  * Dominic's code was based on code by Phil Burk, Darren Gibbs,
00011  * Gord Peters, Stephane Letz, and Greg Pfiel.
00012  *
00013  * The following people also deserve acknowledgements:
00014  *
00015  * Olivier Tristan for feedback and testing
00016  * Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
00017  * interface.
00018  * 
00019  *
00020  * Based on the Open Source API proposed by Ross Bencina
00021  * Copyright (c) 1999-2002 Ross Bencina, Phil Burk
00022  *
00023  * Permission is hereby granted, free of charge, to any person obtaining
00024  * a copy of this software and associated documentation files
00025  * (the "Software"), to deal in the Software without restriction,
00026  * including without limitation the rights to use, copy, modify, merge,
00027  * publish, distribute, sublicense, and/or sell copies of the Software,
00028  * and to permit persons to whom the Software is furnished to do so,
00029  * subject to the following conditions:
00030  *
00031  * The above copyright notice and this permission notice shall be
00032  * included in all copies or substantial portions of the Software.
00033  *
00034  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00035  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00036  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00037  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00038  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00039  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00040  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00041  */
00042 
00043 /*
00044  * The text above constitutes the entire PortAudio license; however, 
00045  * the PortAudio community also makes the following non-binding requests:
00046  *
00047  * Any person wishing to distribute modifications to the Software is
00048  * requested to send the modifications to the original developer so that
00049  * they can be incorporated into the canonical version. It is also 
00050  * requested that these non-binding requests be included along with the 
00051  * license above.
00052  */
00053 
00061 #ifndef PA_MAC_CORE_INTERNAL_H__
00062 #define PA_MAC_CORE_INTERNAL_H__
00063 
00064 #include <AudioUnit/AudioUnit.h>
00065 #include <AudioToolbox/AudioToolbox.h>
00066 
00067 
00068 #include "portaudio.h"
00069 #include "pa_util.h"
00070 #include "pa_hostapi.h"
00071 #include "pa_stream.h"
00072 #include "pa_allocation.h"
00073 #include "pa_cpuload.h"
00074 #include "pa_process.h"
00075 #include "pa_ringbuffer.h"
00076 
00077 #include "pa_mac_core_blocking.h"
00078 
00079 /* function prototypes */
00080 
00081 #ifdef __cplusplus
00082 extern "C"
00083 {
00084 #endif /* __cplusplus */
00085 
00086 PaError PaMacCore_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
00087 
00088 #ifdef __cplusplus
00089 }
00090 #endif /* __cplusplus */
00091 
00092 #define RING_BUFFER_ADVANCE_DENOMINATOR (4)
00093 
00094 PaError ReadStream( PaStream* stream, void *buffer, unsigned long frames );
00095 PaError WriteStream( PaStream* stream, const void *buffer, unsigned long frames );
00096 signed long GetStreamReadAvailable( PaStream* stream );
00097 signed long GetStreamWriteAvailable( PaStream* stream );
00098 /* PaMacAUHAL - host api datastructure specific to this implementation */
00099 typedef struct
00100 {
00101     PaUtilHostApiRepresentation inheritedHostApiRep;
00102     PaUtilStreamInterface callbackStreamInterface;
00103     PaUtilStreamInterface blockingStreamInterface;
00104 
00105     PaUtilAllocationGroup *allocations;
00106 
00107     /* implementation specific data goes here */
00108     long devCount;
00109     AudioDeviceID *devIds; /*array of all audio devices*/
00110     AudioDeviceID defaultIn;
00111     AudioDeviceID defaultOut;
00112 }
00113 PaMacAUHAL;
00114 
00115 
00116 
00117 /* stream data structure specifically for this implementation */
00118 typedef struct PaMacCoreStream
00119 {
00120     PaUtilStreamRepresentation streamRepresentation;
00121     PaUtilCpuLoadMeasurer cpuLoadMeasurer;
00122     PaUtilBufferProcessor bufferProcessor;
00123 
00124     /* implementation specific data goes here */
00125     bool bufferProcessorIsInitialized;
00126     AudioUnit inputUnit;
00127     AudioUnit outputUnit;
00128     AudioDeviceID inputDevice;
00129     AudioDeviceID outputDevice;
00130     size_t userInChan;
00131     size_t userOutChan;
00132     size_t inputFramesPerBuffer;
00133     size_t outputFramesPerBuffer;
00134     PaMacBlio blio;
00135     /* We use this ring buffer when input and out devs are different. */
00136     PaUtilRingBuffer inputRingBuffer;
00137     /* We may need to do SR conversion on input. */
00138     AudioConverterRef inputSRConverter;
00139     /* We need to preallocate an inputBuffer for reading data. */
00140     AudioBufferList inputAudioBufferList;
00141     AudioTimeStamp startTime;
00142     /* FIXME: instead of volatile, these should be properly memory barriered */
00143     volatile PaStreamCallbackFlags xrunFlags;
00144     volatile bool isTimeSet;
00145     volatile enum {
00146        STOPPED          = 0, /* playback is completely stopped,
00147                                 and the user has called StopStream(). */
00148        CALLBACK_STOPPED = 1, /* callback has requested stop,
00149                                 but user has not yet called StopStream(). */
00150        STOPPING         = 2, /* The stream is in the process of closing
00151                                 because the user has called StopStream.
00152                                 This state is just used internally;
00153                                 externally it is indistinguishable from
00154                                 ACTIVE.*/
00155        ACTIVE           = 3  /* The stream is active and running. */
00156     } state;
00157     double sampleRate;
00158     //these may be different from the stream sample rate due to SR conversion:
00159     double outDeviceSampleRate;
00160     double inDeviceSampleRate;
00161 }
00162 PaMacCoreStream;
00163 
00164 #endif /* PA_MAC_CORE_INTERNAL_H__ */

Generated on Thu Sep 9 2010 10:53:52 for PortAudio by  doxygen 1.7.1