Mercurial > molko
diff src/libmlk-core/core/music.c @ 341:0c18acf4517e
js: add music bindings
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 16 Oct 2021 09:45:45 +0200 |
parents | 8f9937403749 |
children | 460c78706989 |
line wrap: on
line diff
--- a/src/libmlk-core/core/music.c Sat Oct 16 09:13:40 2021 +0200 +++ b/src/libmlk-core/core/music.c Sat Oct 16 09:45:45 2021 +0200 @@ -23,6 +23,8 @@ #include "error.h" #include "music.h" +#include "vfs.h" +#include "vfs_p.h" int music_open(struct music *mus, const char *path) @@ -52,6 +54,22 @@ } int +music_openvfs(struct music *mus, struct vfs_file *file) +{ + assert(mus); + assert(vfs_file_ok(file)); + + SDL_RWops *ops; + + if (!(ops = vfs_to_rw(file))) + return -1; + if (!(mus->handle = Mix_LoadMUS_RW(ops, 1))) + return errorf("%s", SDL_GetError()); + + return 0; +} + +int music_ok(const struct music *mus) { return mus && mus->handle;