tweak hack for specialized loadtype models, and fix for loading sounds from floating point files

This commit is contained in:
milek7
2018-01-31 20:13:07 +01:00
parent a63e1fad63
commit 6cd35031ca
2 changed files with 6 additions and 2 deletions

View File

@@ -30,9 +30,12 @@ openal_buffer::openal_buffer( std::string const &Filename ) :
std::replace(file.begin(), file.end(), '\\', '/');
SNDFILE *sf = sf_open(file.c_str(), SFM_READ, &si);
if (sf == nullptr)
throw std::runtime_error("sound: sf_open failed");
sf_command(sf, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
int16_t *fbuf = new int16_t[si.frames * si.channels];
if (sf_readf_short(sf, fbuf, si.frames) != si.frames)
throw std::runtime_error("sound: incomplete file");