blob: f53e042b4897993b7babb80c7fec099f2eabc291 (
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
42
43
44
45
|
#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;
}
/* Allocate mixing channels to play more than 8 sounds in parallel. */
if (Mix_AllocateChannels(69) != 69)
fprintf(stderr, "%s\n", Mix_GetError());
/* Cleanup is handled by previous atexit calls. */
return 0;
}
|