Store file_callbacks in SFData structure

This commit is contained in:
Marcus Weseloh 2018-04-04 11:03:47 +02:00
parent 181b9727e8
commit 9c31e96c60
3 changed files with 10 additions and 6 deletions

View file

@ -650,12 +650,12 @@ int fluid_defsfont_load(fluid_defsfont_t* sfont, const fluid_file_callbacks_t* f
fluid_defsfont_add_preset(sfont, preset);
p = fluid_list_next(p);
}
fluid_sf2_close (sfdata, fcbs);
fluid_sf2_close (sfdata);
return FLUID_OK;
err_exit:
fluid_sf2_close (sfdata, fcbs);
fluid_sf2_close (sfdata);
delete_fluid_defpreset(preset);
return FLUID_FAILED;
}

View file

@ -304,6 +304,8 @@ SFData *fluid_sf2_load(const char *fname, const fluid_file_callbacks_t *fcbs)
}
FLUID_MEMSET(sf, 0, sizeof(SFData));
sf->fcbs = fcbs;
if ((sf->sffd = fcbs->fopen(fname)) == NULL)
{
FLUID_LOG(FLUID_ERR, _("Unable to open file \"%s\""), fname);
@ -343,7 +345,7 @@ SFData *fluid_sf2_load(const char *fname, const fluid_file_callbacks_t *fcbs)
return sf;
error_exit:
fluid_sf2_close(sf, fcbs);
fluid_sf2_close(sf);
return NULL;
}
@ -353,12 +355,12 @@ error_exit:
* @param sf pointer to SFData structure
* @param fcbs file callback structure
*/
void fluid_sf2_close(SFData *sf, const fluid_file_callbacks_t *fcbs)
void fluid_sf2_close(SFData *sf)
{
fluid_list_t *p, *p2;
if (sf->sffd)
fcbs->fclose(sf->sffd);
sf->fcbs->fclose(sf->sffd);
if (sf->fname)
FLUID_FREE(sf->fname);

View file

@ -143,6 +143,8 @@ struct _SFData
char *fname; /* file name */
FILE *sffd; /* loaded sfont file descriptor */
const fluid_file_callbacks_t *fcbs; /* file callbacks used to read this file */
fluid_list_t *info; /* linked list of info strings (1st byte is ID) */
fluid_list_t *preset; /* linked list of preset info */
fluid_list_t *inst; /* linked list of instrument info */
@ -203,6 +205,6 @@ struct _SFShdr
/* Public functions */
SFData *fluid_sf2_load(const char *fname, const fluid_file_callbacks_t *fcbs);
void fluid_sf2_close(SFData *sf, const fluid_file_callbacks_t *fcbs);
void fluid_sf2_close(SFData *sf);
#endif /* _FLUID_SF2_H */