mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
RetroAchievements audio customization: Fix checks for WAV file format
This commit is contained in:
parent
dbbf8e2afc
commit
e5a0788952
@ -42,6 +42,11 @@ struct WavData {
|
||||
free(raw_data);
|
||||
raw_data = nullptr;
|
||||
}
|
||||
|
||||
bool IsSimpleWAV() const {
|
||||
bool isBad = raw_bytes_per_frame > sizeof(int16_t) * num_channels;
|
||||
return !isBad && num_channels > 0 && sample_rate >= 8000 && codec == 0;
|
||||
}
|
||||
};
|
||||
|
||||
void WavData::Read(RIFFReader &file_) {
|
||||
@ -389,7 +394,7 @@ Sample *Sample::Load(const std::string &path) {
|
||||
|
||||
delete[] data;
|
||||
|
||||
if (wave.num_channels > 2 || wave.raw_bytes_per_frame > sizeof(int16_t) * wave.num_channels) {
|
||||
if (!wave.IsSimpleWAV()) {
|
||||
ERROR_LOG(AUDIO, "Wave format not supported for mixer playback. Must be 8-bit or 16-bit raw mono or stereo. '%s'", path.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -39,17 +39,13 @@ AudioFileChooser::AudioFileChooser(std::string *value, const std::string &title,
|
||||
return UI::EVENT_DONE;
|
||||
});
|
||||
Add(new FileChooserChoice(value, title, BrowseFileType::SOUND_EFFECT, new LinearLayoutParams(1.0f)))->OnChange.Add([=](UI::EventParams &e) {
|
||||
// TODO: Check the file format here.
|
||||
// Need to forward the event out.
|
||||
std::string path = e.s;
|
||||
Sample *sample = Sample::Load(path);
|
||||
if (sample) {
|
||||
g_BackgroundAudio.SFX().UpdateSample(sound, sample);
|
||||
} else {
|
||||
if (!sample) {
|
||||
auto au = GetI18NCategory(I18NCat::AUDIO);
|
||||
g_OSD.Show(OSDType::MESSAGE_WARNING, au->T("Audio file format not supported. Must be 16-bit WAV."));
|
||||
}
|
||||
auto au = GetI18NCategory(I18NCat::AUDIO);
|
||||
g_OSD.Show(OSDType::MESSAGE_ERROR, au->T("Audio file format not supported. Must be WAV."));
|
||||
value->clear();
|
||||
}
|
||||
return UI::EVENT_DONE;
|
||||
|
Loading…
Reference in New Issue
Block a user