mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-05-30 08:50:39 +00:00
check for "sfbk" in fluid_is_soundfont()
This commit is contained in:
parent
9456bfab12
commit
292b7e028f
1 changed files with 15 additions and 8 deletions
|
@ -323,25 +323,32 @@ fluid_is_midifile(const char *filename)
|
|||
* @param filename Path to the file to check
|
||||
* @return TRUE if it could be a SoundFont, FALSE otherwise
|
||||
*
|
||||
* The current implementation only checks for the "RIFF" header in the file.
|
||||
* It is useful only to distinguish between SoundFont and MIDI files.
|
||||
* @note The current implementation only checks for the "RIFF" and "sfbk" headers in
|
||||
* the file. It is useful to distinguish between SoundFont and other (e.g. MIDI) files.
|
||||
*/
|
||||
int
|
||||
fluid_is_soundfont(const char *filename)
|
||||
{
|
||||
FILE* fp = fopen(filename, "rb");
|
||||
char id[4];
|
||||
char riff_id[4], sfbk_id[4];
|
||||
|
||||
if (fp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (fread((void*) id, 1, 4, fp) != 4) {
|
||||
if((fread((void*) riff_id, 1, sizeof(riff_id), fp) != sizeof(riff_id)) ||
|
||||
(fseek(fp, 4, SEEK_CUR) != 0) ||
|
||||
(fread((void*) sfbk_id, 1, sizeof(sfbk_id), fp) != sizeof(sfbk_id)))
|
||||
{
|
||||
goto error_rec;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
return (FLUID_STRNCMP(riff_id, "RIFF", sizeof(riff_id)) == 0) &&
|
||||
(FLUID_STRNCMP(sfbk_id, "sfbk", sizeof(sfbk_id)) == 0);
|
||||
|
||||
error_rec:
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return FLUID_STRNCMP(id, "RIFF", 4) == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue