summaryrefslogtreecommitdiff
path: root/src/c_portadao.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c_portadao.c')
-rw-r--r--src/c_portadao.c125
1 files changed, 125 insertions, 0 deletions
diff --git a/src/c_portadao.c b/src/c_portadao.c
new file mode 100644
index 0000000..fc2e3b0
--- /dev/null
+++ b/src/c_portadao.c
@@ -0,0 +1,125 @@
+
+
+// Programmed by Jedidiah Barber
+// Released into the public domain
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <portaudio.h>
+#include "c_portadao.h"
+
+
+
+const int pa_no_error = paNoError;
+const int pa_not_initialized = paNotInitialized;
+const int pa_unanticipated_host_error = paUnanticipatedHostError;
+const int pa_invalid_channel_count = paInvalidChannelCount;
+const int pa_invalid_sample_rate = paInvalidSampleRate;
+const int pa_invalid_device = paInvalidDevice;
+const int pa_invalid_flag = paInvalidFlag;
+const int pa_sample_format_not_supported = paSampleFormatNotSupported;
+const int pa_bad_io_device_combination = paBadIODeviceCombination;
+const int pa_insufficient_memory = paInsufficientMemory;
+const int pa_buffer_too_big = paBufferTooBig;
+const int pa_buffer_too_small = paBufferTooSmall;
+const int pa_null_callback = paNullCallback;
+const int pa_bad_stream_ptr = paBadStreamPtr;
+const int pa_timed_out = paTimedOut;
+const int pa_internal_error = paInternalError;
+const int pa_device_unavailable = paDeviceUnavailable;
+const int pa_incompatible_host_api_specific_stream_info = paIncompatibleHostApiSpecificStreamInfo;
+const int pa_stream_is_stopped = paStreamIsStopped;
+const int pa_stream_is_not_stopped = paStreamIsNotStopped;
+const int pa_input_overflowed = paInputOverflowed;
+const int pa_output_underflowed = paOutputUnderflowed;
+const int pa_host_api_not_found = paHostApiNotFound;
+const int pa_invalid_host_api = paInvalidHostApi;
+const int pa_cannot_read_from_a_callback_stream = paCanNotReadFromACallbackStream;
+const int pa_cannot_write_to_a_callback_stream = paCanNotWriteToACallbackStream;
+const int pa_cannot_read_from_an_output_only_stream = paCanNotReadFromAnOutputOnlyStream;
+const int pa_cannot_write_to_an_input_only_stream = paCanNotWriteToAnInputOnlyStream;
+const int pa_incompatible_stream_host_api = paIncompatibleStreamHostApi;
+const int pa_bad_buffer_ptr = paBadBufferPtr;
+
+const int pa_in_development = paInDevelopment;
+const int pa_direct_sound = paDirectSound;
+const int pa_mme = paMME;
+const int pa_asio = paASIO;
+const int pa_sound_manager = paSoundManager;
+const int pa_core_audio = paCoreAudio;
+const int pa_oss = paOSS;
+const int pa_alsa = paALSA;
+const int pa_al = paAL;
+const int pa_beos = paBeOS;
+const int pa_wdmks = paWDMKS;
+const int pa_jack = paJACK;
+const int pa_wasapi = paWASAPI;
+const int pa_audio_science_hpi = paAudioScienceHPI;
+const int pa_sndio = paSndio;
+
+const int pa_no_device = paNoDevice;
+
+const unsigned long pa_float_32 = paFloat32;
+const unsigned long pa_int_32 = paInt32;
+const unsigned long pa_int_24 = paInt24;
+const unsigned long pa_int_16 = paInt16;
+const unsigned long pa_int_8 = paInt8;
+const unsigned long pa_uint_8 = paUInt8;
+
+const int pa_format_is_supported = paFormatIsSupported;
+
+const unsigned long pa_no_flag = paNoFlag;
+const unsigned long pa_clip_off = paClipOff;
+const unsigned long pa_dither_off = paDitherOff;
+const unsigned long pa_never_drop_input = paNeverDropInput;
+const unsigned long pa_prime_output_buffers_using_stream_callback =
+ paPrimeOutputBuffersUsingStreamCallback;
+
+const int pa_continue = paContinue;
+const int pa_complete = paComplete;
+const int pa_abort = paAbort;
+
+const unsigned long pa_input_underflow = paInputUnderflow;
+const unsigned long pa_input_overflow = paInputOverflow;
+const unsigned long pa_output_underflow = paOutputUnderflow;
+const unsigned long pa_output_overflow = paOutputOverflow;
+const unsigned long pa_priming_output = paPrimingOutput;
+
+
+
+int fd_backup;
+int suppressed = 0;
+
+void suppress_stderr() {
+ fflush(stderr);
+ fd_backup = dup(STDERR_FILENO);
+ //if (freopen("/dev/null", "w", stderr) == NULL) {
+ // freopen("nul", "w", stderr);
+ //}
+ close(STDERR_FILENO);
+ suppressed = 1;
+}
+
+void restore_stderr() {
+ fflush(stderr);
+ dup2(fd_backup, fileno(stderr));
+ close(fd_backup);
+ suppressed = 0;
+}
+
+int apa_init(int stop_msg) {
+ if (stop_msg) {
+ suppress_stderr();
+ }
+ return Pa_Initialize();
+}
+
+int apa_term() {
+ if (suppressed) {
+ restore_stderr();
+ }
+ return Pa_Terminate();
+}
+
+