Mercurial > molko
comparison src/libmlk-core/core/sound.c @ 343:9eb25198d706
js: add sound bindings
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 16 Oct 2021 22:17:09 +0200 |
parents | 8f9937403749 |
children | 12367bfc2df6 |
comparison
equal
deleted
inserted
replaced
342:17569bc205fa | 343:9eb25198d706 |
---|---|
21 | 21 |
22 #include <SDL_mixer.h> | 22 #include <SDL_mixer.h> |
23 | 23 |
24 #include "error.h" | 24 #include "error.h" |
25 #include "sound.h" | 25 #include "sound.h" |
26 #include "vfs.h" | |
27 #include "vfs_p.h" | |
26 | 28 |
27 int | 29 int |
28 sound_open(struct sound *snd, const char *path) | 30 sound_open(struct sound *snd, const char *path) |
29 { | 31 { |
30 assert(snd); | 32 assert(snd); |
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 !(snd->handle = Mix_LoadWAV_RW(ops, 1))) | 50 !(snd->handle = Mix_LoadWAV_RW(ops, 1))) |
51 return errorf("%s", SDL_GetError()); | |
52 | |
53 return 0; | |
54 } | |
55 | |
56 int | |
57 sound_openvfs(struct sound *snd, struct vfs_file *file) | |
58 { | |
59 assert(snd); | |
60 assert(vfs_file_ok(file)); | |
61 | |
62 SDL_RWops *ops; | |
63 | |
64 if (!(ops = vfs_to_rw(file))) | |
65 return -1; | |
66 if (!(snd->handle = Mix_LoadWAV_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 |