/*
* Sound through the kernel's audio render driver (XAudio render driver
* client, as found on hardware by xsdk, https://github.com/jessenic/xsdk):
* the driver takes a frame every 5.33 ms, 256 samples at 48 kHz in 6
* channels (front left, front right, centre, LFE, back left, back right),
* each channel's 256 big-endian floats after the other.
*
* The title fills frames ahead into a ring; the driver's callback takes the
* oldest, or plays silence when the ring is empty.
*/
#ifndef XEX_AUDIO_H
#define XEX_AUDIO_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define XEX_AUDIO_RATE 48000
#define XEX_AUDIO_FRAME_SAMPLES 256
#define XEX_AUDIO_CHANNELS 6
#define XEX_AUDIO_RING_FRAMES 16
/* Registers with the driver. 0 on success. */
int xex_audio_open(void);
/* Frames queued and not yet taken by the driver. */
unsigned xex_audio_queued(void);
/* The next frame to fill (6 x 256 floats, channel after channel; the
* centre, LFE and back channels start out silent and may stay so), or
* NULL when the ring is full. Call xex_audio_queue() once it is filled. */
float *xex_audio_next(void);
void xex_audio_queue(void);
/* Callbacks from the driver so far (one per 5.33 ms frame). */
unsigned xex_audio_callbacks(void);
/* Frames the driver played silence for, because the ring was empty. */
unsigned xex_audio_underruns(void);
/* Unregisters (also done at exit). */
void xex_audio_close(void);
#ifdef __cplusplus
}
#endif
#endif