comparison 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
comparison
equal deleted inserted replaced
340:64aff0afc8ac 341:0c18acf4517e
21 21
22 #include <SDL_mixer.h> 22 #include <SDL_mixer.h>
23 23
24 #include "error.h" 24 #include "error.h"
25 #include "music.h" 25 #include "music.h"
26 #include "vfs.h"
27 #include "vfs_p.h"
26 28
27 int 29 int
28 music_open(struct music *mus, const char *path) 30 music_open(struct music *mus, const char *path)
29 { 31 {
30 assert(mus); 32 assert(mus);
44 46
45 SDL_RWops *ops; 47 SDL_RWops *ops;
46 48
47 if (!(ops = SDL_RWFromConstMem(buffer, buffersz)) || 49 if (!(ops = SDL_RWFromConstMem(buffer, buffersz)) ||
48 !(mus->handle = Mix_LoadMUS_RW(ops, 1))) 50 !(mus->handle = Mix_LoadMUS_RW(ops, 1)))
51 return errorf("%s", SDL_GetError());
52
53 return 0;
54 }
55
56 int
57 music_openvfs(struct music *mus, struct vfs_file *file)
58 {
59 assert(mus);
60 assert(vfs_file_ok(file));
61
62 SDL_RWops *ops;
63
64 if (!(ops = vfs_to_rw(file)))
65 return -1;
66 if (!(mus->handle = Mix_LoadMUS_RW(ops, 1)))
49 return errorf("%s", SDL_GetError()); 67 return errorf("%s", SDL_GetError());
50 68
51 return 0; 69 return 0;
52 } 70 }
53 71