mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
improve audio::ope_PCM_stream error messages & feat: specifying stream path without extension
This commit is contained in:
parent
575bfb28e0
commit
f19cb75534
2 changed files with 16 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue