From 18834c6a45884c7504567d917b22163cea83e886 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Thu, 17 Oct 2013 17:21:42 -0700 Subject: [PATCH] some static analysis cleanup --- .gitignore | 1 + libobs-d3d11/d3d11-exports.h | 2 +- libobs-d3d11/d3d11-shader.cpp | 2 +- libobs-d3d11/d3d11-subsystem.cpp | 2 +- libobs-opengl/gl-exports.h | 2 +- libobs-opengl/gl-shader.c | 77 +++++++++++++++++++++-------- libobs-opengl/gl-shaderparser.c | 8 +-- libobs-opengl/gl-shaderparser.h | 5 ++ libobs-opengl/gl-subsystem.c | 2 +- libobs-opengl/gl-subsystem.h | 1 + libobs-opengl/gl-zstencil.c | 1 + libobs/graphics/effect-parser.c | 11 +++-- libobs/graphics/effect.c | 27 ++++++++-- libobs/graphics/effect.h | 2 + libobs/graphics/graphics-internal.h | 2 +- libobs/graphics/graphics.c | 7 ++- libobs/graphics/graphics.h | 11 +++-- libobs/graphics/math-extra.c | 3 +- libobs/graphics/quat.c | 4 +- libobs/graphics/shader-parser.c | 8 +-- libobs/graphics/texture-render.c | 11 +++-- libobs/graphics/vec3.h | 6 +-- libobs/graphics/vec4.h | 8 +-- libobs/obs-module.c | 10 ++-- libobs/obs-scene.c | 6 +-- libobs/obs-source.c | 11 +++-- libobs/obs-source.h | 8 +-- libobs/obs-video.c | 18 ++++--- libobs/obs.h | 6 +-- libobs/util/bmem.c | 23 ++++++--- libobs/util/cf-lexer.c | 23 +++++---- libobs/util/cf-parser.h | 2 +- libobs/util/config-file.c | 9 ++-- libobs/util/darray.h | 6 ++- libobs/util/dstr.c | 34 ++++--------- libobs/util/lexer.c | 8 +-- libobs/util/platform-windows.c | 4 -- libobs/util/platform.c | 10 ++-- libobs/util/platform.h | 3 ++ libobs/util/text-lookup.c | 5 +- test/test-input/test-random.c | 4 +- test/test-input/test-random.h | 4 +- 42 files changed, 240 insertions(+), 157 deletions(-) diff --git a/.gitignore b/.gitignore index 173be7bc7..4e2aa6248 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ Debug/ x64/ ipch/ +.depend tags *.swp *.dat diff --git a/libobs-d3d11/d3d11-exports.h b/libobs-d3d11/d3d11-exports.h index 53e4ac277..73625a440 100644 --- a/libobs-d3d11/d3d11-exports.h +++ b/libobs-d3d11/d3d11-exports.h @@ -170,7 +170,7 @@ EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer); EXPORT void shader_destroy(shader_t shader); EXPORT int shader_numparams(shader_t shader); -EXPORT sparam_t shader_getparambyidx(shader_t shader, int param); +EXPORT sparam_t shader_getparambyidx(shader_t shader, uint32_t param); EXPORT sparam_t shader_getparambyname(shader_t shader, const char *name); EXPORT void shader_getparaminfo(shader_t shader, sparam_t param, struct shader_param_info *info); diff --git a/libobs-d3d11/d3d11-shader.cpp b/libobs-d3d11/d3d11-shader.cpp index 947f6c9f1..7a1fdc898 100644 --- a/libobs-d3d11/d3d11-shader.cpp +++ b/libobs-d3d11/d3d11-shader.cpp @@ -215,7 +215,7 @@ int shader_numparams(shader_t shader) return (int)shader->params.size(); } -sparam_t shader_getparambyidx(shader_t shader, int param) +sparam_t shader_getparambyidx(shader_t shader, uint32_t param) { return &shader->params[param]; } diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index b5f2e90a0..b18461721 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -232,7 +232,7 @@ ID3D11RasterizerState *gs_device::AddRasterState() ID3D11RasterizerState *state; memset(&rd, 0, sizeof(rd)); - /* use CCW to convert to for a right-handed coordinate system */ + /* use CCW to convert to a right-handed coordinate system */ rd.FrontCounterClockwise = true; rd.FillMode = D3D11_FILL_SOLID; rd.CullMode = ConvertGSCullMode(rasterState.cullMode); diff --git a/libobs-opengl/gl-exports.h b/libobs-opengl/gl-exports.h index a8a6440a1..5c4dae82a 100644 --- a/libobs-opengl/gl-exports.h +++ b/libobs-opengl/gl-exports.h @@ -164,7 +164,7 @@ EXPORT enum gs_index_type indexbuffer_gettype(indexbuffer_t indexbuffer); EXPORT void shader_destroy(shader_t shader); EXPORT int shader_numparams(shader_t shader); -EXPORT sparam_t shader_getparambyidx(shader_t shader, int param); +EXPORT sparam_t shader_getparambyidx(shader_t shader, uint32_t param); EXPORT sparam_t shader_getparambyname(shader_t shader, const char *name); EXPORT void shader_getparaminfo(shader_t shader, sparam_t param, struct shader_param_info *info); diff --git a/libobs-opengl/gl-shader.c b/libobs-opengl/gl-shader.c index 98680bfee..7f0a48509 100644 --- a/libobs-opengl/gl-shader.c +++ b/libobs-opengl/gl-shader.c @@ -67,6 +67,7 @@ static bool gl_add_param(struct gs_shader *shader, struct shader_var *var, param.array_count = var->array_count; param.name = bstrdup(var->name); + param.shader = shader; param.type = get_shader_param_type(var->type); if (param.type == SHADER_PARAM_TEXTURE) { @@ -310,7 +311,7 @@ int shader_numparams(shader_t shader) return (int)shader->params.num; } -sparam_t shader_getparambyidx(shader_t shader, int param) +sparam_t shader_getparambyidx(shader_t shader, uint32_t param) { assert(param < shader->params.num); return shader->params.array+param; @@ -329,9 +330,22 @@ sparam_t shader_getparambyname(shader_t shader, const char *name) return NULL; } +static inline bool matching_shader(shader_t shader, sparam_t sparam) +{ + if (shader != sparam->shader) { + blog(LOG_ERROR, "Shader and shader parameter do not match"); + return false; + } + + return true; +} + void shader_getparaminfo(shader_t shader, sparam_t param, struct shader_param_info *info) { + if (!matching_shader(shader, param)) + return; + info->type = param->type; info->name = param->name; } @@ -348,20 +362,26 @@ sparam_t shader_getworldmatrix(shader_t shader) void shader_setbool(shader_t shader, sparam_t param, bool val) { - glProgramUniform1i(shader->program, param->param, (GLint)val); - gl_success("glProgramUniform1i"); + if (matching_shader(shader, param)) { + glProgramUniform1i(shader->program, param->param, (GLint)val); + gl_success("glProgramUniform1i"); + } } void shader_setfloat(shader_t shader, sparam_t param, float val) { - glProgramUniform1f(shader->program, param->param, val); - gl_success("glProgramUniform1f"); + if (matching_shader(shader, param)) { + glProgramUniform1f(shader->program, param->param, val); + gl_success("glProgramUniform1f"); + } } void shader_setint(shader_t shader, sparam_t param, int val) { - glProgramUniform1i(shader->program, param->param, val); - gl_success("glProgramUniform1i"); + if (matching_shader(shader, param)) { + glProgramUniform1i(shader->program, param->param, val); + gl_success("glProgramUniform1i"); + } } void shader_setmatrix3(shader_t shader, sparam_t param, @@ -370,48 +390,62 @@ void shader_setmatrix3(shader_t shader, sparam_t param, struct matrix4 mat; matrix4_from_matrix3(&mat, val); - glProgramUniformMatrix4fv(shader->program, param->param, 1, false, - mat.x.ptr); - gl_success("glProgramUniformMatrix4fv"); + if (matching_shader(shader, param)) { + glProgramUniformMatrix4fv(shader->program, param->param, 1, + false, mat.x.ptr); + gl_success("glProgramUniformMatrix4fv"); + } } void shader_setmatrix4(shader_t shader, sparam_t param, const struct matrix4 *val) { - glProgramUniformMatrix4fv(shader->program, param->param, 1, false, - val->x.ptr); - gl_success("glProgramUniformMatrix4fv"); + if (matching_shader(shader, param)) { + glProgramUniformMatrix4fv(shader->program, param->param, 1, + false, val->x.ptr); + gl_success("glProgramUniformMatrix4fv"); + } } void shader_setvec2(shader_t shader, sparam_t param, const struct vec2 *val) { - glProgramUniform2fv(shader->program, param->param, 1, val->ptr); - gl_success("glProgramUniform2fv"); + if (matching_shader(shader, param)) { + glProgramUniform2fv(shader->program, param->param, 1, val->ptr); + gl_success("glProgramUniform2fv"); + } } void shader_setvec3(shader_t shader, sparam_t param, const struct vec3 *val) { - glProgramUniform3fv(shader->program, param->param, 1, val->ptr); - gl_success("glProgramUniform3fv"); + if (matching_shader(shader, param)) { + glProgramUniform3fv(shader->program, param->param, 1, val->ptr); + gl_success("glProgramUniform3fv"); + } } void shader_setvec4(shader_t shader, sparam_t param, const struct vec4 *val) { - glProgramUniform4fv(shader->program, param->param, 1, val->ptr); - gl_success("glProgramUniform4fv"); + if (matching_shader(shader, param)) { + glProgramUniform4fv(shader->program, param->param, 1, val->ptr); + gl_success("glProgramUniform4fv"); + } } void shader_settexture(shader_t shader, sparam_t param, texture_t val) { - param->texture = val; + if (matching_shader(shader, param)) + param->texture = val; } static void shader_setval_data(shader_t shader, sparam_t param, const void *val, int count) { + if (!matching_shader(shader, param)) + return; + if (param->type == SHADER_PARAM_BOOL || param->type == SHADER_PARAM_INT) { glProgramUniform1iv(shader->program, param->param, count, val); @@ -460,6 +494,9 @@ void shader_setval(shader_t shader, sparam_t param, const void *val, if (!count) count = 1; + if (!matching_shader(shader, param)) + return; + switch (param->type) { case SHADER_PARAM_FLOAT: expected_size = sizeof(float); break; case SHADER_PARAM_BOOL: diff --git a/libobs-opengl/gl-shaderparser.c b/libobs-opengl/gl-shaderparser.c index 7e05fdc8c..84712131d 100644 --- a/libobs-opengl/gl-shaderparser.c +++ b/libobs-opengl/gl-shaderparser.c @@ -145,7 +145,9 @@ static void gl_write_storage_var(struct gl_shader_parser *glsp, if (st) { gl_unwrap_storage_struct(glsp, st, var->name, input, prefix); } else { - struct gl_parser_attrib attrib = {{0}}; + struct gl_parser_attrib attrib; + gl_parser_attrib_init(&attrib); + dstr_cat(&glsp->gl_string, input ? "in " : "out "); if (prefix) @@ -286,14 +288,14 @@ static inline bool gl_write_texture_call(struct gl_shader_parser *glsp, struct shader_var *var, const char *call) { struct cf_parser *cfp = &glsp->parser.cfp; - size_t sampler_id = -1; + size_t sampler_id = (size_t)-1; if (!next_token(cfp)) return false; if (!token_is(cfp, "(")) return false; if (!next_token(cfp)) return false; sampler_id = sp_getsampler(glsp, cfp->cur_token); - if (sampler_id == -1) return false; + if (sampler_id == (size_t)-1) return false; if (!next_token(cfp)) return false; if (!token_is(cfp, ",")) return false; diff --git a/libobs-opengl/gl-shaderparser.h b/libobs-opengl/gl-shaderparser.h index dc40c8361..6945f6499 100644 --- a/libobs-opengl/gl-shaderparser.h +++ b/libobs-opengl/gl-shaderparser.h @@ -32,6 +32,11 @@ struct gl_parser_attrib { bool input; }; +static inline void gl_parser_attrib_init(struct gl_parser_attrib *attr) +{ + memset(attr, 0, sizeof(struct gl_parser_attrib)); +} + static inline void gl_parser_attrib_free(struct gl_parser_attrib *attr) { dstr_free(&attr->name); diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 2fec2e9f5..5d85e5564 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -265,7 +265,7 @@ static bool load_sampler_on_textures(device_t device, samplerstate_t ss, struct shader_param *param = shader->params.array+i; if (param->type == SHADER_PARAM_TEXTURE && - param->sampler_id == sampler_unit && + param->sampler_id == (uint32_t)sampler_unit && param->texture) { if (!gl_active_texture(GL_TEXTURE0 + param->texture_id)) return false; diff --git a/libobs-opengl/gl-subsystem.h b/libobs-opengl/gl-subsystem.h index 2aaab8128..8c3a69b61 100644 --- a/libobs-opengl/gl-subsystem.h +++ b/libobs-opengl/gl-subsystem.h @@ -279,6 +279,7 @@ struct shader_param { enum shader_param_type type; char *name; + shader_t shader; GLint param; GLint texture_id; size_t sampler_id; diff --git a/libobs-opengl/gl-zstencil.c b/libobs-opengl/gl-zstencil.c index abdfc2443..da450fd2b 100644 --- a/libobs-opengl/gl-zstencil.c +++ b/libobs-opengl/gl-zstencil.c @@ -55,6 +55,7 @@ zstencil_t device_create_zstencil(device_t device, uint32_t width, memset(zs, 0, sizeof(struct gs_zstencil_buffer)); zs->format = convert_zstencil_format(format); zs->attachment = get_attachment(format); + zs->device = device; if (!gl_init_zsbuffer(zs, width, height)) { blog(LOG_ERROR, "device_create_zstencil (GL) failed"); diff --git a/libobs/graphics/effect-parser.c b/libobs/graphics/effect-parser.c index 780f3f362..314e74004 100644 --- a/libobs/graphics/effect-parser.c +++ b/libobs/graphics/effect-parser.c @@ -676,7 +676,7 @@ static bool ep_parse_param_array(struct effect_parser *ep, ep->cfp.cur_token->str.len)) return false; - param->array_count = strtol(ep->cfp.cur_token->str.array, NULL, 10); + param->array_count =(int)strtol(ep->cfp.cur_token->str.array, NULL, 10); if (next_token_should_be(&ep->cfp, "]", ";", NULL) == PARSE_EOF) return false; @@ -1100,10 +1100,10 @@ static inline void ep_write_func_func_deps(struct effect_parser *ep, size_t i; for (i = 0; i < func->func_deps.num; i++) { const char *name = func->func_deps.array[i]; - struct ep_func *func = ep_getfunc(ep, name); + struct ep_func *func_dep = ep_getfunc(ep, name); - if (!func->written) { - ep_write_func(ep, shader, func, used_params); + if (!func_dep->written) { + ep_write_func(ep, shader, func_dep, used_params); dstr_cat(shader, "\n\n"); } } @@ -1274,6 +1274,7 @@ static void ep_compile_param(struct effect_parser *ep, size_t idx) param->name = bstrdup(param_in->name); param->section = EFFECT_PARAM; + param->effect = ep->effect; da_move(param->default_val, param_in->default_val); if (strcmp(param_in->type, "bool") == 0) @@ -1337,7 +1338,7 @@ static inline bool ep_compile_pass_shader(struct effect_parser *ep, struct dstr shader_str; struct dstr location; struct darray used_params; /* struct dstr */ - struct darray *pass_params; /* struct pass_shaderparam */ + struct darray *pass_params = NULL; /* struct pass_shaderparam */ shader_t shader = NULL; bool success = true; diff --git a/libobs/graphics/effect.c b/libobs/graphics/effect.c index b4b351c19..49ec03404 100644 --- a/libobs/graphics/effect.c +++ b/libobs/graphics/effect.c @@ -43,12 +43,12 @@ technique_t effect_gettechnique(effect_t effect, const char *name) return NULL; } -int technique_begin(technique_t tech) +size_t technique_begin(technique_t tech) { tech->effect->cur_technique = tech; tech->effect->graphics->cur_effect = tech->effect; - return (int)tech->passes.num; + return tech->passes.num; } void technique_end(technique_t tech) @@ -156,7 +156,7 @@ bool technique_beginpassbyname(technique_t tech, for (i = 0; i < tech->passes.num; i++) { struct effect_pass *pass = tech->passes.array+i; if (strcmp(pass->name, name) == 0) { - technique_beginpass(tech, (int)i); + technique_beginpass(tech, i); return true; } } @@ -190,9 +190,9 @@ void technique_endpass(technique_t tech) tech->effect->cur_pass = NULL; } -int effect_numparams(effect_t effect) +size_t effect_numparams(effect_t effect) { - return (int)effect->params.num; + return effect->params.num; } eparam_t effect_getparambyidx(effect_t effect, size_t param) @@ -220,9 +220,22 @@ eparam_t effect_getparambyname(effect_t effect, const char *name) return NULL; } +static inline bool matching_effect(effect_t effect, eparam_t param) +{ + if (effect != param->effect) { + blog(LOG_ERROR, "Effect and effect parameter do not match"); + return false; + } + + return true; +} + void effect_getparaminfo(effect_t effect, eparam_t param, struct effect_param_info *info) { + if (!matching_effect(effect, param)) + return; + info->name = param->name; info->type = param->type; } @@ -241,6 +254,10 @@ static inline void effect_setval_inline(effect_t effect, eparam_t param, const void *data, size_t size) { bool size_changed = param->cur_val.num != size; + + if (!matching_effect(effect, param)) + return; + if (size_changed) da_resize(param->cur_val, size); diff --git a/libobs/graphics/effect.h b/libobs/graphics/effect.h index 0b61065a8..0085ff13b 100644 --- a/libobs/graphics/effect.h +++ b/libobs/graphics/effect.h @@ -56,6 +56,8 @@ struct effect_param { DARRAY(uint8_t) cur_val; DARRAY(uint8_t) default_val; + effect_t effect; + /*char *full_name; float scroller_min, scroller_max, scroller_inc, scroller_mul;*/ }; diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 7b91688d7..ea1df7707 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -176,7 +176,7 @@ struct gs_exports { void (*shader_destroy)(shader_t shader); int (*shader_numparams)(shader_t shader); - sparam_t (*shader_getparambyidx)(shader_t shader, int param); + sparam_t (*shader_getparambyidx)(shader_t shader, uint32_t param); sparam_t (*shader_getparambyname)(shader_t shader, const char *name); void (*shader_getparaminfo)(shader_t shader, sparam_t param, struct shader_param_info *info); diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index c84eccfab..d0c97f217 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -472,8 +472,7 @@ void gs_normal3f(float x, float y, float z) static inline bool validvertsize(graphics_t graphics, size_t num, const char *name) { - if (graphics->using_immediate && - graphics->colors.num == IMMEDIATE_COUNT) { + if (graphics->using_immediate && num == IMMEDIATE_COUNT) { blog(LOG_WARNING, "%s: tried to use over %u " "for immediate rendering", name, IMMEDIATE_COUNT); @@ -690,7 +689,7 @@ void gs_resetviewport(void) { uint32_t cx, cy; gs_getsize(&cx, &cy); - gs_setviewport(0, 0, cx, cy); + gs_setviewport(0, 0, (int)cx, (int)cy); } void gs_set2dmode(void) @@ -1222,7 +1221,7 @@ int shader_numparams(shader_t shader) return graphics->exports.shader_numparams(shader); } -sparam_t shader_getparambyidx(shader_t shader, int param) +sparam_t shader_getparambyidx(shader_t shader, uint32_t param) { graphics_t graphics = thread_graphics; return graphics->exports.shader_getparambyidx(shader, param); diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 5f394ea5d..7edd5e415 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -293,7 +293,7 @@ enum shader_type { EXPORT void shader_destroy(shader_t shader); EXPORT int shader_numparams(shader_t shader); -EXPORT sparam_t shader_getparambyidx(shader_t shader, int param); +EXPORT sparam_t shader_getparambyidx(shader_t shader, uint32_t param); EXPORT sparam_t shader_getparambyname(shader_t shader, const char *name); EXPORT void shader_getparaminfo(shader_t shader, sparam_t param, struct shader_param_info *info); @@ -345,14 +345,14 @@ EXPORT void effect_destroy(effect_t effect); EXPORT technique_t effect_gettechnique(effect_t effect, const char *name); -EXPORT int technique_begin(technique_t technique); +EXPORT size_t technique_begin(technique_t technique); EXPORT void technique_end(technique_t technique); EXPORT bool technique_beginpass(technique_t technique, size_t pass); EXPORT bool technique_beginpassbyname(technique_t technique, const char *name); EXPORT void technique_endpass(technique_t technique); -EXPORT int effect_numparams(effect_t effect); +EXPORT size_t effect_numparams(effect_t effect); EXPORT eparam_t effect_getparambyidx(effect_t effect, size_t param); EXPORT eparam_t effect_getparambyname(effect_t effect, const char *name); EXPORT void effect_getparaminfo(effect_t effect, eparam_t param, @@ -389,7 +389,7 @@ EXPORT void effect_setdefault(effect_t effect, eparam_t param); EXPORT texrender_t texrender_create(enum gs_color_format format, enum gs_zstencil_format zsformat); EXPORT void texrender_destroy(texrender_t texrender); -EXPORT bool texrender_begin(texrender_t texrender, int cx, int cy); +EXPORT bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy); EXPORT void texrender_end(texrender_t texrender); EXPORT void texrender_reset(texrender_t texrender); EXPORT texture_t texrender_gettexture(texrender_t texrender); @@ -681,7 +681,8 @@ static inline uint32_t gs_get_format_bpp(enum gs_color_format format) case GS_DXT1: return 4; case GS_DXT3: return 8; case GS_DXT5: return 8; - default: return 0; + default: + case GS_UNKNOWN: return 0; } } diff --git a/libobs/graphics/math-extra.c b/libobs/graphics/math-extra.c index 02111b027..d024d5b8b 100644 --- a/libobs/graphics/math-extra.c +++ b/libobs/graphics/math-extra.c @@ -18,6 +18,7 @@ #include #include "vec2.h" #include "vec3.h" +#include "math-defs.h" #include "math-extra.h" void polar_to_cart(struct vec3 *dst, const struct vec3 *v) @@ -70,7 +71,7 @@ float calc_torquef(float val1, float val2, float torque, float min_adjust, float dist; bool over; - if (val1 == val2) + if (close_float(val1, val2, EPSILON)) return val1; dist = (val2-val1)*torque; diff --git a/libobs/graphics/quat.c b/libobs/graphics/quat.c index 08dfcdecb..f036a0e1e 100644 --- a/libobs/graphics/quat.c +++ b/libobs/graphics/quat.c @@ -55,10 +55,10 @@ void quat_from_axisang(struct quat *dst, const struct axisang *aa) } struct f4x4 { - float ptr[4][4]; + float ptr[4][4]; }; -void quat_from_matrix(struct quat *dst, const struct matrix3 *m) +void quat_from_matrix3(struct quat *dst, const struct matrix3 *m) { float tr = (m->x.x + m->y.y + m->z.z); float inv_half; diff --git a/libobs/graphics/shader-parser.c b/libobs/graphics/shader-parser.c index 0bef84d40..e0a747edb 100644 --- a/libobs/graphics/shader-parser.c +++ b/libobs/graphics/shader-parser.c @@ -110,7 +110,7 @@ void shader_sampler_convert(struct shader_sampler *ss, else if (astrcmpi(state, "AddressW") == 0) info->address_w = get_address_mode(value); else if (astrcmpi(state, "MaxAnisotropy") == 0) - info->max_anisotropy = strtol(value, NULL, 10); + info->max_anisotropy = (int)strtol(value, NULL, 10); /*else if (astrcmpi(state, "BorderColor") == 0) // TODO */ } @@ -319,7 +319,7 @@ static inline int sp_check_for_keyword(struct shader_parser *sp, } static inline int sp_parse_func_param(struct shader_parser *sp, - struct shader_func *func, struct shader_var *var) + struct shader_var *var) { int errcode; bool is_uniform = false; @@ -380,7 +380,7 @@ static bool sp_parse_func_params(struct shader_parser *sp, if (!token_is(&sp->cfp, "(") && !token_is(&sp->cfp, ",")) cf_adderror_syntax_error(&sp->cfp); - errcode = sp_parse_func_param(sp, func, &var); + errcode = sp_parse_func_param(sp, &var); if (errcode != PARSE_SUCCESS) { shader_var_free(&var); @@ -453,7 +453,7 @@ static bool sp_parse_param_array(struct shader_parser *sp, sp->cfp.cur_token->str.len)) return false; - param->array_count = strtol(sp->cfp.cur_token->str.array, NULL, 10); + param->array_count =(int)strtol(sp->cfp.cur_token->str.array, NULL, 10); if (next_token_should_be(&sp->cfp, "]", ";", NULL) == PARSE_EOF) return false; diff --git a/libobs/graphics/texture-render.c b/libobs/graphics/texture-render.c index 00783af4e..e39e86eeb 100644 --- a/libobs/graphics/texture-render.c +++ b/libobs/graphics/texture-render.c @@ -27,7 +27,7 @@ struct gs_texture_render { texture_t target, prev_target; zstencil_t zs, prev_zs; - int cx, cy; + uint32_t cx, cy; enum gs_color_format format; enum gs_zstencil_format zsformat; @@ -57,7 +57,8 @@ void texrender_destroy(texrender_t texrender) } } -static bool texrender_resetbuffer(texrender_t texrender, int cx, int cy) +static bool texrender_resetbuffer(texrender_t texrender, uint32_t cx, + uint32_t cy) { texture_destroy(texrender->target); zstencil_destroy(texrender->zs); @@ -85,14 +86,14 @@ static bool texrender_resetbuffer(texrender_t texrender, int cx, int cy) return true; } -bool texrender_begin(texrender_t texrender, int cx, int cy) +bool texrender_begin(texrender_t texrender, uint32_t cx, uint32_t cy) { if (texrender->rendered) return false; - if (cx == -1) + if (cx == 0) cx = gs_getwidth(); - if (cy == -1) + if (cy == 0) cy = gs_getheight(); assert(cx && cy); diff --git a/libobs/graphics/vec3.h b/libobs/graphics/vec3.h index 0233f6127..b5ec05527 100644 --- a/libobs/graphics/vec3.h +++ b/libobs/graphics/vec3.h @@ -128,9 +128,9 @@ static inline void vec3_cross(struct vec3 *dst, const struct vec3 *v1, static inline void vec3_neg(struct vec3 *dst, const struct vec3 *v) { - dst->x = -dst->x; - dst->y = -dst->y; - dst->z = -dst->z; + dst->x = -v->x; + dst->y = -v->y; + dst->z = -v->z; } static inline float vec3_len(const struct vec3 *v) diff --git a/libobs/graphics/vec4.h b/libobs/graphics/vec4.h index 857d3ceda..ce09d1ce7 100644 --- a/libobs/graphics/vec4.h +++ b/libobs/graphics/vec4.h @@ -111,10 +111,10 @@ static inline float vec4_dot(const struct vec4 *v1, const struct vec4 *v2) static inline void vec4_neg(struct vec4 *dst, const struct vec4 *v) { - dst->x = -dst->x; - dst->y = -dst->y; - dst->z = -dst->z; - dst->w = -dst->w; + dst->x = -v->x; + dst->y = -v->y; + dst->z = -v->z; + dst->w = -v->w; } static inline float vec4_len(const struct vec4 *v) diff --git a/libobs/obs-module.c b/libobs/obs-module.c index 20c2d2716..52375f5ab 100644 --- a/libobs/obs-module.c +++ b/libobs/obs-module.c @@ -41,7 +41,7 @@ void *load_module_subfunc(void *module, const char *module_name, return func_addr; } -static void module_load_exports(struct obs_data *obs, struct obs_module *mod, +static void module_load_exports(struct obs_module *mod, struct darray *output_array, const char *type, const size_t data_size, void *callback_ptr) { @@ -94,13 +94,13 @@ int obs_load_module(const char *path) } mod.name = bstrdup(path); - module_load_exports(obs, &mod, &obs->input_types.da, "inputs", + module_load_exports(&mod, &obs->input_types.da, "inputs", sizeof(struct source_info), get_source_info); - module_load_exports(obs, &mod, &obs->filter_types.da, "filters", + module_load_exports(&mod, &obs->filter_types.da, "filters", sizeof(struct source_info), get_source_info); - module_load_exports(obs, &mod, &obs->transition_types.da, "transitions", + module_load_exports(&mod, &obs->transition_types.da, "transitions", sizeof(struct source_info), get_source_info); - module_load_exports(obs, &mod, &obs->output_types.da, "outputs", + module_load_exports(&mod, &obs->output_types.da, "outputs", sizeof(struct output_info), get_output_info); da_push_back(obs->modules, &mod); diff --git a/libobs/obs-scene.c b/libobs/obs-scene.c index 454d922fd..4f490177f 100644 --- a/libobs/obs-scene.c +++ b/libobs/obs-scene.c @@ -64,9 +64,9 @@ static void scene_video_render(void *data) } } -static int scene_getsize(void *data) +static uint32_t scene_getsize(void *data) { - return -1; + return 0; } static bool scene_enum_children(void *data, size_t idx, obs_source_t *child) @@ -147,7 +147,7 @@ obs_sceneitem_t obs_scene_add(obs_scene_t scene, obs_source_t source) return item; } -void obs_sceneitem_remove(obs_sceneitem_t item) +void obs_sceneitem_destroy(obs_sceneitem_t item) { if (item) { da_erase_item(item->parent->items, item); diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 2b4d5e77d..4f6e67fd6 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -98,6 +98,7 @@ obs_source_t obs_source_create(enum obs_source_type type, const char *name, case SOURCE_INPUT: list = &obs->input_types.da; break; case SOURCE_FILTER: list = &obs->filter_types.da; break; case SOURCE_TRANSITION: list = &obs->transition_types.da; break; + case SOURCE_SCENE: default: return NULL; } @@ -180,14 +181,14 @@ void obs_source_video_render(obs_source_t source) } } -int obs_source_getwidth(obs_source_t source) +uint32_t obs_source_getwidth(obs_source_t source) { if (source->callbacks.getwidth) return source->callbacks.getwidth(source->data); return 0; } -int obs_source_getheight(obs_source_t source) +uint32_t obs_source_getheight(obs_source_t source) { if (source->callbacks.getheight) return source->callbacks.getheight(source->data); @@ -225,7 +226,7 @@ obs_source_t obs_filter_gettarget(obs_source_t filter) void obs_source_filter_add(obs_source_t source, obs_source_t filter) { - if (da_find(source->filters, &filter, 0) != -1) { + if (da_find(source->filters, &filter, 0) != DARRAY_INVALID) { blog(LOG_WARNING, "Tried to add a filter that was already " "present on the source"); return; @@ -243,7 +244,7 @@ void obs_source_filter_add(obs_source_t source, obs_source_t filter) void obs_source_filter_remove(obs_source_t source, obs_source_t filter) { size_t idx = da_find(source->filters, &filter, 0); - if (idx == -1) + if (idx == DARRAY_INVALID) return; if (idx > 0) { @@ -260,7 +261,7 @@ void obs_source_filter_setorder(obs_source_t source, obs_source_t filter, { size_t idx = da_find(source->filters, &filter, 0); size_t i; - if (idx == -1) + if (idx == DARRAY_INVALID) return; if (movement == ORDER_MOVE_UP) { diff --git a/libobs/obs-source.h b/libobs/obs-source.h index cd6b228b5..a96cf9534 100644 --- a/libobs/obs-source.h +++ b/libobs/obs-source.h @@ -76,12 +76,12 @@ * + SOURCE_ASYNC: video is sent asynchronously via RAM * * --------------------------------------------------------- - * int [name]_getwidth(void *data); + * uint32_t [name]_getwidth(void *data); * Returns the width of a source, or -1 for maximum width. If you render * video, this is required. * * --------------------------------------------------------- - * int [name]_getheight(void *data); + * uint32_t [name]_getheight(void *data); * Returns the height of a source, or -1 for maximum height. If you * render video, this is required. * @@ -170,8 +170,8 @@ struct source_info { void (*video_tick)(void *data, float seconds); void (*video_render)(void *data); - int (*getwidth)(void *data); - int (*getheight)(void *data); + uint32_t (*getwidth)(void *data); + uint32_t (*getheight)(void *data); size_t (*getparam)(void *data, const char *param, void *data_out, size_t buf_size); diff --git a/libobs/obs-video.c b/libobs/obs-video.c index dff25e8f9..38a1f0d44 100644 --- a/libobs/obs-video.c +++ b/libobs/obs-video.c @@ -42,17 +42,21 @@ static inline void render_displays(void) struct vec4 clear_color; vec4_set(&clear_color, 0.3f, 0.0f, 0.0f, 1.0f); - gs_ortho(0.0f, (float)obs->output_width, - 0.0f, (float)obs->output_height, - -100.0f, 100.0f); for (i = 0; i < obs->displays.num; i++) { + uint32_t cx, cy; obs_display_t display = obs->displays.array[i]; gs_load_swapchain(display->swap); + cx = gs_getwidth(); + cy = gs_getheight(); + + gs_beginscene(); - gs_setviewport(0, 0, gs_getwidth(), gs_getheight()); + gs_setviewport(0, 0, (int)cx, (int)cy); + gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -100.0f, 100.0f); + gs_setviewport(0, 0, obs->output_width, obs->output_height); if (display->source) obs_source_video_render(display->source); @@ -71,7 +75,10 @@ static inline void render_displays(void) gs_enable_blending(false); gs_setcullmode(GS_NEITHER); - gs_setviewport(0, 0, gs_getwidth(), gs_getheight()); + gs_ortho(0.0f, (float)obs->output_width, + 0.0f, (float)obs->output_height, + -100.0f, 100.0f); + gs_setviewport(0, 0, obs->output_width, obs->output_height); if (obs->primary_source) obs_source_video_render(obs->primary_source); @@ -113,7 +120,6 @@ static bool swap_frame(uint64_t timestamp) void *obs_video_thread(void *param) { - struct obs_data *obs = param; uint64_t last_time = 0; while (video_output_wait(obs->video)) { diff --git a/libobs/obs.h b/libobs/obs.h index ac53187a5..d4625459f 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -182,7 +182,7 @@ EXPORT void obs_source_destroy(obs_source_t source); * SOURCE_ASYNC if the video is asynchronous. * SOURCE_AUDIO if it presents/modifies audio (always async) */ -EXPORT uint32_t obs_source_get_obs_output_flags(obs_source_t source); +EXPORT uint32_t obs_source_get_output_flags(obs_source_t source); /** Specifies whether the source can be configured */ EXPORT bool obs_source_hasconfig(obs_source_t source); @@ -194,10 +194,10 @@ EXPORT void obs_source_config(obs_source_t source, void *parent); EXPORT void obs_source_video_render(obs_source_t source); /** Gets the width of a source (if it has video) */ -EXPORT int obs_source_getwidth(obs_source_t source); +EXPORT uint32_t obs_source_getwidth(obs_source_t source); /** Gets the height of a source (if it has video) */ -EXPORT int obs_source_getheight(obs_source_t source); +EXPORT uint32_t obs_source_getheight(obs_source_t source); /** * Gets a custom parameter from the source. diff --git a/libobs/util/bmem.c b/libobs/util/bmem.c index b27babdd2..2db39ffa7 100644 --- a/libobs/util/bmem.c +++ b/libobs/util/bmem.c @@ -33,13 +33,18 @@ */ #define ALIGNMENT 16 + +#if defined(_WIN32) && !defined(_WIN64) +#define ALIGNED_MALLOC 1 +#elif !defined(__LP64__) #define ALIGNMENT_HACK 1 +#endif static void *a_malloc(size_t size) { -#ifdef _WIN32 +#ifdef ALIGNED_MALLOC return _aligned_malloc(size, ALIGNMENT); -#else +#elif ALIGNMENT_HACK void *ptr = NULL; long diff; @@ -49,14 +54,16 @@ static void *a_malloc(size_t size) ((char *)ptr)[-1] = (char)diff; return ptr; +#else + return malloc(size); #endif } static void *a_realloc(void *ptr, size_t size) { -#ifdef _WIN32 +#ifdef ALIGNED_MALLOC return _aligned_realloc(ptr, size, ALIGNMENT); -#else +#elif ALIGNMENT_HACK long diff; if (!ptr) @@ -66,16 +73,20 @@ static void *a_realloc(void *ptr, size_t size) if (ptr) ptr = (char *)ptr + diff; return ptr; +#else + return realloc(ptr, size); #endif } static void a_free(void *ptr) { -#ifdef _WIN32 +#ifdef ALIGNED_MALLOC _aligned_free(ptr); -#else +#elif ALIGNMENT_HACK if (ptr) free((char *)ptr - ((char*)ptr)[-1]); +#else + free(ptr); #endif } diff --git a/libobs/util/cf-lexer.c b/libobs/util/cf-lexer.c index 815151b49..98ed53b0b 100644 --- a/libobs/util/cf-lexer.c +++ b/libobs/util/cf-lexer.c @@ -131,7 +131,7 @@ static bool cf_is_token_break(struct base_token *start_token, break; } - default: + case BASETOKEN_NONE: return true; } @@ -196,7 +196,8 @@ static bool cf_lexer_process_comment(struct cf_lexer *lex, } } - out_token->unmerged_str.len += offset - out_token->unmerged_str.array; + out_token->unmerged_str.len += + (size_t)(offset - out_token->unmerged_str.array); out_token->type = CFTOKEN_SPACETAB; lex->base_lexer.offset = offset; @@ -277,7 +278,8 @@ static void cf_lexer_getstrtoken(struct cf_lexer *lex, } *lex->write_offset = 0; - out_token->unmerged_str.len += offset - out_token->unmerged_str.array; + out_token->unmerged_str.len += + (size_t)(offset - out_token->unmerged_str.array); out_token->type = CFTOKEN_STRING; lex->base_lexer.offset = offset; } @@ -316,7 +318,8 @@ static inline enum cf_token_type cf_get_token_type(const struct cf_token *token, else return CFTOKEN_SPACETAB; - default: + case BASETOKEN_NONE: + case BASETOKEN_OTHER: break; } @@ -370,8 +373,8 @@ static bool cf_lexer_nexttoken(struct cf_lexer *lex, struct cf_token *out_token) } if (wrote_data) { - out_token->unmerged_str.len = lex->base_lexer.offset - - out_token->unmerged_str.array; + out_token->unmerged_str.len = (size_t)(lex->base_lexer.offset - + out_token->unmerged_str.array); out_token->type = cf_get_token_type(out_token, &start_token); } @@ -738,6 +741,8 @@ exit: return success; } +#define INVALID_INDEX ((size_t)-1) + static inline size_t cf_preprocess_get_def_idx(struct cf_preprocessor *pp, const struct strref *def_name) { @@ -751,14 +756,14 @@ static inline size_t cf_preprocess_get_def_idx(struct cf_preprocessor *pp, return i; } - return -1; + return INVALID_INDEX; } static inline struct cf_def *cf_preprocess_get_def(struct cf_preprocessor *pp, const struct strref *def_name) { size_t idx = cf_preprocess_get_def_idx(pp, def_name); - if (idx == -1) + if (idx == INVALID_INDEX) return NULL; return pp->defines.array+idx; @@ -844,7 +849,7 @@ static inline void cf_preprocess_remove_def_strref(struct cf_preprocessor *pp, const struct strref *ref) { size_t def_idx = cf_preprocess_get_def_idx(pp, ref); - if (def_idx != -1) { + if (def_idx != INVALID_INDEX) { struct cf_def *array = pp->defines.array; cf_def_free(array+def_idx); da_erase(pp->defines, def_idx); diff --git a/libobs/util/cf-parser.h b/libobs/util/cf-parser.h index 097f5e7c9..23e357ef6 100644 --- a/libobs/util/cf-parser.h +++ b/libobs/util/cf-parser.h @@ -163,7 +163,7 @@ static inline bool go_to_token_type(struct cf_parser *p, enum cf_token_type type) { while (p->cur_token->type != CFTOKEN_NONE && - p->cur_token->type != CFTOKEN_NEWLINE) + p->cur_token->type != type) p->cur_token++; return p->cur_token->type != CFTOKEN_NONE; diff --git a/libobs/util/config-file.c b/libobs/util/config-file.c index aadb97087..890879cb3 100644 --- a/libobs/util/config-file.c +++ b/libobs/util/config-file.c @@ -172,7 +172,8 @@ static void config_parse_section(struct config_section *section, } } -static int config_parse(struct darray *sections, const char *file) +static int config_parse(struct darray *sections, const char *file, + bool always_open) { char *file_data; struct lexer lex; @@ -181,6 +182,8 @@ static int config_parse(struct darray *sections, const char *file) FILE *f; f = os_fopen(file, "rb"); + if (always_open && !f) + f = os_fopen(file, "w+"); if (!f) return CONFIG_FILENOTFOUND; @@ -238,7 +241,7 @@ int config_open(config_t *config, const char *file, bool always_open) *config = bmalloc(sizeof(struct config_data)); memset(*config, 0, sizeof(struct config_data)); - errorcode = config_parse(&(*config)->sections, file); + errorcode = config_parse(&(*config)->sections, file, always_open); if (errorcode != CONFIG_SUCCESS) { config_close(*config); @@ -253,7 +256,7 @@ int config_open_defaults(config_t config, const char *file) if (!config) return CONFIG_ERROR; - return config_parse(&config->defaults, file); + return config_parse(&config->defaults, file, false); } int config_save(config_t config) diff --git a/libobs/util/darray.h b/libobs/util/darray.h index 2f7553f94..fa416880e 100644 --- a/libobs/util/darray.h +++ b/libobs/util/darray.h @@ -43,6 +43,8 @@ extern "C" { * See DARRAY macro at the bottom of thhe file for slightly safer usage. */ +#define DARRAY_INVALID ((size_t)-1) + struct darray { void *array; size_t num; @@ -186,7 +188,7 @@ static inline size_t darray_find(const size_t element_size, return i; } - return -1; + return DARRAY_INVALID; } static inline size_t darray_push_back(const size_t element_size, @@ -322,7 +324,7 @@ static inline void darray_erase_item(const size_t element_size, struct darray *dst, const void *item) { size_t idx = darray_find(element_size, dst, item, 0); - if (idx != (size_t)-1) + if (idx != DARRAY_INVALID) darray_erase(element_size, dst, idx); } diff --git a/libobs/util/dstr.c b/libobs/util/dstr.c index 4b66a0822..ef227b683 100644 --- a/libobs/util/dstr.c +++ b/libobs/util/dstr.c @@ -46,8 +46,8 @@ int astrcmpi(const char *str1, const char *str2) str2 = astrblank; do { - char ch1 = toupper(*str1); - char ch2 = toupper(*str2); + char ch1 = (char)toupper(*str1); + char ch2 = (char)toupper(*str2); if (ch1 < ch2) return -1; @@ -66,8 +66,8 @@ int wstrcmpi(const wchar_t *str1, const wchar_t *str2) str2 = wstrblank; do { - wchar_t ch1 = towupper(*str1); - wchar_t ch2 = towupper(*str2); + wchar_t ch1 = (wchar_t)towupper(*str1); + wchar_t ch2 = (wchar_t)towupper(*str2); if (ch1 < ch2) return -1; @@ -132,8 +132,8 @@ int astrcmpi_n(const char *str1, const char *str2, size_t n) str2 = astrblank; do { - char ch1 = toupper(*str1); - char ch2 = toupper(*str2); + char ch1 = (char)toupper(*str1); + char ch2 = (char)toupper(*str2); if (ch1 < ch2) return -1; @@ -154,8 +154,8 @@ int wstrcmpi_n(const wchar_t *str1, const wchar_t *str2, size_t n) str2 = wstrblank; do { - wchar_t ch1 = towupper(*str1); - wchar_t ch2 = towupper(*str2); + wchar_t ch1 = (wchar_t)towupper(*str1); + wchar_t ch2 = (wchar_t)towupper(*str2); if (ch1 < ch2) return -1; @@ -476,7 +476,7 @@ void dstr_replace(struct dstr *str, const char *find, temp = str->array; if (replace_len < find_len) { - int count = 0; + unsigned long count = 0; while ((temp = strstr(temp, find)) != NULL) { char *end = temp+find_len; @@ -498,7 +498,7 @@ void dstr_replace(struct dstr *str, const char *find, str->len += (replace_len-find_len) * count; } else if (replace_len > find_len) { - int count = 0; + unsigned long count = 0; while ((temp = strstr(temp, find)) != NULL) { temp += find_len; @@ -595,17 +595,3 @@ void dstr_from_wcs(struct dstr *dst, const wchar_t *wstr) dstr_free(dst); } } - -wchar_t *dstr_to_utf8(const struct dstr *str) -{ - wchar_t *out = NULL; - size_t len = utf8_to_wchar(str->array, str->len, NULL, 0, 0); - - if (len) { - out = bmalloc((len+1) * sizeof(wchar_t)); - utf8_to_wchar(str->array, str->len, out, len+1, 0); - out[len] = 0; - } - - return out; -} diff --git a/libobs/util/lexer.c b/libobs/util/lexer.c index 2bf26ee30..e094bcb9b 100644 --- a/libobs/util/lexer.c +++ b/libobs/util/lexer.c @@ -67,8 +67,8 @@ int strref_cmpi(const struct strref *str1, const char *str2) do { char ch1, ch2; - ch1 = (i < str1->len) ? toupper(str1->array[i]) : 0; - ch2 = toupper(*str2); + ch1 = (i < str1->len) ? (char)toupper(str1->array[i]) : 0; + ch2 = (char)toupper(*str2); if (ch1 < ch2) return -1; @@ -117,8 +117,8 @@ int strref_cmpi_strref(const struct strref *str1, const struct strref *str2) do { char ch1, ch2; - ch1 = (i < str1->len) ? toupper(str1->array[i]) : 0; - ch2 = (i < str2->len) ? toupper(str2->array[i]) : 0; + ch1 = (i < str1->len) ? (char)toupper(str1->array[i]) : 0; + ch2 = (i < str2->len) ? (char)toupper(str2->array[i]) : 0; if (ch1 < ch2) return -1; diff --git a/libobs/util/platform-windows.c b/libobs/util/platform-windows.c index 354b0626e..2c36eeffc 100644 --- a/libobs/util/platform-windows.c +++ b/libobs/util/platform-windows.c @@ -21,8 +21,6 @@ distribution. ******************************************************************************/ -#ifdef _WIN32 - #include #include "base.h" #include "platform.h" @@ -165,5 +163,3 @@ BOOL WINAPI DllMain(HINSTANCE hinst_dll, DWORD reason, LPVOID reserved) } #endif - -#endif diff --git a/libobs/util/platform.c b/libobs/util/platform.c index aac39e4d7..35c57a050 100644 --- a/libobs/util/platform.c +++ b/libobs/util/platform.c @@ -84,11 +84,11 @@ off_t os_fgetsize(FILE *file) size_t os_fread_mbs(FILE *file, char **pstr) { - off_t size = 0; + size_t size = 0; size_t len = 0; fseeko(file, 0, SEEK_END); - size = ftello(file); + size = (size_t)ftello(file); if (size > 0) { char *mbstr = bmalloc(size+1); @@ -107,11 +107,11 @@ size_t os_fread_mbs(FILE *file, char **pstr) size_t os_fread_utf8(FILE *file, char **pstr) { - off_t size = 0; + size_t size = 0; size_t len = 0; fseeko(file, 0, SEEK_END); - size = ftello(file); + size = (size_t)ftello(file); if (size > 0) { char bom[3]; @@ -244,7 +244,7 @@ size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char **pstr) size_t os_wcs_to_utf8(const wchar_t *str, size_t len, char **pstr) { - size_t in_len = wcslen(str); + size_t in_len = (len != 0) ? len : wcslen(str); size_t out_len = wchar_to_utf8(str, in_len, NULL, 0, 0); char *dst = NULL; diff --git a/libobs/util/platform.h b/libobs/util/platform.h index 5ee84cafe..c2aaf5aa0 100644 --- a/libobs/util/platform.h +++ b/libobs/util/platform.h @@ -48,6 +48,9 @@ EXPORT size_t os_fread_utf8(FILE *file, char **pstr); EXPORT char *os_quick_read_utf8_file(const char *path); EXPORT bool os_quick_write_utf8_file(const char *path, const char *str, size_t len, bool marker); +EXPORT char *os_quick_read_mbs_file(const char *path); +EXPORT bool os_quick_write_mbs_file(const char *path, const char *str, + size_t len); EXPORT size_t os_mbs_to_wcs(const char *str, size_t len, wchar_t **pstr); EXPORT size_t os_utf8_to_wcs(const char *str, size_t len, wchar_t **pstr); diff --git a/libobs/util/text-lookup.c b/libobs/util/text-lookup.c index 863269d37..69bcaf314 100644 --- a/libobs/util/text-lookup.c +++ b/libobs/util/text-lookup.c @@ -117,7 +117,7 @@ static void lookup_createsubnode(const char *lookup_val, new->leaf = leaf; dstr_copy(&new->str, lookup_val); - darray_push_back(sizeof(struct text_node*), &new->subnodes, &new); + darray_push_back(sizeof(struct text_node*), &node->subnodes, &new); } static void lookup_splitnode(const char *lookup_val, size_t len, @@ -197,7 +197,8 @@ static void lookup_getstringtoken(struct lexer *lex, struct strref *token) ++temp; } - token->len += temp - lex->offset - 1; /* include starting " char */ + /* include starting " char */ + token->len += (size_t)(temp - lex->offset - 1); lex->offset = temp; } diff --git a/test/test-input/test-random.c b/test/test-input/test-random.c index 7c3c7423f..ca0c9834e 100644 --- a/test/test-input/test-random.c +++ b/test/test-input/test-random.c @@ -74,12 +74,12 @@ void random_video_render(struct random_tex *rt, obs_source_t filter_target) technique_end(tech); } -int random_getwidth(struct random_tex *rt) +uint32_t random_getwidth(struct random_tex *rt) { return texture_getwidth(rt->texture); } -int random_getheight(struct random_tex *rt) +uint32_t random_getheight(struct random_tex *rt) { return texture_getheight(rt->texture); } diff --git a/test/test-input/test-random.h b/test/test-input/test-random.h index f7bb12dcb..d02afdb69 100644 --- a/test/test-input/test-random.h +++ b/test/test-input/test-random.h @@ -17,8 +17,8 @@ EXPORT uint32_t random_get_output_flags(struct random_tex *rt); EXPORT void random_video_render(struct random_tex *rt, obs_source_t filter_target); -EXPORT int random_getwidth(struct random_tex *rt); -EXPORT int random_getheight(struct random_tex *rt); +EXPORT uint32_t random_getwidth(struct random_tex *rt); +EXPORT uint32_t random_getheight(struct random_tex *rt); #ifdef __cplusplus }