libsoundio/src/jack.h
Andrew Kelley ee7c0d3e11 convert source code to pure C
List<T> is now a really ugly macro.

Added a workaround for jack.h not putting `void` in function
prototypes for functions that take no arguments. I made upstream
pull requests to jack1 and jack2 but I don't have high hopes
about them getting merged.

I removed the lock-free atomic asserts. clang reports
non-lock-free atomics when in fact it does have lock-free
atomics. I inspected the generated code for gcc and clang
for fetch_add, load, and store, on x86_64 and armhf, and
it's all lock free.

Closes #45.
2015-11-10 02:24:18 -07:00

80 lines
1.9 KiB
C

/*
* Copyright (c) 2015 Andrew Kelley
*
* This file is part of libsoundio, which is MIT licensed.
* See http://opensource.org/licenses/MIT
*/
#ifndef SOUNDIO_JACK_H
#define SOUNDIO_JACK_H
#include "soundio_internal.h"
#include "os.h"
#include "atomics.h"
// jack.h does not properly put `void` in function prototypes with no
// arguments, so we're forced to temporarily disable -Werror=strict-prototypes
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <jack/jack.h>
#pragma GCC diagnostic pop
struct SoundIoPrivate;
int soundio_jack_init(struct SoundIoPrivate *si);
struct SoundIoDeviceJackPort {
char *full_name;
int full_name_len;
enum SoundIoChannelId channel_id;
jack_latency_range_t latency_range;
};
struct SoundIoDeviceJack {
int port_count;
struct SoundIoDeviceJackPort *ports;
};
struct SoundIoJack {
jack_client_t *client;
struct SoundIoOsMutex *mutex;
struct SoundIoOsCond *cond;
atomic_flag refresh_devices_flag;
int sample_rate;
int period_size;
bool is_shutdown;
bool emitted_shutdown_cb;
};
struct SoundIoOutStreamJackPort {
jack_port_t *source_port;
const char *dest_port_name;
int dest_port_name_len;
};
struct SoundIoOutStreamJack {
jack_client_t *client;
int period_size;
int frames_left;
double hardware_latency;
struct SoundIoOutStreamJackPort ports[SOUNDIO_MAX_CHANNELS];
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
};
struct SoundIoInStreamJackPort {
jack_port_t *dest_port;
const char *source_port_name;
int source_port_name_len;
};
struct SoundIoInStreamJack {
jack_client_t *client;
int period_size;
int frames_left;
double hardware_latency;
struct SoundIoInStreamJackPort ports[SOUNDIO_MAX_CHANNELS];
struct SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
char *buf_ptrs[SOUNDIO_MAX_CHANNELS];
};
#endif