'count' parameter for AddStereoSamples and AddStereoSamplesBE in WaveFile should be unsigned. Doesn't make sense to have them signed.
This commit is contained in:
parent
dfc0c4b08d
commit
dcc216a027
|
@ -100,39 +100,52 @@ void WaveFileWriter::Write4(const char *ptr)
|
||||||
file.WriteBytes(ptr, 4);
|
file.WriteBytes(ptr, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveFileWriter::AddStereoSamples(const short *sample_data, int count)
|
void WaveFileWriter::AddStereoSamples(const short *sample_data, u32 count)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
PanicAlertT("WaveFileWriter - file not open.");
|
PanicAlertT("WaveFileWriter - file not open.");
|
||||||
if (skip_silence) {
|
|
||||||
|
if (skip_silence)
|
||||||
|
{
|
||||||
bool all_zero = true;
|
bool all_zero = true;
|
||||||
for (int i = 0; i < count * 2; i++)
|
|
||||||
if (sample_data[i]) all_zero = false;
|
for (u32 i = 0; i < count * 2; i++)
|
||||||
if (all_zero) return;
|
{
|
||||||
|
if (sample_data[i])
|
||||||
|
all_zero = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (all_zero)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.WriteBytes(sample_data, count * 4);
|
file.WriteBytes(sample_data, count * 4);
|
||||||
audio_size += count * 4;
|
audio_size += count * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, int count)
|
void WaveFileWriter::AddStereoSamplesBE(const short *sample_data, u32 count)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
PanicAlertT("WaveFileWriter - file not open.");
|
PanicAlertT("WaveFileWriter - file not open.");
|
||||||
|
|
||||||
if (count > BUF_SIZE * 2)
|
if (count > BUF_SIZE * 2)
|
||||||
PanicAlert("WaveFileWriter - buffer too small (count = %i).", count);
|
PanicAlert("WaveFileWriter - buffer too small (count = %u).", count);
|
||||||
|
|
||||||
if (skip_silence)
|
if (skip_silence)
|
||||||
{
|
{
|
||||||
bool all_zero = true;
|
bool all_zero = true;
|
||||||
for (int i = 0; i < count * 2; i++)
|
|
||||||
|
for (u32 i = 0; i < count * 2; i++)
|
||||||
|
{
|
||||||
if (sample_data[i])
|
if (sample_data[i])
|
||||||
all_zero = false;
|
all_zero = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (all_zero)
|
if (all_zero)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count * 2; i++)
|
for (u32 i = 0; i < count * 2; i++)
|
||||||
conv_buffer[i] = Common::swap16((u16)sample_data[i]);
|
conv_buffer[i] = Common::swap16((u16)sample_data[i]);
|
||||||
|
|
||||||
file.WriteBytes(conv_buffer, count * 4);
|
file.WriteBytes(conv_buffer, count * 4);
|
||||||
|
|
|
@ -50,8 +50,8 @@ public:
|
||||||
|
|
||||||
void SetSkipSilence(bool skip) { skip_silence = skip; }
|
void SetSkipSilence(bool skip) { skip_silence = skip; }
|
||||||
|
|
||||||
void AddStereoSamples(const short *sample_data, int count);
|
void AddStereoSamples(const short *sample_data, u32 count);
|
||||||
void AddStereoSamplesBE(const short *sample_data, int count); // big endian
|
void AddStereoSamplesBE(const short *sample_data, u32 count); // big endian
|
||||||
u32 GetAudioSize() { return audio_size; }
|
u32 GetAudioSize() { return audio_size; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue