add SFWrapper error logging

This commit is contained in:
tildearrow 2024-08-19 12:40:51 -05:00
parent d3af810462
commit ecbfacef1f

View file

@ -91,10 +91,12 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
f=ps_fopen(path,modeC);
if (f==NULL) {
logE("SFWrapper: failed to open (%s)",strerror(errno));
return NULL;
}
if (fseek(f,0,SEEK_END)==-1) {
logE("SFWrapper: failed to seek to end (%s)",strerror(errno));
fclose(f);
f=NULL;
return NULL;
@ -102,6 +104,7 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
len=ftell(f);
if (len==(SIZE_MAX>>1)) {
logE("SFWrapper: failed to tell (%s)",strerror(errno));
len=0;
fclose(f);
f=NULL;
@ -109,6 +112,7 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
}
if (fseek(f,0,SEEK_SET)==-1) {
logE("SFWrapper: failed to seek to beginning (%s)",strerror(errno));
len=0;
fclose(f);
f=NULL;
@ -117,5 +121,8 @@ SNDFILE* SFWrapper::doOpen(const char* path, int mode, SF_INFO* sfinfo) {
sf=sf_open_virtual(&vio,mode,sfinfo,this);
if (sf!=NULL) fileMode=mode;
if (sf==NULL) {
logE("SFWrapper: WHY IS IT NULL?!");
}
return sf;
}
}