forked from mirror/openmw-tes3mp
Improved WAV error checking
This commit is contained in:
parent
8f154ac622
commit
200fab03ef
3 changed files with 6 additions and 9 deletions
|
@ -17,9 +17,8 @@ namespace Sound {
|
||||||
MP3: mpg123
|
MP3: mpg123
|
||||||
WAV: custom wav loader (PCM only)
|
WAV: custom wav loader (PCM only)
|
||||||
|
|
||||||
This could be an alternative to using eg. libsndfile or other 3rd
|
This could be an alternative to using eg. 3rd party decoder
|
||||||
party decoder libraries. (We implemented this for OpenMW because
|
libraries like libsndfile.
|
||||||
we were experiencing crashes when using libsndfile.)
|
|
||||||
*/
|
*/
|
||||||
class OpenAL_Various_Factory : public InputFilter
|
class OpenAL_Various_Factory : public InputFilter
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,11 +106,6 @@ Mpg123Source::Mpg123Source(const std::string &file)
|
||||||
|
|
||||||
// This is the only bit size we support.
|
// This is the only bit size we support.
|
||||||
bits = 16;
|
bits = 16;
|
||||||
|
|
||||||
// Ensure the output format does not change. (The tutorial on the
|
|
||||||
// mpg123 site did this, I assume it's kosher.)
|
|
||||||
mpg123_format_none(mhh);
|
|
||||||
mpg123_format(mhh,rate,channels,encoding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Mpg123Source::~Mpg123Source()
|
Mpg123Source::~Mpg123Source()
|
||||||
|
|
|
@ -30,7 +30,10 @@ size_t WavSource::read(void *data, size_t length)
|
||||||
{
|
{
|
||||||
if(length > left)
|
if(length > left)
|
||||||
length = left;
|
length = left;
|
||||||
input->read(data, length);
|
size_t read = input->read(data, length);
|
||||||
|
if(read < length)
|
||||||
|
// Something went wrong
|
||||||
|
fail("WAV read error");
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue