diff --git a/include/util/util.hpp b/include/util/util.hpp index 7ea0317..ea379e5 100755 --- a/include/util/util.hpp +++ b/include/util/util.hpp @@ -18,4 +18,5 @@ namespace inst::util { std::vector setClockSpeed(int deviceToClock, uint32_t clockSpeed); std::string getIPAddress(); int getUsbState(); + void playAudio(std::string audioPath); } \ No newline at end of file diff --git a/romfs/audio/awoo.wav b/romfs/audio/awoo.wav new file mode 100755 index 0000000..f1ac9e1 Binary files /dev/null and b/romfs/audio/awoo.wav differ diff --git a/romfs/audio/bark.wav b/romfs/audio/bark.wav new file mode 100755 index 0000000..17bb5af Binary files /dev/null and b/romfs/audio/bark.wav differ diff --git a/source/install/install_nsp.cpp b/source/install/install_nsp.cpp index a26fd46..1bee85d 100755 --- a/source/install/install_nsp.cpp +++ b/source/install/install_nsp.cpp @@ -28,6 +28,7 @@ SOFTWARE. #include #include #include +#include #include "nx/ncm.hpp" #include "install/nca.hpp" @@ -40,6 +41,7 @@ SOFTWARE. #include "util/title_util.hpp" #include "sdInstall.hpp" #include "ui/MainApplication.hpp" +#include "util/util.hpp" namespace inst::ui { extern MainApplication *mainApp; @@ -129,7 +131,9 @@ namespace tin::install::nsp if (!Crypto::rsa2048PssVerify(&header.magic, 0x200, header.fixed_key_sig, Crypto::NCAHeaderSignature)) { + std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav"); int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false); + audioThread.join(); if (rc != 1) THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str()); declinedValidation = true; diff --git a/source/install/install_nsp_remote.cpp b/source/install/install_nsp_remote.cpp index 25e73c6..662f6b5 100755 --- a/source/install/install_nsp_remote.cpp +++ b/source/install/install_nsp_remote.cpp @@ -23,6 +23,8 @@ SOFTWARE. #include "install/install_nsp_remote.hpp" #include +#include + #include "install/nca.hpp" #include "nx/fs.hpp" #include "nx/ncm.hpp" @@ -33,6 +35,7 @@ SOFTWARE. #include "util/debug.h" #include "util/error.hpp" #include "ui/MainApplication.hpp" +#include "util/util.hpp" namespace inst::ui { extern MainApplication *mainApp; @@ -107,7 +110,9 @@ namespace tin::install::nsp if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature)) { + std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav"); int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false); + audioThread.join(); if (rc != 1) THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str()); declinedValidation = true; diff --git a/source/install/install_xci.cpp b/source/install/install_xci.cpp index 306c4fa..8d065d9 100755 --- a/source/install/install_xci.cpp +++ b/source/install/install_xci.cpp @@ -20,6 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #include "install/install_xci.hpp" #include "util/file_util.hpp" #include "util/title_util.hpp" @@ -30,6 +32,7 @@ SOFTWARE. #include "install/nca.hpp" #include "sdInstall.hpp" #include "ui/MainApplication.hpp" +#include "util/util.hpp" namespace inst::ui { extern MainApplication *mainApp; @@ -108,7 +111,9 @@ namespace tin::install::xci if (!Crypto::rsa2048PssVerify(&header->magic, 0x200, header->fixed_key_sig, Crypto::NCAHeaderSignature)) { + std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav"); int rc = inst::ui::mainApp->CreateShowDialog("Invalid NCA signature detected!", "Improperly signed software should only be installed from trustworthy\nsources. Files containing cartridge repacks and DLC unlockers will always\nshow this warning. You can disable this check in Awoo Installer's settings.\n\nAre you sure you want to continue the installation?", {"Cancel", "Yes, I understand the risks"}, false); + audioThread.join(); if (rc != 1) THROW_FORMAT(("The requested NCA (" + tin::util::GetNcaIdString(ncaId) + ") is not properly signed").c_str()); declinedValidation = true; diff --git a/source/netInstall.cpp b/source/netInstall.cpp index 1e0c0c4..d2553c5 100755 --- a/source/netInstall.cpp +++ b/source/netInstall.cpp @@ -26,6 +26,7 @@ SOFTWARE. #include #include #include +#include #include #include "util/network_util.hpp" @@ -171,7 +172,9 @@ namespace netInstStuff{ fprintf(stdout, "%s", e.what()); inst::ui::setInstInfoText("Failed to install " + urlNames[urlItr]); inst::ui::setInstBarPerc(0); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav"); inst::ui::mainApp->CreateShowDialog("Failed to install " + urlNames[urlItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); + audioThread.join(); nspInstalled = false; } @@ -189,8 +192,10 @@ namespace netInstStuff{ if(nspInstalled) { inst::ui::setInstInfoText("Install complete"); inst::ui::setInstBarPerc(100); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav"); if (ourUrlList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourUrlList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true); else inst::ui::mainApp->CreateShowDialog(urlNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true); + audioThread.join(); } LOG_DEBUG("Done"); diff --git a/source/sdInstall.cpp b/source/sdInstall.cpp index 954c8ae..ef7c924 100755 --- a/source/sdInstall.cpp +++ b/source/sdInstall.cpp @@ -24,6 +24,7 @@ SOFTWARE. #include #include #include +#include #include "install/install_nsp.hpp" #include "install/install_xci.hpp" @@ -140,7 +141,9 @@ namespace nspInstStuff { fprintf(stdout, "%s", e.what()); inst::ui::setInstInfoText("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true)); inst::ui::setInstBarPerc(0); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav"); inst::ui::mainApp->CreateShowDialog("Failed to install " + inst::util::shortenString(ourTitleList[titleItr].filename().string(), 42, true) + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); + audioThread.join(); nspInstalled = false; } @@ -160,6 +163,7 @@ namespace nspInstStuff { if(nspInstalled) { inst::ui::setInstInfoText("Install complete"); inst::ui::setInstBarPerc(100); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav"); if (ourTitleList.size() > 1) { if (inst::config::deletePrompt) { if(inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully! Delete them from the SD card?", "The original files aren't needed anymore after they've been installed", {"No","Yes"}, false) == 1) { @@ -173,6 +177,7 @@ namespace nspInstStuff { if(inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 32, true) + " installed! Delete it from the SD card?", "The original file isn't needed anymore after it's been installed", {"No","Yes"}, false) == 1) if (std::filesystem::exists(ourTitleList[0])) std::filesystem::remove(ourTitleList[0]); } else inst::ui::mainApp->CreateShowDialog(inst::util::shortenString(ourTitleList[0].filename().string(), 42, true) + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true); } + audioThread.join(); } LOG_DEBUG("Done"); diff --git a/source/usbInstall.cpp b/source/usbInstall.cpp index d78a186..2e83644 100755 --- a/source/usbInstall.cpp +++ b/source/usbInstall.cpp @@ -1,4 +1,5 @@ #include +#include #include "util/error.hpp" #include "usbInstall.hpp" #include "install/usb_nsp.hpp" @@ -31,8 +32,6 @@ namespace usbInstStuff { } PACKED; std::vector OnSelected() { - Result rc = 0; - TUSHeader header; while(true) { if (tin::util::USBRead(&header, sizeof(TUSHeader)) != 0) break; @@ -111,7 +110,9 @@ namespace usbInstStuff { fprintf(stdout, "%s", e.what()); inst::ui::setInstInfoText("Failed to install " + fileNames[fileItr]); inst::ui::setInstBarPerc(0); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/bark.wav"); inst::ui::mainApp->CreateShowDialog("Failed to install " + fileNames[fileItr] + "!", "Partially installed contents can be removed from the System Settings applet.\n\n" + (std::string)e.what(), {"OK"}, true); + audioThread.join(); nspInstalled = false; } @@ -125,8 +126,10 @@ namespace usbInstStuff { tin::util::USBCmdManager::SendExitCmd(); inst::ui::setInstInfoText("Install complete"); inst::ui::setInstBarPerc(100); + std::thread audioThread(inst::util::playAudio,"romfs:/audio/awoo.wav"); if (ourTitleList.size() > 1) inst::ui::mainApp->CreateShowDialog(std::to_string(ourTitleList.size()) + " files installed successfully!", nspInstStuff::finishedMessage(), {"OK"}, true); else inst::ui::mainApp->CreateShowDialog(fileNames[0] + " installed!", nspInstStuff::finishedMessage(), {"OK"}, true); + audioThread.join(); } LOG_DEBUG("Done"); diff --git a/source/util/util.cpp b/source/util/util.cpp index fa6433f..97d8556 100755 --- a/source/util/util.cpp +++ b/source/util/util.cpp @@ -264,4 +264,35 @@ namespace inst::util { usbDsGetState(&usbState); return usbState; } + + void playAudio(std::string audioPath) { + int audio_rate = 22050; + Uint16 audio_format = AUDIO_S16SYS; + int audio_channels = 2; + int audio_buffers = 4096; + + if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) return; + + Mix_Chunk *sound = NULL; + sound = Mix_LoadWAV(audioPath.c_str()); + if(sound == NULL) { + Mix_FreeChunk(sound); + Mix_CloseAudio(); + return; + } + + int channel = Mix_PlayChannel(-1, sound, 0); + if(channel == -1) { + Mix_FreeChunk(sound); + Mix_CloseAudio(); + return; + } + + while(Mix_Playing(channel) != 0); + + Mix_FreeChunk(sound); + Mix_CloseAudio(); + + return; + } } \ No newline at end of file