improve audio::ope_PCM_stream error messages & feat: specifying stream path without extension

This commit is contained in:
MihailRis 2026-10-27 14:20:01 +03:00
parent 575bfb28e0
commit f19cb75534
2 changed files with 16 additions and 4 deletions

View file

@ -262,6 +262,18 @@ std::unique_ptr<Sound> audio::create_sound(
}
std::unique_ptr<PCMStream> audio::open_PCM_stream(const io::path& file) {
if (!io::exists(file)) {
io::path candidate = file.string() + ".wav";
if (io::exists(candidate)) {
return wav::create_stream(candidate);
}
candidate = file.string() + ".ogg";
if (io::exists(candidate)) {
return ogg::create_stream(candidate);
}
throw std::runtime_error("file not found '" + file.string() + "'");
}
std::string ext = file.extension();
if (ext == ".wav" || ext == ".WAV") {
return wav::create_stream(file);