fixed issue in waveinput where the format would be detected incorrectly

Floating point detection was backwards causing float-based audio to be
detected as integer and vice versa (for >32-bit formats)
This commit is contained in:
itsmattkc
2019-11-30 02:49:19 +11:00
parent e5e68c8947
commit c19cf8f8e6
2 changed files with 27 additions and 10 deletions
+21 -7
View File
@@ -96,16 +96,16 @@ bool WaveInput::open()
break;
case 32:
if (data_is_float) {
format = SAMPLE_FMT_S32;
} else {
format = SAMPLE_FMT_FLT;
} else {
format = SAMPLE_FMT_S32;
}
break;
case 64:
if (data_is_float) {
format = SAMPLE_FMT_S64;
} else {
format = SAMPLE_FMT_DBL;
} else {
format = SAMPLE_FMT_S64;
}
break;
default:
@@ -130,11 +130,20 @@ bool WaveInput::open()
return true;
}
bool WaveInput::is_open()
bool WaveInput::is_open() const
{
return file_.isOpen();
}
QByteArray WaveInput::read(int length)
{
if (!is_open()) {
return QByteArray();
}
return file_.read(length);
}
QByteArray WaveInput::read(int offset, int length)
{
if (!is_open()) {
@@ -155,7 +164,12 @@ void WaveInput::read(int offset, char *buffer, int length)
file_.read(buffer, length);
}
AudioRenderingParams WaveInput::params()
bool WaveInput::at_end() const
{
return file_.atEnd();
}
const AudioRenderingParams &WaveInput::params() const
{
return params_;
}
@@ -167,7 +181,7 @@ void WaveInput::close()
}
}
int WaveInput::sample_count()
int WaveInput::sample_count() const
{
return params_.bytes_to_samples(static_cast<int>(data_size_));
}