summaryrefslogtreecommitdiff
path: root/src/sdl.c
diff options
context:
space:
mode:
authorzlago2024-09-01 17:41:03 +0200
committerzlago2024-09-01 17:41:03 +0200
commit2eab12e43c040d369b685efc13e2452405cf6451 (patch)
tree9be66da4ce69f0a3d752159cef4a81abd90a5893 /src/sdl.c
parent519e350739f55cfd3ef8b9a97e241b61ca9ed1f9 (diff)
tweaks
Diffstat (limited to 'src/sdl.c')
-rw-r--r--src/sdl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/sdl.c b/src/sdl.c
index e780906..875cde5 100644
--- a/src/sdl.c
+++ b/src/sdl.c
@@ -5,7 +5,9 @@
#include <stdlib.h>
#include <stdio.h>
-#include "modules/openmpt.h"
+#include "include.h"
+
+int module_openmpt(struct blob *file, struct userdata *userdata);
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
@@ -15,7 +17,6 @@ SDL_Window *window = NULL;
struct blob load_file(char const *const name);
-#include "include.h"
struct userdata userdata = {
.callback = NULL,
.user = NULL,
@@ -107,10 +108,12 @@ int main(void) {
if (module_openmpt(&file, audio, &newuser)) {
// error
} else {
+ SDL_LockAudioDevice(audio);
if (userdata.freefunc != NULL) {
userdata.freefunc(userdata.user);
}
userdata = newuser;
+ SDL_UnlockAudioDevice(audio);
}
free(file.data);
break;
@@ -120,6 +123,11 @@ int main(void) {
}
}
done:
+ if (userdata.freefunc != NULL) {
+ SDL_LockAudioDevice(audio);
+ userdata.freefunc(userdata.user);
+ SDL_UnlockAudioDevice(audio);
+ }
SDL_DestroyRenderer(renderer);