fix compile warnings; remove soloud
This commit is contained in:
2
Makefile
2
Makefile
@@ -1,6 +1,6 @@
|
||||
debug: FORCE
|
||||
meson setup build_dbg -Dbuildtype=debugoptimized
|
||||
meson install --only-changed -C build_dbg
|
||||
meson install --only-changed -C --verbose build_dbg
|
||||
|
||||
fast: FORCE
|
||||
meson setup build_fast
|
||||
|
||||
13
meson.build
13
meson.build
@@ -207,15 +207,6 @@ if host_machine.system() != 'emscripten'
|
||||
endif
|
||||
endif
|
||||
|
||||
# Try to find system-installed soloud first
|
||||
soloud_dep = dependency('soloud', static: true, required: false)
|
||||
if not soloud_dep.found()
|
||||
message('⚙ System soloud not found, building subproject...')
|
||||
deps += dependency('soloud', static:true)
|
||||
else
|
||||
deps += soloud_dep
|
||||
endif
|
||||
|
||||
link_args = link
|
||||
sources = []
|
||||
src += [ # core
|
||||
@@ -229,10 +220,6 @@ src += [ # core
|
||||
'qjs_wota.c',
|
||||
]
|
||||
|
||||
src += [ # engine
|
||||
'qjs_soloud.c',
|
||||
]
|
||||
|
||||
src += ['quickjs.c', 'libregexp.c', 'libunicode.c', 'cutils.c', 'dtoa.c']
|
||||
|
||||
scripts = [
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#define countof(a) (sizeof(a)/sizeof(*(a)))
|
||||
|
||||
static JSClassID enet_host_id;
|
||||
static JSClassID enet_peer_class_id;
|
||||
|
||||
/* Finalizers */
|
||||
static void js_enet_host_finalizer(JSRuntime *rt, JSValue val)
|
||||
{
|
||||
ENetHost *host = JS_GetOpaque(val, enet_host_id);
|
||||
|
||||
@@ -306,7 +306,6 @@ JSC_CCALL(fd_fstat,
|
||||
if (fstat(fd, &st) != 0)
|
||||
return JS_ThrowInternalError(js, "fstat failed: %s", strerror(errno));
|
||||
|
||||
printf("fstat on %s\n", argv[0]);
|
||||
JSValue obj = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, obj, "size", JS_NewInt64(js, st.st_size));
|
||||
JS_SetPropertyStr(js, obj, "mode", JS_NewInt32(js, st.st_mode));
|
||||
|
||||
@@ -56,9 +56,6 @@ JSC_CCALL(js_eval_compile,
|
||||
|
||||
// Compile a function object into a bytecode blob.
|
||||
JSC_CCALL(js_compile_blob,
|
||||
JSRuntime *rt = JS_GetRuntime(js);
|
||||
// JS_SetStripInfo(rt, JS_STRIP_SOURCE);
|
||||
// JS_SetStripInfo(rt, JS_STRIP_DEBUG);
|
||||
size_t size;
|
||||
uint8_t *data = JS_WriteObject(js, &size, argv[0], JS_WRITE_OBJ_BYTECODE);
|
||||
if (!data) {
|
||||
|
||||
@@ -46,7 +46,6 @@ static JSValue js_miniz_read(JSContext *js, JSValue self, int argc, JSValue *arg
|
||||
return JS_ThrowReferenceError(js, "Could not create data.\n");
|
||||
|
||||
mz_zip_archive *zip = calloc(sizeof(*zip),1);
|
||||
int success = mz_zip_reader_init_mem(zip, data, len, 0);
|
||||
int err = mz_zip_get_last_error(zip);
|
||||
if (err)
|
||||
return JS_ThrowInternalError(js, "miniz error: %s\n", mz_zip_get_error_string(err));
|
||||
@@ -162,15 +161,8 @@ static JSValue js_miniz_decompress(JSContext *js,
|
||||
return JS_ThrowInternalError(js,
|
||||
"miniz: decompression failed");
|
||||
|
||||
/* wrap for JS */
|
||||
JSValue ret;
|
||||
int asString = (argc > 1) && JS_ToBool(js, argv[1]);
|
||||
|
||||
// if (asString)
|
||||
ret = JS_NewStringLen(js, (const char *)out_ptr, out_len);
|
||||
// else
|
||||
// ret = JS_NewArrayBufferCopy(js, out_ptr, out_len);
|
||||
|
||||
#ifdef MZ_FREE
|
||||
MZ_FREE(out_ptr);
|
||||
#else
|
||||
|
||||
36
scripts/os.c
36
scripts/os.c
@@ -262,40 +262,6 @@ static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef TRACY_ENABLE
|
||||
#include <tracy/TracyC.h>
|
||||
JSC_CCALL(os_frame,
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
TracyCFrameMark
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_img,
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
size_t len;
|
||||
double width, height;
|
||||
JS_ToFloat64(js,&width,argv[1]);
|
||||
JS_ToFloat64(js,&height,argv[2]);
|
||||
___tracy_emit_frame_image(js_get_blob_data(js, &len, argv[0]), width, height, 0, 0);
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_message,
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
size_t len;
|
||||
const char *str = JS_ToCStringLen(js, &len, argv[0]);
|
||||
TracyCMessage(str,len);
|
||||
JS_FreeCString(js,str);
|
||||
)
|
||||
#else
|
||||
JSC_CCALL(os_frame,
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_img,
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_message,
|
||||
)
|
||||
#endif
|
||||
|
||||
JSC_SCALL(os_system,
|
||||
int err = system(str);
|
||||
ret = number2js(js,err);
|
||||
@@ -496,9 +462,9 @@ static const JSCFunctionListEntry js_os_funcs[] = {
|
||||
MIST_FUNC_DEF(os, rusage, 0),
|
||||
MIST_FUNC_DEF(os, mallinfo, 0),
|
||||
MIST_FUNC_DEF(os, buffer2string, 1),
|
||||
MIST_FUNC_DEF(os, frame, 0),
|
||||
MIST_FUNC_DEF(os, system, 1),
|
||||
MIST_FUNC_DEF(os, exit, 0),
|
||||
MIST_FUNC_DEF(os, sleep, 1),
|
||||
MIST_FUNC_DEF(os, dylib_open, 1),
|
||||
MIST_FUNC_DEF(os, dylib_symbol, 2),
|
||||
MIST_FUNC_DEF(os, load_internal, 1),
|
||||
|
||||
@@ -79,7 +79,7 @@ static SDL_SpinLock main_queue_lock = 0;
|
||||
|
||||
static SDL_Mutex *actors_mutex = NULL;
|
||||
static struct { char *key; cell_rt *value; } *actors = NULL;
|
||||
static unsigned char *zip_buffer_global = NULL;
|
||||
|
||||
static qop_desc qop_core;
|
||||
static qop_file *qop_hashmap = NULL;
|
||||
cell_rt *root_cell = NULL;
|
||||
@@ -87,11 +87,6 @@ cell_rt *root_cell = NULL;
|
||||
static SDL_AtomicInt shutting_down;
|
||||
static SDL_AtomicInt runners_count;
|
||||
|
||||
static inline uint64_t now_ns()
|
||||
{
|
||||
return SDL_GetTicksNS();
|
||||
}
|
||||
|
||||
static void exit_handler(void)
|
||||
{
|
||||
SDL_SetAtomicInt(&shutting_down, 1);
|
||||
|
||||
@@ -27,7 +27,6 @@ JSC_CCALL(os_mailbox_push,
|
||||
return JS_ThrowInternalError(js, "No mailbox found for given ID");
|
||||
}
|
||||
|
||||
cell_rt *target = get_actor(id);
|
||||
JS_FreeCString(js,id);
|
||||
|
||||
/* JSValue sys = JS_GetPropertyStr(js, argv[1], "__SYSTEM__");
|
||||
|
||||
@@ -1,201 +0,0 @@
|
||||
#include "cell.h"
|
||||
|
||||
#define STB_HEXWAVE_IMPLEMENTATION
|
||||
#include "soloud_c.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define countof(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
#define FNSIG (JSContext *js, JSValueConst this_val, int argc, JSValue *argv)
|
||||
#define GETSIG (JSContext *js, JSValueConst this_val)
|
||||
#define SETSIG (JSContext *js, JSValueConst this_val, JSValue val)
|
||||
|
||||
#define JSCLASS(TYPE, FINALIZER) \
|
||||
static JSClassID js_##TYPE##_class_id; \
|
||||
static inline TYPE *js2##TYPE(JSContext *js, JSValue v) { \
|
||||
return JS_GetOpaque(v, js_##TYPE##_class_id); \
|
||||
} \
|
||||
static inline JSValue TYPE##2js(JSContext *js, TYPE *data) { \
|
||||
JSValue obj = JS_NewObjectClass(js, js_##TYPE##_class_id); \
|
||||
JS_SetOpaque(obj, data); \
|
||||
return obj; \
|
||||
} \
|
||||
static inline void js_##TYPE##_finalizer(JSRuntime *rt, JSValue val) { \
|
||||
FINALIZER(JS_GetOpaque(val, js_##TYPE##_class_id)); \
|
||||
} \
|
||||
static JSClassDef js_##TYPE##_class = { \
|
||||
#TYPE, \
|
||||
.finalizer = js_##TYPE##_finalizer \
|
||||
}; \
|
||||
|
||||
#define JS_GETPROP(C, PROP, VAL, TYPE) \
|
||||
{ \
|
||||
JSValue tmp = JS_GetPropertyStr(js, VAL, #PROP); \
|
||||
JS_To##TYPE(js, &C, tmp); \
|
||||
JS_FreeValue(js, tmp); \
|
||||
} \
|
||||
|
||||
typedef unsigned int voice;
|
||||
|
||||
static Soloud *soloud;
|
||||
|
||||
void voice_free(unsigned int *voice)
|
||||
{
|
||||
Soloud_stop(soloud, *voice);
|
||||
free(voice);
|
||||
}
|
||||
|
||||
JSCLASS(Wav, Wav_destroy)
|
||||
JSCLASS(voice, voice_free)
|
||||
JSCLASS(Bus, Bus_destroy)
|
||||
|
||||
static JSValue js_soloud_make(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
soloud = Soloud_create();
|
||||
Soloud_initEx(soloud, SOLOUD_CLIP_ROUNDOFF, SOLOUD_NULLDRIVER, 44100, SOLOUD_AUTO, 2);
|
||||
JSValue obj = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, obj, "channels", JS_NewFloat64(js, Soloud_getBackendChannels(soloud)));
|
||||
JS_SetPropertyStr(js, obj, "samplerate", JS_NewFloat64(js, Soloud_getBackendSamplerate(soloud)));
|
||||
return obj;
|
||||
}
|
||||
|
||||
static JSValue js_soloud_play(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
Wav *wav = js2Wav(js,argv[0]);
|
||||
unsigned int *ret = malloc(sizeof(*ret));
|
||||
*ret = Soloud_play(soloud, wav);
|
||||
JSValue voice = voice2js(js,ret);
|
||||
return voice;
|
||||
}
|
||||
|
||||
static JSValue js_soloud_mix(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
int req;
|
||||
JS_ToInt32(js, &req, argv[0]);
|
||||
float *buf = malloc(2*req*sizeof(float));
|
||||
Soloud_mix(soloud, buf, req);
|
||||
return js_new_blob_stoned_copy(js, buf, 2*req*sizeof(float));
|
||||
}
|
||||
|
||||
// Create a voice from a WAV file
|
||||
static JSValue js_load_wav_mem(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
size_t len;
|
||||
void *data = js_get_blob_data(js, &len, argv[0]);
|
||||
Wav *wav = Wav_create();
|
||||
if (Wav_loadMemEx(wav, data, len, 1, 1)) {
|
||||
Wav_destroy(wav);
|
||||
return JS_ThrowReferenceError(js, "buffer data not wav data");
|
||||
}
|
||||
return Wav2js(js, wav);
|
||||
}
|
||||
|
||||
// Create a voice from pure PWM data
|
||||
static JSValue js_load_pwm(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
size_t len;
|
||||
void *data = js_get_blob_data(js, &len, argv[0]);
|
||||
Wav *wav = Wav_create();
|
||||
Wav_loadRawWaveEx(wav, data, len, js2number(js,argv[1]), js2number(js,argv[2]), 1, 1);
|
||||
return Wav2js(js, wav);
|
||||
}
|
||||
|
||||
static JSValue js_soloud_profile(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
JSValue prof = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, prof, "active_voices", JS_NewFloat64(js, Soloud_getActiveVoiceCount(soloud)));
|
||||
JS_SetPropertyStr(js, prof, "voices", JS_NewFloat64(js, Soloud_getVoiceCount(soloud)));
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_soloud_funcs[] = {
|
||||
JS_CFUNC_DEF("init", 3, js_soloud_make),
|
||||
JS_CFUNC_DEF("mix", 1, js_soloud_mix),
|
||||
JS_CFUNC_DEF("load_pwm", 3, js_load_pwm),
|
||||
JS_CFUNC_DEF("load_wav_mem", 1, js_load_wav_mem),
|
||||
JS_CFUNC_DEF("play", 1, js_soloud_play),
|
||||
JS_CFUNC_DEF("profile", 0, js_soloud_profile),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry *js_Wav_funcs;
|
||||
|
||||
#define SOLOUD_GETSET(ENTRY, TYPE) \
|
||||
static JSValue js_voice_set_##ENTRY (JSContext *js, JSValueConst self, JSValue val) { \
|
||||
unsigned int voice = *js2voice(js, self); \
|
||||
Soloud_set##ENTRY(soloud, voice, js2##TYPE(js, val)); \
|
||||
return JS_NULL; \
|
||||
} \
|
||||
static JSValue js_voice_get_##ENTRY (JSContext *js, JSValueConst self) { \
|
||||
unsigned int voice = *js2voice(js,self); \
|
||||
return TYPE##2js(js, Soloud_get##ENTRY(soloud, voice)); \
|
||||
} \
|
||||
|
||||
static JSValue js_voice_seek(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
Soloud_seek(soloud, voice, js2number(js, argv[0]));
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_voice_stop(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
Soloud_stop(soloud, voice);
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_voice_setInaudibleBehavior(JSContext *js, JSValueConst self, int argc, JSValue *argv)
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
int mustTick = js2bool(js, argv[0]);
|
||||
int kill = js2bool(js, argv[1]);
|
||||
Soloud_setInaudibleBehavior(soloud, voice, mustTick, kill);
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_voice_valid(JSContext *js, JSValueConst self, int argc, JSValue *argv)
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
return JS_NewBool(js, Soloud_isValidVoiceHandle(soloud, voice));
|
||||
}
|
||||
|
||||
SOLOUD_GETSET(Volume, number);
|
||||
SOLOUD_GETSET(Pan, number)
|
||||
SOLOUD_GETSET(Samplerate, number)
|
||||
SOLOUD_GETSET(RelativePlaySpeed, number)
|
||||
SOLOUD_GETSET(LoopPoint, number)
|
||||
SOLOUD_GETSET(Looping, bool)
|
||||
SOLOUD_GETSET(AutoStop, bool)
|
||||
SOLOUD_GETSET(ProtectVoice, bool)
|
||||
|
||||
static const JSCFunctionListEntry js_voice_funcs[] = {
|
||||
JS_CFUNC_DEF("seek", 1, js_voice_seek),
|
||||
JS_CFUNC_DEF("stop", 0, js_voice_stop),
|
||||
JS_CGETSET_DEF("volume", js_voice_get_Volume, js_voice_set_Volume),
|
||||
JS_CGETSET_DEF("pan", js_voice_get_Pan, js_voice_set_Pan),
|
||||
JS_CGETSET_DEF("samplerate", js_voice_get_Samplerate, js_voice_set_Samplerate),
|
||||
JS_CGETSET_DEF("relativePlaySpeed", js_voice_get_RelativePlaySpeed, js_voice_set_RelativePlaySpeed),
|
||||
JS_CGETSET_DEF("loopPoint", js_voice_get_LoopPoint, js_voice_set_LoopPoint),
|
||||
JS_CGETSET_DEF("loop", js_voice_get_Looping, js_voice_set_Looping),
|
||||
JS_CGETSET_DEF("autoStop", js_voice_get_AutoStop, js_voice_set_AutoStop),
|
||||
JS_CGETSET_DEF("protect", js_voice_get_ProtectVoice, js_voice_set_ProtectVoice),
|
||||
JS_CFUNC_DEF("is_valid", 0, js_voice_valid),
|
||||
};
|
||||
|
||||
static const JSCFunctionListEntry *js_Bus_funcs;
|
||||
|
||||
#define INITCLASS(TYPE) \
|
||||
JS_NewClassID(&js_##TYPE##_class_id); \
|
||||
JS_NewClass(JS_GetRuntime(js), js_##TYPE##_class_id, &js_##TYPE##_class); \
|
||||
JSValue TYPE##_proto = JS_NewObject(js); \
|
||||
JS_SetPropertyFunctionList(js, TYPE##_proto, js_##TYPE##_funcs, countof(js_##TYPE##_funcs)); \
|
||||
JS_SetClassProto(js, js_##TYPE##_class_id, TYPE##_proto); \
|
||||
|
||||
JSValue js_soloud_use(JSContext *js)
|
||||
{
|
||||
INITCLASS(Wav)
|
||||
INITCLASS(voice)
|
||||
INITCLASS(Bus)
|
||||
JSValue export = JS_NewObject(js);
|
||||
JS_SetPropertyFunctionList(js, export, js_soloud_funcs, sizeof(js_soloud_funcs)/sizeof(JSCFunctionListEntry));
|
||||
return export;
|
||||
}
|
||||
@@ -1409,7 +1409,6 @@ void JS_SetRuntimeInfo(JSRuntime *rt, const char *s)
|
||||
|
||||
void JS_FreeRuntime(JSRuntime *rt)
|
||||
{
|
||||
struct list_head *el, *el1;
|
||||
int i;
|
||||
|
||||
JS_FreeValueRT(rt, rt->current_exception);
|
||||
@@ -7055,7 +7054,6 @@ int JS_HasProperty(JSContext *ctx, JSValueConst obj, JSAtom prop)
|
||||
{
|
||||
JSObject *p;
|
||||
int ret;
|
||||
JSValue obj1;
|
||||
|
||||
if (unlikely(JS_VALUE_GET_TAG(obj) != JS_TAG_OBJECT))
|
||||
return FALSE;
|
||||
@@ -9055,7 +9053,7 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
|
||||
{
|
||||
const char *p, *p_start;
|
||||
int sep, is_neg;
|
||||
BOOL is_float, has_legacy_octal;
|
||||
BOOL is_float;
|
||||
int atod_type = flags & ATOD_TYPE_MASK;
|
||||
char buf1[64], *buf;
|
||||
int i, j, len;
|
||||
@@ -9065,7 +9063,6 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
|
||||
|
||||
/* optional separator between digits */
|
||||
sep = (flags & ATOD_ACCEPT_UNDERSCORES) ? '_' : 256;
|
||||
has_legacy_octal = FALSE;
|
||||
|
||||
p = str;
|
||||
p_start = p;
|
||||
@@ -9098,7 +9095,6 @@ static JSValue js_atof(JSContext *ctx, const char *str, const char **pp,
|
||||
} else if ((p[1] >= '0' && p[1] <= '9') &&
|
||||
radix == 0 && (flags & ATOD_ACCEPT_LEGACY_OCTAL)) {
|
||||
int i;
|
||||
has_legacy_octal = TRUE;
|
||||
sep = 256;
|
||||
for (i = 1; (p[i] >= '0' && p[i] <= '7'); i++)
|
||||
continue;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/johnalanbrook/soloud.git
|
||||
revision = head
|
||||
depth = 1
|
||||
|
||||
[provide]
|
||||
soloud = soloud_dep
|
||||
Reference in New Issue
Block a user