/[pcsx2_0.9.7]/trunk/3rdparty/portaudio/src/hostapi/coreaudio/pa_mac_core_blocking.h
ViewVC logotype

Contents of /trunk/3rdparty/portaudio/src/hostapi/coreaudio/pa_mac_core_blocking.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (show annotations) (download)
Mon Sep 6 11:40:06 2010 UTC (9 years, 5 months ago) by william
File MIME type: text/plain
File size: 4639 byte(s)
exported r3113 from ./upstream/trunk
1 /*
2 * Internal blocking interfaces for PortAudio Apple AUHAL implementation
3 *
4 * PortAudio Portable Real-Time Audio Library
5 * Latest Version at: http://www.portaudio.com
6 *
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)
9 *
10 * Dominic's code was based on code by Phil Burk, Darren Gibbs,
11 * Gord Peters, Stephane Letz, and Greg Pfiel.
12 *
13 * The following people also deserve acknowledgements:
14 *
15 * Olivier Tristan for feedback and testing
16 * Glenn Zelniker and Z-Systems engineering for sponsoring the Blocking I/O
17 * interface.
18 *
19 *
20 * Based on the Open Source API proposed by Ross Bencina
21 * Copyright (c) 1999-2002 Ross Bencina, Phil Burk
22 *
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:
30 *
31 * The above copyright notice and this permission notice shall be
32 * included in all copies or substantial portions of the Software.
33 *
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.
41 */
42
43 /*
44 * The text above constitutes the entire PortAudio license; however,
45 * the PortAudio community also makes the following non-binding requests:
46 *
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
51 * license above.
52 */
53
54 /**
55 @file
56 @ingroup hostapi_src
57 */
58
59 #ifndef PA_MAC_CORE_BLOCKING_H_
60 #define PA_MAC_CORE_BLOCKING_H_
61
62 #include "pa_ringbuffer.h"
63 #include "portaudio.h"
64 #include "pa_mac_core_utilities.h"
65
66 /*
67 * Number of miliseconds to busy wait whil waiting for data in blocking calls.
68 */
69 #define PA_MAC_BLIO_BUSY_WAIT_SLEEP_INTERVAL (5)
70 /*
71 * Define exactly one of these blocking methods
72 * PA_MAC_BLIO_MUTEX is not actively maintained.
73 */
74 #define PA_MAC_BLIO_BUSY_WAIT
75 /*
76 #define PA_MAC_BLIO_MUTEX
77 */
78
79 typedef struct {
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;
89
90 size_t framesPerBuffer;
91
92 int inChan;
93 int outChan;
94
95 //PaStreamCallbackFlags statusFlags;
96 uint32_t statusFlags;
97 PaError errors;
98
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;
104
105 volatile bool isOutputFull;
106 pthread_mutex_t outputMutex;
107 pthread_cond_t outputCond;
108 #endif
109 }
110 PaMacBlio;
111
112 /*
113 * These functions operate on condition and related variables.
114 */
115
116 PaError initializeBlioRingBuffers(
117 PaMacBlio *blio,
118 PaSampleFormat inputSampleFormat,
119 PaSampleFormat outputSampleFormat,
120 size_t framesPerBuffer,
121 long ringBufferSize,
122 int inChan,
123 int outChan );
124 PaError destroyBlioRingBuffers( PaMacBlio *blio );
125 PaError resetBlioRingBuffers( PaMacBlio *blio );
126
127 int BlioCallback(
128 const void *input, void *output,
129 unsigned long frameCount,
130 const PaStreamCallbackTimeInfo* timeInfo,
131 PaStreamCallbackFlags statusFlags,
132 void *userData );
133
134 void waitUntilBlioWriteBufferIsFlushed( PaMacBlio *blio );
135
136 #endif /*PA_MAC_CORE_BLOCKING_H_*/

  ViewVC Help
Powered by ViewVC 1.1.22