Updating built in Io code to use += instead of x = x + y
[io/quag.git] / addons / PortAudio / source / AudioDevice.h
blob148e6a2b785e9143e4c408869cc393bf40787e3f
2 #ifndef AudioDevice_DEFINED
3 #define AudioDevice_DEFINED 1
5 #include "List.h"
6 #include "UArray.h"
7 #include <portaudio.h>
9 typedef double PaTimestamp;
11 typedef struct AudioDevice AudioDevice;
13 typedef void (AudioDeviceCallback)(void *);
15 struct AudioDevice
17 PaError err;
18 PaStream *stream;
20 int isFreed;
21 int locked;
22 int needsData;
23 AudioDeviceCallback *needsDataCallback;
24 void *needsDataCallbackContext;
26 /* for speaker output */
27 unsigned long writeFrame;
28 UArray *writeBuffer;
29 UArray *nextWriteBuffer;
31 /* for mic input */
32 unsigned long readFrame;
33 UArray *readBuffer;
34 UArray *nextReadBuffer;
35 int isListening;
36 int maxReadFrame;
38 int showed;
39 int writeBufferIsEmpty;
40 unsigned int lockSleepMicroSeconds;
43 void AudioDevice_nanoSleep(AudioDevice *self);
45 AudioDevice *AudioDevice_new(void);
46 void AudioDevice_free(AudioDevice *self);
48 int AudioDevice_framesPerBuffer(AudioDevice *self);
50 void AudioDevice_init(AudioDevice *self);
51 void AudioDevice_terminate(AudioDevice *self);
53 void AudioDevice_isListening_(AudioDevice *self, int v);
54 int AudioDevice_isListening(AudioDevice *self);
56 void AudioDevice_open(AudioDevice *self);
57 void AudioDevice_openForReadingAndWriting(AudioDevice *self);
58 void AudioDevice_close(AudioDevice *self);
60 const char *AudioDevice_error(AudioDevice *self);
61 void AudioDevice_printError(AudioDevice *self);
62 void AudioDevice_checkForError(AudioDevice *self);
64 void AudioDevice_start(AudioDevice *self);
65 void AudioDevice_stop(AudioDevice *self);
67 int AudioDevice_isActive(AudioDevice *self);
68 int AudioDevice_streamTime(AudioDevice *self);
69 double AudioDevice_cpuLoad(AudioDevice *self);
72 int AudioDevice_callbackTest(
73 void *inputBuffer,
74 void *outputBuffer,
75 unsigned long framesPerBuffer,
76 PaTimestamp outTime,
77 void *userData);
79 int AudioDevice_callbackInputTest(
80 void *inputBuffer,
81 void *outputBuffer,
82 unsigned long framesPerBuffer,
83 PaTimestamp outTime,
84 void *userData);
86 int AudioDevice_callback(
87 void *inputBuffer,
88 void *outputBuffer,
89 unsigned long framesPerBuffer,
90 PaTimestamp outTime,
91 void *userData);
94 int AudioDevice_swapWriteBuffers(AudioDevice *self);
95 int AudioDevice_swapReadBuffers(AudioDevice *self);
97 void AudioDevice_write_(AudioDevice *self, UArray *buf);
98 void AudioDevice_writeData_length_(AudioDevice *self, uint8_t *data, size_t numBytes);
99 UArray *AudioDevice_read(AudioDevice *self);
100 void AudioDevice_clearBuffers(AudioDevice *self);
102 int AudioDevice_isLocked(AudioDevice *self);
104 #endif