| 1 |
STATUS: |
| 2 |
|
| 3 |
MME, DirectSound and ASIO versions are more-or-less working. See FIXMEs @todos |
| 4 |
and the proposals matrix at portaudio.com for further status. |
| 5 |
|
| 6 |
The pa_tests directory contains tests. pa_tests/README.txt notes which tests |
| 7 |
currently build. |
| 8 |
|
| 9 |
The PaUtil support code is finished enough for other implementations to be |
| 10 |
ported. No changes are expected to be made to the definition of the PaUtil |
| 11 |
functions. |
| 12 |
|
| 13 |
Note that it's not yet 100% clear how the current support functions |
| 14 |
will interact with blocking read/write streams. |
| 15 |
|
| 16 |
BUILD INSTRUCTIONS |
| 17 |
|
| 18 |
to build tests/patest_sine.c you will need to compile and link the following |
| 19 |
files (MME) |
| 20 |
pa_common\pa_process.c |
| 21 |
pa_common\pa_skeleton.c |
| 22 |
pa_common\pa_stream.c |
| 23 |
pa_common\pa_trace.c |
| 24 |
pa_common\pa_converters.c |
| 25 |
pa_common\pa_cpuload.c |
| 26 |
pa_common\pa_dither.c |
| 27 |
pa_common\pa_front.c |
| 28 |
pa_common\pa_allocation.h |
| 29 |
pa_win\pa_win_util.c |
| 30 |
pa_win\pa_win_hostapis.c |
| 31 |
pa_win_wmme\pa_win_wmme.c |
| 32 |
|
| 33 |
see below for a description of these files. |
| 34 |
|
| 35 |
|
| 36 |
FILES: |
| 37 |
|
| 38 |
portaudio.h |
| 39 |
public api header file |
| 40 |
|
| 41 |
pa_front.c |
| 42 |
implements the interface defined in portaudio.h. manages multiple host apis. |
| 43 |
validates function parameters before calling through to host apis. tracks |
| 44 |
open streams and closes them at Pa_Terminate(). |
| 45 |
|
| 46 |
pa_util.h |
| 47 |
declares utility functions for use my implementations. including utility |
| 48 |
functions which must be implemented separately for each platform. |
| 49 |
|
| 50 |
pa_hostapi.h |
| 51 |
hostapi representation structure used to interface between pa_front.c |
| 52 |
and implementations |
| 53 |
|
| 54 |
pa_stream.c/h |
| 55 |
stream interface and representation structures and helper functions |
| 56 |
used to interface between pa_front.c and implementations |
| 57 |
|
| 58 |
pa_cpuload.c/h |
| 59 |
source and header for cpu load calculation facility |
| 60 |
|
| 61 |
pa_trace.c/h |
| 62 |
source and header for debug trace log facility |
| 63 |
|
| 64 |
pa_converters.c/h |
| 65 |
sample buffer conversion facility |
| 66 |
|
| 67 |
pa_dither.c/h |
| 68 |
dither noise generator |
| 69 |
|
| 70 |
pa_process.c/h |
| 71 |
callback buffer processing facility including interleave and block adaption |
| 72 |
|
| 73 |
pa_allocation.c/h |
| 74 |
allocation context for tracking groups of allocations |
| 75 |
|
| 76 |
pa_skeleton.c |
| 77 |
an skeleton implementation showing how the common code can be used. |
| 78 |
|
| 79 |
pa_win_util.c |
| 80 |
Win32 implementation of platform specific PaUtil functions (memory allocation, |
| 81 |
usec clock, Pa_Sleep().) The file will be used with all Win32 host APIs. |
| 82 |
|
| 83 |
pa_win_hostapis.c |
| 84 |
contains the paHostApiInitializers array and an implementation of |
| 85 |
Pa_GetDefaultHostApi() for win32 builds. |
| 86 |
|
| 87 |
pa_win_wmme.c |
| 88 |
Win32 host api implementation for the windows multimedia extensions audio API. |
| 89 |
|
| 90 |
pa_win_wmme.h |
| 91 |
public header file containing interfaces to mme-specific functions and the |
| 92 |
deviceInfo data structure. |
| 93 |
|
| 94 |
|
| 95 |
CODING GUIDELINES: |
| 96 |
|
| 97 |
naming conventions: |
| 98 |
#defines begin with PA_ |
| 99 |
#defines local to a file end with _ |
| 100 |
global utility variables begin with paUtil |
| 101 |
global utility types begin with PaUtil (including function types) |
| 102 |
global utility functions begin with PaUtil_ |
| 103 |
static variables end with _ |
| 104 |
static constants begin with const and end with _ |
| 105 |
static funtions have no special prefix/suffix |
| 106 |
|
| 107 |
In general, implementations should declare all of their members static, |
| 108 |
except for their initializer which should be exported. All exported names |
| 109 |
should be preceeded by Pa<MN>_ where MN is the module name, for example |
| 110 |
the windows mme initializer should be named PaWinWmme_Initialize(). |
| 111 |
|
| 112 |
Every host api should define an initializer which returns an error code |
| 113 |
and a PaHostApiInterface*. The initializer should only return an error other |
| 114 |
than paNoError if it encounters an unexpected and fatal error (memory allocation |
| 115 |
error for example). In general, there may be conditions under which it returns |
| 116 |
a NULL interface pointer and also returns paNoError. For example, if the ASIO |
| 117 |
implementation detects that ASIO is not installed, it should return a |
| 118 |
NULL interface, and paNoError. |
| 119 |
|
| 120 |
Platform-specific shared functions should begin with Pa<PN>_ where PN is the |
| 121 |
platform name. eg. PaWin_ for windows, PaUnix_ for unix. |
| 122 |
|
| 123 |
The above two conventions should also be followed whenever it is necessary to |
| 124 |
share functions accross multiple source files. |
| 125 |
|
| 126 |
Two utilities for debug messages are provided. The PA_DEBUG macro defined in |
| 127 |
pa_implementation.h provides a simple way to print debug messages to stderr. |
| 128 |
Due to real-time performance issues, PA_DEBUG may not be suitable for use |
| 129 |
within the portaudio processing callback, or in other threads. In such cases |
| 130 |
the event tracing facility provided in pa_trace.h may be more appropriate. |
| 131 |
|
| 132 |
If PA_LOG_API_CALLS is defined, all calls to the public PortAudio API |
| 133 |
will be logged to stderr along with parameter and return values. |
| 134 |
|
| 135 |
|
| 136 |
TODO: |
| 137 |
(this list is totally out of date) |
| 138 |
|
| 139 |
finish coding converter functions in pa_converters.c (anyone?) |
| 140 |
|
| 141 |
implement block adaption in pa_process.c (phil?) |
| 142 |
|
| 143 |
fix all current tests to work with new code. this should mostly involve |
| 144 |
changing PortAudioStream to PaStream, and GetDefaultDeviceID to GetDefaultDevice etc. |
| 145 |
|
| 146 |
write some new tests to exercise the multi-api functions |
| 147 |
|
| 148 |
write (doxygen) documentation for pa_trace (phil?) |
| 149 |
|
| 150 |
remove unused typeids from PaHostAPITypeID |
| 151 |
|
| 152 |
create a global configuration file which documents which PA_ defines can be |
| 153 |
used for configuration |
| 154 |
|
| 155 |
need a coding standard for comment formatting |
| 156 |
|
| 157 |
migrate directx (phil) |
| 158 |
|
| 159 |
migrate asio (ross?, stephane?) |
| 160 |
|
| 161 |
see top of pa_win_wmme.c for MME todo items (ross) |
| 162 |
|
| 163 |
write style guide document (ross) |
| 164 |
|
| 165 |
|
| 166 |
DESIGN ISSUES: |
| 167 |
(this list is totally out of date) |
| 168 |
|
| 169 |
consider removing Pa_ConvertHostApiDeviceIndexToGlobalDeviceIndex() from the API |
| 170 |
|
| 171 |
switch to new latency parameter mechanism now (?) |
| 172 |
|
| 173 |
question: if input or outputDriverInfo structures are passed for a different |
| 174 |
hostApi from the one being called, do we return an error or just ignore |
| 175 |
them? (i think return error) |
| 176 |
|
| 177 |
consider renaming PortAudioCallback to PaStreamCallback |
| 178 |
|
| 179 |
consider renaming PaError, PaResult |
| 180 |
|
| 181 |
|
| 182 |
ASSORTED DISORGANISED NOTES: |
| 183 |
|
| 184 |
NOTE: |
| 185 |
pa_lib.c performs the following validations for Pa_OpenStream() which we do not currently do: |
| 186 |
- checks the device info to make sure that the device supports the requested sample rate, |
| 187 |
it may also change the sample rate to the "closest available" sample rate if it |
| 188 |
is within a particular error margin |
| 189 |
|
| 190 |
rationale for breaking up internalPortAudioStream: |
| 191 |
each implementation has its own requirements and behavior, and should be |
| 192 |
able to choose the best way to operate without being limited by the |
| 193 |
constraints imposed by a common infrastructure. in other words the |
| 194 |
implementations should be able to pick and choose services from the |
| 195 |
common infrastructure. currently identified services include: |
| 196 |
|
| 197 |
- cpu load tracking |
| 198 |
- buffering and conversion service (same code works for input and output) |
| 199 |
- should support buffer multiplexing (non-integer length input and output buffers) |
| 200 |
- in-place conversion where possible (only for callback, read/write always copies) |
| 201 |
- should manage allocation of temporary buffers if necessary |
| 202 |
- instrumentation (should be able to be disabled): callback count, framesProcessed |
| 203 |
- common data: magic, streamInterface, callback, userdata |
| 204 |
|
| 205 |
|
| 206 |
- conversion functions: |
| 207 |
- should handle temp buffer allocation |
| 208 |
- dithering (random number state per-stream) |
| 209 |
- buffer size mismatches |
| 210 |
- with new buffer slip rules, temp buffers may always be needed |
| 211 |
- we should aim for in-place conversion wherever possible |
| 212 |
- does phil's code support in-place conversion? (yes) |
| 213 |
|
| 214 |
- dicuss relationship between user and host buffer sizes |
| 215 |
- completely independent.. individual implementations may constrain |
| 216 |
host buffer sizes if necessary |
| 217 |
|
| 218 |
|
| 219 |
- discuss device capabilities: |
| 220 |
- i'd like to be able to request certain information: |
| 221 |
- channel count for example |
| 222 |
|