Mercurial > molko
diff libmlk-core/mlk/core/music.c @ 641:fcd124e513ea
core: reintroduce VFS
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 01 Oct 2023 09:18:01 +0200 |
parents | 3761e33d429e |
children |
line wrap: on
line diff
--- a/libmlk-core/mlk/core/music.c Wed Sep 27 22:03:17 2023 +0200 +++ b/libmlk-core/mlk/core/music.c Sun Oct 01 09:18:01 2023 +0200 @@ -19,9 +19,12 @@ #include <assert.h> #include <string.h> +#include "alloc.h" #include "err.h" #include "music.h" #include "sys_p.h" +#include "vfs.h" +#include "vfs_p.h" #define SOURCE(mus) ((const struct mlk__audiostream *)mus->handle)->source @@ -44,6 +47,26 @@ } int +mlk_music_openvfs(struct mlk_music *music, struct mlk_vfs_file *file) +{ + assert(music); + assert(file); + + char *data; + size_t datasz; + int ret = 0; + + if (!(data = mlk_vfs_file_read_all(file, &datasz))) + return -1; + if (mlk__audiostream_openmem((struct mlk__audiostream **)&music->handle, data, datasz) < 0) + ret = -1; + + mlk_alloc_free(data); + + return ret; +} + +int mlk_music_ok(const struct mlk_music *mus) { return mus && mus->handle;