Skip to content

Commit

Permalink
Report the libmysofa error value with the string
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Aug 6, 2024
1 parent f692577 commit 49b6bdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions utils/makemhr/loaddef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "alstring.h"
#include "makemhr.h"
#include "polyphase_resampler.h"
#include "sofa-support.h"

#include "mysofa.h"

Expand Down Expand Up @@ -1105,15 +1106,15 @@ auto LoadSofaFile(SourceRefT *src, const uint hrirRate, const uint n) -> MYSOFA_
sofa->hrtf = mysofa_load(src->mPath.data(), &err);
if(!sofa->hrtf)
{
fprintf(stderr, "\nError: Could not load source file '%s' (error: %d).\n",
src->mPath.data(), err);
fprintf(stderr, "\nError: Could not load source file '%s': %s (%d).\n",
src->mPath.data(), SofaErrorStr(err), err);
return nullptr;
}
/* NOTE: Some valid SOFA files are failing this check. */
err = mysofa_check(sofa->hrtf);
if(err != MYSOFA_OK)
fprintf(stderr, "\nWarning: Supposedly malformed source file '%s' (error: %d).\n",
src->mPath.data(), err);
fprintf(stderr, "\nWarning: Supposedly malformed source file '%s': %s (%d).\n",
src->mPath.data(), SofaErrorStr(err), err);
if((src->mOffset + n) > sofa->hrtf->N)
{
fprintf(stderr, "\nError: Not enough samples in SOFA file '%s'.\n", src->mPath.data());
Expand Down
8 changes: 4 additions & 4 deletions utils/makemhr/loadsofa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,16 @@ bool LoadSofaFile(const std::string_view filename, const uint numThreads, const
MySofaHrtfPtr sofaHrtf{mysofa_load(std::string{filename}.c_str(), &err)};
if(!sofaHrtf)
{
fprintf(stdout, "Error: Could not load %.*s: %s\n", al::sizei(filename), filename.data(),
SofaErrorStr(err));
fprintf(stdout, "Error: Could not load %.*s: %s (%d)\n", al::sizei(filename),
filename.data(), SofaErrorStr(err), err);
return false;
}

/* NOTE: Some valid SOFA files are failing this check. */
err = mysofa_check(sofaHrtf.get());
if(err != MYSOFA_OK)
fprintf(stderr, "Warning: Supposedly malformed source file '%.*s' (%s).\n",
al::sizei(filename), filename.data(), SofaErrorStr(err));
fprintf(stderr, "Warning: Supposedly malformed source file '%.*s': %s (%d)\n",
al::sizei(filename), filename.data(), SofaErrorStr(err), err);

mysofa_tocartesian(sofaHrtf.get());

Expand Down

0 comments on commit 49b6bdb

Please sign in to comment.