2024-07-08 06:46:12 +00:00
|
|
|
#ifndef PRIVATE_AUDIO_H
|
|
|
|
#define PRIVATE_AUDIO_H
|
|
|
|
|
|
|
|
#include "../audio.h"
|
|
|
|
|
|
|
|
#include <SDL2/SDL_audio.h>
|
|
|
|
|
|
|
|
#define STB_VORBIS_HEADER_ONLY
|
|
|
|
#include <stb_vorbis.c>
|
2024-07-08 13:58:23 +00:00
|
|
|
#include <xm.h>
|
2024-07-08 06:46:12 +00:00
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum audio_file_type {
|
|
|
|
audio_file_type_ogg,
|
|
|
|
audio_file_type_xm,
|
|
|
|
audio_file_type_count,
|
|
|
|
audio_file_type_unknown,
|
|
|
|
} t_audio_file_type;
|
|
|
|
|
|
|
|
|
|
|
|
union audio_context {
|
|
|
|
struct {
|
|
|
|
stb_vorbis *handle;
|
|
|
|
unsigned char *data;
|
|
|
|
int frequency;
|
|
|
|
uint8_t channel_count;
|
|
|
|
} vorbis;
|
2024-07-08 13:58:23 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
xm_context_t *handle;
|
|
|
|
} xm;
|
2024-07-08 06:46:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct audio_channel {
|
|
|
|
t_play_audio_args args;
|
|
|
|
enum audio_file_type file_type;
|
|
|
|
union audio_context context; /* interpreted by `file_type` value */
|
|
|
|
const char *path;
|
2024-07-08 15:22:40 +00:00
|
|
|
const char *name;
|
2024-07-08 06:46:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct audio_channel_pair {
|
|
|
|
char *key;
|
|
|
|
struct audio_channel value;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void audio_callback(void *userdata, uint8_t *stream, int len);
|
|
|
|
|
|
|
|
#endif
|