}
static u32 jsfio_write(GF_FileIO *fileio, u8 *buffer, u32 bytes)
{
	JSValue argv[1], res;
	u32 ret;
	JSFileIOCtx *ioctx = gf_fileio_get_udta(fileio);
	if (!ioctx || !ioctx->gfio) return GF_BAD_PARAM;
	JSContext *ctx = ioctx->factory->ctx;

	gf_js_lock(ctx, GF_TRUE);
	argv[0] = JS_NewArrayBuffer(ctx, buffer, bytes, NULL, 0, 0);
	res = JS_Call(ctx, ioctx->factory->write, ioctx->js_obj, 1, argv);
	JS_FreeValue(ctx, argv[0]);
	JS_ToInt32(ctx, &ret, res);
	JS_FreeValue(ctx, res);
	gf_js_lock(ctx, GF_FALSE);
	return ret;
}
static u32 jsfio_write(GF_FileIO *fileio, u8 *buffer, u32 bytes)
{
	JSValue argv[1], res;
	u32 ret;
	JSFileIOCtx *ioctx = gf_fileio_get_udta(fileio);
	if (!ioctx || !ioctx->gfio) return GF_BAD_PARAM;
	JSContext *ctx = ioctx->factory->ctx;

	gf_js_lock(ctx, GF_TRUE);
	argv[0] = JS_NewArrayBuffer(ctx, buffer, bytes, NULL, 0, 0);
	res = JS_Call(ctx, ioctx->factory->write, ioctx->js_obj, 1, argv);
	JS_FreeValue(ctx, argv[0]);
	JS_ToInt32(ctx, &ret, res);
	JS_FreeValue(ctx, res);
	gf_js_lock(ctx, GF_FALSE);
	return ret;