~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.2.1/third_party/portaudio/src/hostapi/coreaudio/pa_mac_core_internal.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Internal 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 pa_mac_core
 
56
 @ingroup hostapi_src
 
57
 @author Bjorn Roche
 
58
 @brief AUHAL implementation of PortAudio
 
59
*/
 
60
 
 
61
#ifndef PA_MAC_CORE_INTERNAL_H__
 
62
#define PA_MAC_CORE_INTERNAL_H__
 
63
 
 
64
#include <CoreAudio/CoreAudio.h>
 
65
#include <CoreServices/CoreServices.h>
 
66
#include <AudioUnit/AudioUnit.h>
 
67
#include <AudioToolbox/AudioToolbox.h>
 
68
 
 
69
#include "portaudio.h"
 
70
#include "pa_util.h"
 
71
#include "pa_hostapi.h"
 
72
#include "pa_stream.h"
 
73
#include "pa_allocation.h"
 
74
#include "pa_cpuload.h"
 
75
#include "pa_process.h"
 
76
#include "pa_ringbuffer.h"
 
77
 
 
78
#include "pa_mac_core_blocking.h"
 
79
 
 
80
/* function prototypes */
 
81
 
 
82
#ifdef __cplusplus
 
83
extern "C"
 
84
{
 
85
#endif /* __cplusplus */
 
86
 
 
87
PaError PaMacCore_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index );
 
88
 
 
89
#ifdef __cplusplus
 
90
}
 
91
#endif /* __cplusplus */
 
92
 
 
93
#define RING_BUFFER_ADVANCE_DENOMINATOR (4)
 
94
 
 
95
PaError ReadStream( PaStream* stream, void *buffer, unsigned long frames );
 
96
PaError WriteStream( PaStream* stream, const void *buffer, unsigned long frames );
 
97
signed long GetStreamReadAvailable( PaStream* stream );
 
98
signed long GetStreamWriteAvailable( PaStream* stream );
 
99
/* PaMacAUHAL - host api datastructure specific to this implementation */
 
100
typedef struct
 
101
{
 
102
    PaUtilHostApiRepresentation inheritedHostApiRep;
 
103
    PaUtilStreamInterface callbackStreamInterface;
 
104
    PaUtilStreamInterface blockingStreamInterface;
 
105
 
 
106
    PaUtilAllocationGroup *allocations;
 
107
 
 
108
    /* implementation specific data goes here */
 
109
    long devCount;
 
110
    AudioDeviceID *devIds; /*array of all audio devices*/
 
111
    AudioDeviceID defaultIn;
 
112
    AudioDeviceID defaultOut;
 
113
}
 
114
PaMacAUHAL;
 
115
 
 
116
 
 
117
 
 
118
/* stream data structure specifically for this implementation */
 
119
typedef struct PaMacCoreStream
 
120
{
 
121
    PaUtilStreamRepresentation streamRepresentation;
 
122
    PaUtilCpuLoadMeasurer cpuLoadMeasurer;
 
123
    PaUtilBufferProcessor bufferProcessor;
 
124
 
 
125
    /* implementation specific data goes here */
 
126
    bool bufferProcessorIsInitialized;
 
127
    AudioUnit inputUnit;
 
128
    AudioUnit outputUnit;
 
129
    AudioDeviceID inputDevice;
 
130
    AudioDeviceID outputDevice;
 
131
    size_t userInChan;
 
132
    size_t userOutChan;
 
133
    size_t inputFramesPerBuffer;
 
134
    size_t outputFramesPerBuffer;
 
135
    PaMacBlio blio;
 
136
    /* We use this ring buffer when input and out devs are different. */
 
137
    PaUtilRingBuffer inputRingBuffer;
 
138
    /* We may need to do SR conversion on input. */
 
139
    AudioConverterRef inputSRConverter;
 
140
    /* We need to preallocate an inputBuffer for reading data. */
 
141
    AudioBufferList inputAudioBufferList;
 
142
    AudioTimeStamp startTime;
 
143
    /* FIXME: instead of volatile, these should be properly memory barriered */
 
144
    volatile PaStreamCallbackFlags xrunFlags;
 
145
    volatile bool isTimeSet;
 
146
    volatile enum {
 
147
       STOPPED          = 0, /* playback is completely stopped,
 
148
                                and the user has called StopStream(). */
 
149
       CALLBACK_STOPPED = 1, /* callback has requested stop,
 
150
                                but user has not yet called StopStream(). */
 
151
       STOPPING         = 2, /* The stream is in the process of closing
 
152
                                because the user has called StopStream.
 
153
                                This state is just used internally;
 
154
                                externally it is indistinguishable from
 
155
                                ACTIVE.*/
 
156
       ACTIVE           = 3  /* The stream is active and running. */
 
157
    } state;
 
158
    double sampleRate;
 
159
    //these may be different from the stream sample rate due to SR conversion:
 
160
    double outDeviceSampleRate;
 
161
    double inDeviceSampleRate;
 
162
}
 
163
PaMacCoreStream;
 
164
 
 
165
#endif /* PA_MAC_CORE_INTERNAL_H__ */