Before we begin, it's important to realize that the callback is a delicate place. This is because some systems perform the callback in a special thread, or interrupt handler, and it is rarely treated the same as the rest of your code.
For most modern systems, you won't be able to cause crashes by making disallowed calls in the callback, but if you want your code to produce glitch-free audio, you will have to make sure you avoid function calls that may take an unbounded amount of time
to execute. Exactly what these are depend on your platform but almost certainly include the following: memory allocation/deallocation, I/O (including file I/O as well as console I/O, such as printf()), context switching (such as exec() or
-yield()), mutex operations, or anything else that might rely on the OS. If you think short critical sections are safe please go read about priority inversion. Windows amd Mac OS schedulers have no real-time safe priority inversion prevention. Other platforms require special mutex flags. In addition, it is not safe to call any PortAudio API functions in the callback except as explicitly permitted in the documentation.
+yield()), mutex operations, or anything else that might rely on the OS. If you think short critical sections are safe please go read about priority inversion. Windows and Mac OS schedulers have no real-time safe priority inversion prevention. Other platforms require special mutex flags. In addition, it is not safe to call any PortAudio API functions in the callback except as explicitly permitted in the documentation.
Your callback function must return an int and accept the exact parameters specified in this typedef:
/** Specifies thread priority explicitly. Will be used only if paWinWasapiThreadPriority flag
is specified.
- Please note, if Input/Output streams are opened simultaniously (Full-Duplex mode)
+ Please note, if Input/Output streams are opened simultaneously (Full-Duplex mode)
you shall specify same value for threadPriority or othervise one of the values will be used
to setup thread priority.
*/
case $func_quote_for_eval_unquoted_result in
# Double-quote args containing shell metacharacters to delay
- # word splitting, command substitution and and variable
+ # word splitting, command substitution and variable
# expansion for a subsequent eval.
# Many Bourne shells cannot handle close brackets correctly
# in scan sets, so we specify it separately.
will interrupt other apps to improve performance. For example, if 44100 Hz
sample rate is requested but the device is set at 48000 Hz, PA can either
change the device for optimal playback ("Pro" mode), which may interrupt
-other programs playing back audio, or simple use a sample-rate coversion,
+other programs playing back audio, or simple use a sample-rate conversion,
which allows for friendlier sharing of the device ("Play Nice" mode).
Additionally, the user may define a "channel mapping" by calling
/*
static int renderCount = 0;
static int inputCount = 0;
- printf( "------------------- starting reder/input\n" );
+ printf( "------------------- starting render/input\n" );
if( isRender )
printf("Render callback (%d):\t", ++renderCount);
else
// HANDLE processingThread;
// DWORD processingThreadId;
- char throttleProcessingThreadOnOverload; // 0 -> don't throtte, non-0 -> throttle
+ char throttleProcessingThreadOnOverload; // 0 -> don't throttle, non-0 -> throttle
int processingThreadPriority;
int highThreadPriority;
int throttledThreadPriority;
*/
/* Until May 2011 PA/DS has used a multimedia timer to perform the callback.
- We're replacing this with a new implementation using a thread and a different timer mechanim.
+ We're replacing this with a new implementation using a thread and a different timer mechanism.
Defining PA_WIN_DS_USE_WMME_TIMER uses the old (pre-May 2011) behavior.
*/
//#define PA_WIN_DS_USE_WMME_TIMER
NOTE: GetVersionEx() is deprecated as of Windows 8.1 and can not be used to reliably detect
versions of Windows higher than Windows 8 (due to manifest requirements for reporting higher versions).
Microsoft recommends switching to VerifyVersionInfo (available on Win 2k and later), however GetVersionEx
-is is faster, for now we just disable the deprecation warning.
+is faster, for now we just disable the deprecation warning.
See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx
See: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
*/
// Mixer function
typedef void (*MixMonoToStereoF) (void *__to, const void *__from, UINT32 count);
-// AVRT is the new "multimedia schedulling stuff"
+// AVRT is the new "multimedia scheduling stuff"
#ifndef PA_WINRT
typedef BOOL (WINAPI *FAvRtCreateThreadOrderingGroup) (PHANDLE,PLARGE_INTEGER,GUID*,PLARGE_INTEGER);
typedef BOOL (WINAPI *FAvRtDeleteThreadOrderingGroup) (HANDLE);
// Correct buffer to max size if it maxed out result of GetBufferSize
stream->out.bufferSize = maxBufferSize;
- // Get interface latency (actually uneeded as we calculate latency from the size of maxBufferSize)
+ // Get interface latency (actually unneeded as we calculate latency from the size of maxBufferSize)
if (FAILED(hr = IAudioClient_GetStreamLatency(stream->out.clientParent, &stream->out.deviceLatency)))
{
LogHostError(hr);
// Correct buffer to max size if it maxed out result of GetBufferSize
stream->in.bufferSize = maxBufferSize;
- // Get interface latency (actually uneeded as we calculate latency from the size
+ // Get interface latency (actually unneeded as we calculate latency from the size
// of maxBufferSize).
if (FAILED(hr = IAudioClient_GetStreamLatency(stream->in.clientParent, &stream->in.deviceLatency)))
{
NOTE: GetVersionEx() is deprecated as of Windows 8.1 and can not be used to reliably detect
versions of Windows higher than Windows 8 (due to manifest requirements for reporting higher versions).
Microsoft recommends switching to VerifyVersionInfo (available on Win 2k and later), however GetVersionEx
-is is faster, for now we just disable the deprecation warning.
+is faster, for now we just disable the deprecation warning.
See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx
See: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
*/
/* When client suggestedLatency could result in many host buffers, we aim to have around 8,
based off Windows documentation that suggests that the kmixer uses 8 buffers. This choice
- is somewhat arbitrary here, since we haven't observed significant stability degredation
+ is somewhat arbitrary here, since we haven't observed significant stability degradation
with using either more, or less buffers.
*/
#define PA_MME_TARGET_HOST_BUFFER_COUNT_ 8
NOTE: GetVersionEx() is deprecated as of Windows 8.1 and can not be used to reliably detect
versions of Windows higher than Windows 8 (due to manifest requirements for reporting higher versions).
Microsoft recommends switching to VerifyVersionInfo (available on Win 2k and later), however GetVersionEx
-is is faster, for now we just disable the deprecation warning.
+is faster, for now we just disable the deprecation warning.
See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx
See: http://www.codeproject.com/Articles/678606/Part-Overcoming-Windows-s-deprecation-of-GetVe
*/
HANDLE processingThread;
PA_THREAD_ID processingThreadId;
- char throttleProcessingThreadOnOverload; /* 0 -> don't throtte, non-0 -> throttle */
+ char throttleProcessingThreadOnOverload; /* 0 -> don't throttle, non-0 -> throttle */
int processingThreadPriority;
int highThreadPriority;
int throttledThreadPriority;
*/
pthread_t paUnixMainThread = 0;
#else
-/*pthreads are opaque. We don't know that asigning it an int value
+/*pthreads are opaque. We don't know that assigning it an int value
always makes sense, so we don't initialize it unless we have to.*/
pthread_t paUnixMainThread = 0;
#endif
* illegal way, it may fail for reasons that are not PA bugs.
*/
-/* Wait for awhile then abort the stream. */
+/* Wait awhile then abort the stream. */
void *stop_thread_proc(void *arg)
{
PaStream *stream = (PaStream *)arg;