summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..df408e7
--- /dev/null
+++ b/main.c
@@ -0,0 +1,41 @@
+#include <SDL2/SDL.h>
+#include <SDL2/SDL_mixer.h>
+#include <stdio.h>
+
+int main(int argc, char **argv) {
+ (void)argc, (void)argv;
+
+ /* Initialize SDL and SDL_mixer. */
+ if (SDL_Init(SDL_INIT_AUDIO)) {
+ fprintf(stderr, "%s\n", SDL_GetError());
+ return 1;
+ }
+ if (atexit(SDL_Quit)) {
+ perror("atexit(SDL_Quit)");
+ SDL_Quit();
+ return 1;
+ }
+ if (Mix_Init(MIX_INIT_FLAC) != MIX_INIT_FLAC) {
+ fprintf(stderr, "%s\n", Mix_GetError());
+ return 1;
+ }
+ if (atexit(Mix_Quit)) {
+ perror("atexit(Mix_Quit)");
+ Mix_Quit();
+ return 1;
+ }
+
+ /* Open audio device. */
+ if (Mix_OpenAudio(48000, AUDIO_F32SYS, 2, 4096)) {
+ fprintf(stderr, "%s\n", Mix_GetError());
+ return 1;
+ }
+ if (atexit(Mix_CloseAudio)) {
+ perror("atexit(Mix_CloseAudio)");
+ Mix_CloseAudio();
+ return 1;
+ }
+
+ /* All cleanup is handled through atexit. */
+ return 0;
+}