2
* Internal blocking interfaces for PortAudio Apple AUHAL implementation
4
* PortAudio Portable Real-Time Audio Library
5
* Latest Version at: http://www.portaudio.com
7
* Written by Bjorn Roche of XO Audio LLC, from PA skeleton code.
8
* Portions copied from code by Dominic Mazzoni (who wrote a HAL implementation)
10
* Dominic's code was based on code by Phil Burk, Darren Gibbs,
11
* Gord Peters, Stephane Letz, and Greg Pfiel.
13
* The following people also deserve acknowledgements:
15
* Olivier Tristan for feedback and testing
16
* Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
20
* Based on the Open Source API proposed by Ross Bencina
21
* Copyright (c) 1999-2002 Ross Bencina, Phil Burk
23
* Permission is hereby granted, free of charge, to any person obtaining
24
* a copy of this software and associated documentation files
25
* (the "Software"), to deal in the Software without restriction,
26
* including without limitation the rights to use, copy, modify, merge,
27
* publish, distribute, sublicense, and/or sell copies of the Software,
28
* and to permit persons to whom the Software is furnished to do so,
29
* subject to the following conditions:
31
* The above copyright notice and this permission notice shall be
32
* included in all copies or substantial portions of the Software.
34
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
35
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
36
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
37
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
38
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
39
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
40
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44
* The text above constitutes the entire PortAudio license; however,
45
* the PortAudio community also makes the following non-binding requests:
47
* Any person wishing to distribute modifications to the Software is
48
* requested to send the modifications to the original developer so that
49
* they can be incorporated into the canonical version. It is also
50
* requested that these non-binding requests be included along with the
59
#ifndef PA_MAC_CORE_BLOCKING_H_
60
#define PA_MAC_CORE_BLOCKING_H_
62
#include "pa_ringbuffer.h"
63
#include "portaudio.h"
64
#include "pa_mac_core_utilities.h"
67
* Number of miliseconds to busy wait whil waiting for data in blocking calls.
69
#define PA_MAC_BLIO_BUSY_WAIT_SLEEP_INTERVAL (5)
71
* Define exactly one of these blocking methods
72
* PA_MAC_BLIO_MUTEX is not actively maintained.
74
#define PA_MAC_BLIO_BUSY_WAIT
76
#define PA_MAC_BLIO_MUTEX
80
PaUtilRingBuffer inputRingBuffer;
81
PaUtilRingBuffer outputRingBuffer;
82
size_t ringBufferFrames;
83
PaSampleFormat inputSampleFormat;
84
size_t inputSampleSizeActual;
85
size_t inputSampleSizePow2;
86
PaSampleFormat outputSampleFormat;
87
size_t outputSampleSizeActual;
88
size_t outputSampleSizePow2;
90
size_t framesPerBuffer;
95
//PaStreamCallbackFlags statusFlags;
99
/* Here we handle blocking, using condition variables. */
100
#ifdef PA_MAC_BLIO_MUTEX
101
volatile bool isInputEmpty;
102
pthread_mutex_t inputMutex;
103
pthread_cond_t inputCond;
105
volatile bool isOutputFull;
106
pthread_mutex_t outputMutex;
107
pthread_cond_t outputCond;
113
* These functions operate on condition and related variables.
116
PaError initializeBlioRingBuffers(
118
PaSampleFormat inputSampleFormat,
119
PaSampleFormat outputSampleFormat,
120
size_t framesPerBuffer,
124
PaError destroyBlioRingBuffers( PaMacBlio *blio );
125
PaError resetBlioRingBuffers( PaMacBlio *blio );
128
const void *input, void *output,
129
unsigned long frameCount,
130
const PaStreamCallbackTimeInfo* timeInfo,
131
PaStreamCallbackFlags statusFlags,
134
void waitUntilBlioWriteBufferIsFlushed( PaMacBlio *blio );
136
#endif /*PA_MAC_CORE_BLOCKING_H_*/