Some error recovery

This commit is contained in:
mid 2025-10-05 23:24:12 +03:00
parent c91115dad4
commit e510d92b17
3 changed files with 15 additions and 10 deletions

View File

@ -563,6 +563,7 @@ static int muxmkv_start(CHiPubNode *pubn) {
this->fd = fopen(CHi_Crawl(&pubn->sinks[CUTIHI_MUXWEBM_IN_FILENAME])->data.text, "wb"); this->fd = fopen(CHi_Crawl(&pubn->sinks[CUTIHI_MUXWEBM_IN_FILENAME])->data.text, "wb");
if(!this->fd) { if(!this->fd) {
CHi_AddError(pubn, "invalid file", CUTIHI_MUXWEBM_IN_FILENAME);
return 0; return 0;
} }

View File

@ -534,9 +534,7 @@ static int image_perform(CHiPubNode *node) {
} }
if(node->sinks[CUTIHI_IMAGE_IN_FILE].type != CUTIHI_VAL_TEXT) { if(node->sinks[CUTIHI_IMAGE_IN_FILE].type != CUTIHI_VAL_TEXT) {
node->errors.active[0] = true; CHi_AddError(node, "invalid type", 0);
strncpy(node->errors.code[0], "invalid type", CUTIHI_ERR_SIZE);
node->errors.sink[0] = CUTIHI_IMAGE_IN_FILE;
return 1; return 1;
} }
@ -549,9 +547,7 @@ static int image_perform(CHiPubNode *node) {
if(!internal->cacheImg) { if(!internal->cacheImg) {
struct sail_image *simg; struct sail_image *simg;
if(sail_load_from_file(fn, &simg) != SAIL_OK) { if(sail_load_from_file(fn, &simg) != SAIL_OK) {
node->errors.active[0] = true; CHi_AddError(node, "invalid file", 0);
strncpy(node->errors.code[0], "invalid file", CUTIHI_ERR_SIZE);
node->errors.sink[0] = CUTIHI_IMAGE_IN_FILE;
return 1; return 1;
} }
@ -574,6 +570,9 @@ static int image_perform(CHiPubNode *node) {
} }
sail_destroy_image(cimg); sail_destroy_image(cimg);
free(internal->cachePath);
internal->cachePath = strdup(fn);
} }
if(CHi_Node_Active(node)) { if(CHi_Node_Active(node)) {
@ -717,9 +716,7 @@ static int modulate_perform(CHiPubNode *node) {
} }
if(imgsrc->type != CUTIHI_VAL_SAMPLE) { if(imgsrc->type != CUTIHI_VAL_SAMPLE) {
node->errors.active[0] = true; CHi_AddError(node, "invalid type", 0);
strncpy(node->errors.code[0], "invalid type", CUTIHI_ERR_SIZE);
node->errors.sink[0] = 0;
return 1; return 1;
} }
@ -728,11 +725,15 @@ static int modulate_perform(CHiPubNode *node) {
if(!CHi_Node_Active(node)) { if(!CHi_Node_Active(node)) {
node->sources->data.sample = NULL; node->sources->data.sample = NULL;
return; return 1;
} }
CHiImage *src = imgsrc->data.sample; CHiImage *src = imgsrc->data.sample;
if(!src) {
return 1;
}
assert(src->stride % 16 == 0); assert(src->stride % 16 == 0);
CHiImage *dst = CHi_Image_New(2, 4, src->stride, src->width, src->height, NULL); CHiImage *dst = CHi_Image_New(2, 4, src->stride, src->width, src->height, NULL);

View File

@ -290,6 +290,9 @@ CUTIVIS CHiValue *CHi_Crawl(CHiValue*);
CUTIVIS bool CHi_Node_Active(CHiPubNode*); CUTIVIS bool CHi_Node_Active(CHiPubNode*);
CUTIVIS void CHi_Node_Destroy(CHiPubNode*); CUTIVIS void CHi_Node_Destroy(CHiPubNode*);
CUTIVIS void CHi_AddError(CHiPubNode*, const char *err, size_t sink);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif