aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Audio/Source.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-07-27 00:01:34 +0800
committerchai <chaifix@163.com>2018-07-27 00:01:34 +0800
commitb855ebb91ad8d97617ec1aa418b4add84670a07d (patch)
treeb11847a1879a2582c9cfd380074ad4c70f17a1a8 /src/libjin/Audio/Source.cpp
parent1a882936e91826e4d69584745e16a79650272015 (diff)
*change name
Diffstat (limited to 'src/libjin/Audio/Source.cpp')
-rw-r--r--src/libjin/Audio/Source.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/libjin/Audio/Source.cpp b/src/libjin/Audio/Source.cpp
new file mode 100644
index 0000000..ceb882d
--- /dev/null
+++ b/src/libjin/Audio/Source.cpp
@@ -0,0 +1,28 @@
+#include "../modules.h"
+#if JIN_MODULES_AUDIO
+
+#include <cstring>
+#include "source.h"
+
+namespace jin
+{
+namespace audio
+{
+
+ static int check_header(const void *data, int size, char *str, int offset) {
+ int len = strlen(str);
+ return (size >= offset + len) && !memcmp((char*)data + offset, str, len);
+ }
+
+ SourceType Source::getType(const void* mem, int size)
+ {
+ if(check_header(mem, size, "WAVE", 8))
+ return SourceType::WAV;
+ if(check_header(mem, size, "OggS", 0))
+ return SourceType::OGG;
+ return SourceType::INVALID;
+ }
+
+}
+}
+#endif // JIN_MODULES_AUDIO \ No newline at end of file