blob: df408e77cf59df02f47694d3e4aaa846f3fb6852 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
}
|