From d6433afe46915e5386529a2b05186595f2d50e03 Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 30 Aug 2024 12:52:45 -0500 Subject: [PATCH] Capture error when requested file does not exist. An error message indicating missing file is now thrown to the API user. --- README.md | 6 +++--- include/ReMixer/stream.h | 6 ++++-- main.cpp | 7 ++++--- src/linux/sound.cpp | 8 ++++++-- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a91f291..2fde32c 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,8 @@ You know the drill, send those pull requests. ## License -ReMixer is licensed under the MIT License. See the LICENSE file for more details. +ReMixer is expressly licensed to the Public Domain. See the LICENSE file for details. -## Contact +## Acknowledgements -For questions or support, please contact your-email@example.com. \ No newline at end of file +ReMixer is developed and maintained by the boys from Redacted Software. \ No newline at end of file diff --git a/include/ReMixer/stream.h b/include/ReMixer/stream.h index 33e4b10..f32e798 100644 --- a/include/ReMixer/stream.h +++ b/include/ReMixer/stream.h @@ -15,11 +15,13 @@ #include #include #include -#include "sound.h" -#include "SoundSubsystem.h" +#include +#include #include namespace ReMixer { + + class Stream { private: std::string name; diff --git a/main.cpp b/main.cpp index fd8153f..a025e33 100644 --- a/main.cpp +++ b/main.cpp @@ -4,9 +4,9 @@ /// (c) 2024 Redacted Software /// This work is explicitly dedicated to the public domain, for the hopeful betterment of the software industry. -/// @file StreamManager.h -/// @desc This class manages internal creation and storage of active Streams. -/// @edit 2024-08-06 +/// @file main.cpp +/// @desc This file is the program code for the ReMixer-Test program. +/// @edit 2024-08-30 #include #include @@ -37,6 +37,7 @@ test.Play(test_stream, test_sound); //test.Play(test_stream2, ogg_test_sound); + std::cout << "This text will print after the sound plays>" << std::endl; while(true) { //std::this_thread::sleep_for(25ms); diff --git a/src/linux/sound.cpp b/src/linux/sound.cpp index 753590f..baa7e85 100644 --- a/src/linux/sound.cpp +++ b/src/linux/sound.cpp @@ -24,9 +24,13 @@ ReMixer::Sound ReMixer::Sound::FromPCMBuffer(std::vector buffer, uint samp } void ReMixer::Sound::LoadPCMFile(const std::filesystem::path &file_name, uint sampleRate, StreamMode streamMode) { - - std::ifstream file(file_name, std::ios::binary | std::ios::ate); + + if (!file.is_open()) + { + throw std::runtime_error(std::format("No such file {} could be found", file_name.c_str())); + } + file.unsetf(std::ios::skipws); file.seekg(0, std::ios::end);