summary refs log tree commit diff stats
path: root/vendor/fmod/inc/fmod_codec.h
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/fmod/inc/fmod_codec.h')
-rw-r--r--vendor/fmod/inc/fmod_codec.h136
1 files changed, 136 insertions, 0 deletions
diff --git a/vendor/fmod/inc/fmod_codec.h b/vendor/fmod/inc/fmod_codec.h new file mode 100644 index 0000000..668d9cf --- /dev/null +++ b/vendor/fmod/inc/fmod_codec.h
@@ -0,0 +1,136 @@
1/* ======================================================================================== */
2/* FMOD Core API - Codec development header file. */
3/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2021. */
4/* */
5/* Use this header if you are wanting to develop your own file format plugin to use with */
6/* FMOD's codec system. With this header you can make your own fileformat plugin that FMOD */
7/* can register and use. See the documentation and examples on how to make a working */
8/* plugin. */
9/* */
10/* For more detail visit: */
11/* https://fmod.com/resources/documentation-api?version=2.0&page=core-api.html */
12/* ======================================================================================== */
13#ifndef _FMOD_CODEC_H
14#define _FMOD_CODEC_H
15
16/*
17 Codec types
18*/
19typedef struct FMOD_CODEC_STATE FMOD_CODEC_STATE;
20typedef struct FMOD_CODEC_WAVEFORMAT FMOD_CODEC_WAVEFORMAT;
21
22/*
23 Codec constants
24*/
25#define FMOD_CODEC_PLUGIN_VERSION 1
26
27typedef int FMOD_CODEC_SEEK_METHOD;
28#define FMOD_CODEC_SEEK_METHOD_SET 0
29#define FMOD_CODEC_SEEK_METHOD_CURRENT 1
30#define FMOD_CODEC_SEEK_METHOD_END 2
31
32/*
33 Codec callbacks
34*/
35typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_OPEN_CALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
36typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_CLOSE_CALLBACK) (FMOD_CODEC_STATE *codec_state);
37typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_READ_CALLBACK) (FMOD_CODEC_STATE *codec_state, void *buffer, unsigned int samples_in, unsigned int *samples_out);
38typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETLENGTH_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *length, FMOD_TIMEUNIT lengthtype);
39typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
40typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *position, FMOD_TIMEUNIT postype);
41typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SOUNDCREATE_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, FMOD_SOUND *sound);
42typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETWAVEFORMAT_CALLBACK)(FMOD_CODEC_STATE *codec_state, int index, FMOD_CODEC_WAVEFORMAT *waveformat);
43
44/*
45 Codec functions
46*/
47typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_METADATA_FUNC) (FMOD_CODEC_STATE *codec_state, FMOD_TAGTYPE tagtype, char *name, void *data, unsigned int datalen, FMOD_TAGDATATYPE datatype, int unique);
48typedef void * (F_CALLBACK *FMOD_CODEC_ALLOC_FUNC) (unsigned int size, unsigned int align, const char *file, int line);
49typedef void (F_CALLBACK *FMOD_CODEC_FREE_FUNC) (void *ptr, const char *file, int line);
50typedef void (F_CALLBACK *FMOD_CODEC_LOG_FUNC) (FMOD_DEBUG_FLAGS level, const char *file, int line, const char *function, const char *string, ...);
51
52typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_FILE_READ_FUNC) (FMOD_CODEC_STATE *codec_state, void *buffer, unsigned int sizebytes, unsigned int *bytesread);
53typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_FILE_SEEK_FUNC) (FMOD_CODEC_STATE *codec_state, unsigned int pos, FMOD_CODEC_SEEK_METHOD method);
54typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_FILE_TELL_FUNC) (FMOD_CODEC_STATE *codec_state, unsigned int *pos);
55typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_FILE_SIZE_FUNC) (FMOD_CODEC_STATE *codec_state, unsigned int *size);
56
57/*
58 Codec structures
59*/
60typedef struct FMOD_CODEC_DESCRIPTION
61{
62 unsigned int apiversion;
63 const char *name;
64 unsigned int version;
65 int defaultasstream;
66 FMOD_TIMEUNIT timeunits;
67 FMOD_CODEC_OPEN_CALLBACK open;
68 FMOD_CODEC_CLOSE_CALLBACK close;
69 FMOD_CODEC_READ_CALLBACK read;
70 FMOD_CODEC_GETLENGTH_CALLBACK getlength;
71 FMOD_CODEC_SETPOSITION_CALLBACK setposition;
72 FMOD_CODEC_GETPOSITION_CALLBACK getposition;
73 FMOD_CODEC_SOUNDCREATE_CALLBACK soundcreate;
74 FMOD_CODEC_GETWAVEFORMAT_CALLBACK getwaveformat;
75} FMOD_CODEC_DESCRIPTION;
76
77struct FMOD_CODEC_WAVEFORMAT
78{
79 const char* name;
80 FMOD_SOUND_FORMAT format;
81 int channels;
82 int frequency;
83 unsigned int lengthbytes;
84 unsigned int lengthpcm;
85 unsigned int pcmblocksize;
86 int loopstart;
87 int loopend;
88 FMOD_MODE mode;
89 FMOD_CHANNELMASK channelmask;
90 FMOD_CHANNELORDER channelorder;
91 float peakvolume;
92};
93
94typedef struct FMOD_CODEC_STATE_FUNCTIONS
95{
96 FMOD_CODEC_METADATA_FUNC metadata;
97 FMOD_CODEC_ALLOC_FUNC alloc;
98 FMOD_CODEC_FREE_FUNC free;
99 FMOD_CODEC_LOG_FUNC log;
100 FMOD_CODEC_FILE_READ_FUNC read;
101 FMOD_CODEC_FILE_SEEK_FUNC seek;
102 FMOD_CODEC_FILE_TELL_FUNC tell;
103 FMOD_CODEC_FILE_SIZE_FUNC size;
104} FMOD_CODEC_STATE_FUNCTIONS;
105
106struct FMOD_CODEC_STATE
107{
108 void *plugindata;
109 FMOD_CODEC_WAVEFORMAT *waveformat;
110 FMOD_CODEC_STATE_FUNCTIONS *functions;
111 int numsubsounds;
112};
113
114/*
115 Codec macros
116*/
117#define FMOD_CODEC_METADATA(_state, _tagtype, _name, _data, _datalen, _datatype, _unique) \
118 (_state)->functions->metadata(_size, _tagtype, _name, _data, _datalen, _datatype, _unique)
119#define FMOD_CODEC_ALLOC(_state, _size, _align) \
120 (_state)->functions->alloc(_size, _align, __FILE__, __LINE__)
121#define FMOD_CODEC_FREE(_state, _ptr) \
122 (_state)->functions->free(_ptr, __FILE__, __LINE__)
123#define FMOD_CODEC_LOG(_state, _level, _location, _format, ...) \
124 (_state)->functions->log(_level, __FILE__, __LINE__, _location, _format, __VA_ARGS__)
125#define FMOD_CODEC_FILE_READ(_state, _buffer, _sizebytes, _bytesread) \
126 (_state)->functions->read(_state, _buffer, _sizebytes, _bytesread)
127#define FMOD_CODEC_FILE_SEEK(_state, _pos, _method) \
128 (_state)->functions->seek(_state, _pos, _method)
129#define FMOD_CODEC_FILE_TELL(_state, _pos) \
130 (_state)->functions->tell(_state, _pos)
131#define FMOD_CODEC_FILE_SIZE(_state, _size) \
132 (_state)->functions->size(_state, _size)
133
134#endif
135
136