1 /*
2  * This software is licensed under the terms of the MIT License.
3  * See COPYING for further information.
4  * ---
5  * Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
6  * Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
7  */
8 
9 #ifndef IGUARD_audio_backend_h
10 #define IGUARD_audio_backend_h
11 
12 #include "taisei.h"
13 
14 #include "audio.h"
15 
16 typedef enum {
17 	SNDGROUP_ALL,
18 	SNDGROUP_MAIN,
19 	SNDGROUP_UI,
20 } AudioBackendSoundGroup;
21 
22 typedef struct AudioFuncs {
23 	bool (*init)(void);
24 	bool (*music_fade)(double fadetime);
25 	bool (*music_is_paused)(void);
26 	bool (*music_is_playing)(void);
27 	bool (*music_pause)(void);
28 	bool (*music_play)(MusicImpl *mus);
29 	bool (*music_resume)(void);
30 	bool (*music_set_global_volume)(double gain);
31 	bool (*music_set_loop_point)(MusicImpl *mus, double pos);
32 	bool (*music_set_position)(double pos);
33 	bool (*music_stop)(void);
34 	bool (*output_works)(void);
35 	bool (*set_sfx_volume)(float gain);
36 	bool (*shutdown)(void);
37 	bool (*sound_loop)(SoundImpl *snd, AudioBackendSoundGroup group);
38 	bool (*sound_pause_all)(AudioBackendSoundGroup group);
39 	bool (*sound_play)(SoundImpl *snd, AudioBackendSoundGroup group);
40 	bool (*sound_play_or_restart)(SoundImpl *snd, AudioBackendSoundGroup group);
41 	bool (*sound_resume_all)(AudioBackendSoundGroup group);
42 	bool (*sound_set_global_volume)(double gain);
43 	bool (*sound_set_volume)(SoundImpl *snd, double vol);
44 	bool (*sound_stop_all)(AudioBackendSoundGroup group);
45 	bool (*sound_stop_loop)(SoundImpl *snd);
46 	const char* const* (*get_supported_music_exts)(uint *out_numexts);
47 	const char* const* (*get_supported_sound_exts)(uint *out_numexts);
48 	MusicImpl* (*music_load)(const char *vfspath);
49 	SoundImpl* (*sound_load)(const char *vfspath);
50 	void (*music_unload)(MusicImpl *mus);
51 	void (*sound_unload)(SoundImpl *snd);
52 } AudioFuncs;
53 
54 typedef struct AudioBackend {
55 	const char *name;
56 	AudioFuncs funcs;
57 	void *custom;
58 } AudioBackend;
59 
60 extern AudioBackend _a_backend;
61 
62 bool audio_backend_init(void);
63 
64 #endif // IGUARD_audio_backend_h
65