-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaudio.c
More file actions
37 lines (29 loc) · 834 Bytes
/
audio.c
File metadata and controls
37 lines (29 loc) · 834 Bytes
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
#include <stdbool.h>
#include "audio.h"
// Function prototypes
static bool load_audio_assets();
// Initialize audio
bool audio_init() {
// Initialize the mixer
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) {
fprintf(stderr, "SDL_mixer could not initialize! SDL_mixer Error: %s\n", Mix_GetError());
return false;
}
// Load audio assets
if (!load_audio_assets()) {
fprintf(stderr, "Failed to load audio assets!\n");
return false;
}
return true;
}
// Load audio assets
static bool load_audio_assets() {
// Load music, sound effects, and other audio assets here
// Return false if any loading fails
return true;
}
// Clean up resources
void audio_cleanup() {
// Free music, sound effects, and other audio assets here
Mix_CloseAudio();
}