aboutsummaryrefslogtreecommitdiff
path: root/common/fmplayer_file.h
diff options
context:
space:
mode:
authorTakamichi Horikawa <takamichiho@gmail.com>2017-03-27 23:32:18 +0900
committerTakamichi Horikawa <takamichiho@gmail.com>2017-03-27 23:32:18 +0900
commit0073f2b8befc6163f2970cb7a01e75fffc95994e (patch)
treeaab8d559720269e65b5ad05c07d98a865ff14e57 /common/fmplayer_file.h
parente2ee18347d45e4620a8279afb8b0bc4a809441ef (diff)
refactor common file loading functions
Diffstat (limited to 'common/fmplayer_file.h')
-rw-r--r--common/fmplayer_file.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/common/fmplayer_file.h b/common/fmplayer_file.h
new file mode 100644
index 0000000..fd7c53e
--- /dev/null
+++ b/common/fmplayer_file.h
@@ -0,0 +1,52 @@
+#ifndef MYON_FMPLAYER_FILE_H_INCLUDED
+#define MYON_FMPLAYER_FILE_H_INCLUDED
+
+#include <stddef.h>
+#include "fmdriver/fmdriver.h"
+#include "fmdriver/fmdriver_pmd.h"
+#include "fmdriver/fmdriver_fmp.h"
+
+enum fmplayer_file_type {
+ FMPLAYER_FILE_TYPE_PMD,
+ FMPLAYER_FILE_TYPE_FMP
+};
+
+enum fmplayer_file_error {
+ FMPLAYER_FILE_ERR_OK,
+ FMPLAYER_FILE_ERR_NOMEM,
+ FMPLAYER_FILE_ERR_FILEIO,
+ FMPLAYER_FILE_ERR_BADFILE_SIZE,
+ FMPLAYER_FILE_ERR_BADFILE,
+ FMPLAYER_FILE_ERR_COUNT
+};
+
+struct fmplayer_file {
+ void *path;
+ enum fmplayer_file_type type;
+ union {
+ struct driver_pmd pmd;
+ struct driver_fmp fmp;
+ } driver;
+ bool pmd_ppc_err;
+ bool pmd_ppz_err;
+ bool fmp_pvi_err;
+ bool fmp_ppz_err;
+ void *buf;
+ void *ppzbuf[2];
+};
+struct fmplayer_file *fmplayer_file_alloc(const void *path, enum fmplayer_file_error *error);
+void fmplayer_file_free(const struct fmplayer_file *fmfile);
+void fmplayer_file_load(struct fmdriver_work *work, struct fmplayer_file *fmfile);
+
+const char *fmplayer_file_strerror(enum fmplayer_file_error error);
+const wchar_t *fmplayer_file_strerror_w(enum fmplayer_file_error error);
+
+// path: wchar_t* on windows, else char*
+// examples:
+// fmplayer_fileread("/home/foo/bar.mz", 0, 0, &filesize);
+// fmplayer_fileread("/home/foo/bar.mz", "BAZ", ".PVI", &filesize);
+void *fmplayer_fileread(const void *path, const char *pcmname, const char *extension, size_t maxsize, size_t *filesize, enum fmplayer_file_error *error);
+
+void *fmplayer_path_dup(const void *path);
+
+#endif // MYON_FMPLAYER_FILE_H_INCLUDED