diff --git a/out/boot.dol b/out/boot.dol index d933010e..ccd4ca4d 100644 Binary files a/out/boot.dol and b/out/boot.dol differ diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 1aa6fba5..43466caf 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1603,12 +1603,13 @@ void CMenu::_addUserLabels(s16 *ids, u32 start, u32 size, const char *domain) } } +bool musicPaused = false; void CMenu::_mainLoopCommon(bool withCF, bool adjusting) { - /*if(m_thrdWorking) + if(m_thrdWorking) { - if(!MusicPlayer.IsStopped()) - MusicPlayer.Stop(); + musicPaused = true; + MusicPlayer.Pause(); m_btnMgr.tick(); m_vid.prepare(); m_vid.setup2DProjection(false, true); @@ -1618,7 +1619,12 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting) m_btnMgr.draw(); m_vid.render(); return; - }*/ + } + if(musicPaused && !m_thrdWorking) + { + musicPaused = false; + MusicPlayer.Resume(); + } /* ticks - for moving and scaling covers and gui buttons and text */ if(withCF) @@ -2389,16 +2395,32 @@ bool CMenu::_loadPluginList() } } if(addHomebrew) + { + if(updateCache) + m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true); _loadHomebrewList(); + } if(addGamecube) + { + if(updateCache) + m_cfg.setBool(GC_DOMAIN, "update_cache", true); _loadGamecubeList(); + } if(addWii) + { + if(updateCache) + m_cfg.setBool(WII_DOMAIN, "update_cache", true); _loadWiiList(); + } if(addChannel) + { + if(updateCache) + m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true); _loadChannelList(); + } m_cfg.remove(PLUGIN_DOMAIN, "update_cache"); return true; diff --git a/source/menu/menu_cheat.cpp b/source/menu/menu_cheat.cpp index 82300355..45997a13 100644 --- a/source/menu/menu_cheat.cpp +++ b/source/menu/menu_cheat.cpp @@ -30,8 +30,12 @@ int CMenu::_downloadCheatFileAsync() { update_pThread(1);//its downloaded fsop_WriteFile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id), cheatfile.data, cheatfile.size); + if(cheatfile.data != NULL) + free(cheatfile.data); return 0; } + if(cheatfile.data != NULL) + free(cheatfile.data); return -3;// download failed } diff --git a/source/menu/menu_download.cpp b/source/menu/menu_download.cpp index a42f75ab..87d657ab 100644 --- a/source/menu/menu_download.cpp +++ b/source/menu/menu_download.cpp @@ -221,6 +221,8 @@ void CMenu::_showDownload(void) m_btnMgr.show(m_downloadLblUser[i]); } +int count, countFlat; +u32 n; void CMenu::_download(string gameId) { m_coverDLGameId = gameId; @@ -283,14 +285,23 @@ void CMenu::_download(string gameId) _start_pThread(); int ret = _coverDownloader(dlAll); _stop_pThread(); + if(countFlat == 0) + { + m_thrdMessage = wfmt(_fmt("dlmsg5", L"%i/%i files downloaded."), count, n); + m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage); + } + else + { + m_thrdMessage = wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat); + m_btnMgr.setText(m_wbfsLblDialog, m_thrdMessage); + } + if(ret == -1) m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg27", L"Not enough memory!")); else if(ret == -2) m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!")); else if(ret == -3) m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg30", L"No covers missing.")); - else - m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done.")); dl_finished = true; gameId.clear(); //maybe show back button @@ -869,7 +880,8 @@ void CMenu::_downloadProgress(void *obj, int size, int position) int CMenu::_coverDownloader(bool download_all) { - int count = 0, countFlat = 0; + count = 0; + countFlat = 0; GameTDB c_gameTDB; if(m_settingsDir.size() > 0) @@ -916,7 +928,7 @@ int CMenu::_coverDownloader(bool download_all) else coverIDList.push_back(m_coverDLGameId); - u32 n = coverIDList.size(); + n = coverIDList.size(); m_thrdTotal = n * 3;// 3 = download cover, save png, and make wfc if(m_thrdTotal == 0) @@ -1106,7 +1118,9 @@ int CMenu::_coverDownloader(bool download_all) m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str()); m_thrdMessageAdded = true; CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, true);//it may fail - + if(download.data != NULL) + free(download.data); + ++count; update_pThread(1); success = true; @@ -1248,6 +1262,8 @@ int CMenu::_coverDownloader(bool download_all) m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str()); m_thrdMessageAdded = true; CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, true);//it may fail + if(download.data != NULL) + free(download.data); update_pThread(1); ++count; @@ -1383,7 +1399,9 @@ int CMenu::_coverDownloader(bool download_all) m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str())); m_thrdMessageAdded = true; CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, false);//it may fail - + if(download.data != NULL) + free(download.data); + ++countFlat; update_pThread(1); success = true; @@ -1522,7 +1540,9 @@ int CMenu::_coverDownloader(bool download_all) m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str())); m_thrdMessageAdded = true; CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, false);//it may fail - + if(download.data != NULL) + free(download.data); + ++countFlat; update_pThread(1); success = true; @@ -1532,14 +1552,11 @@ int CMenu::_coverDownloader(bool download_all) break; } } + if(!success) + update_pThread(3); } } - if(countFlat == 0) - m_thrdMessage = wfmt(_fmt("dlmsg5", L"%i/%i files downloaded."), count, n); - else - m_thrdMessage = wfmt(_fmt("dlmsg9", L"%i/%i files downloaded. %i are front covers only."), count + countFlat, n, countFlat); - m_thrdMessageAdded = true; - + /* cover list done and downloading complete */ if(c_gameTDB.IsLoaded()) c_gameTDB.CloseFile(); coverIDList.clear(); @@ -1583,6 +1600,8 @@ int CMenu::_gametdbDownloaderAsync() m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip"); m_thrdMessageAdded = true; res = fsop_WriteFile(zippath, download.data, download.size); + if(download.data != NULL) + free(download.data); } if(res == false) { @@ -1654,8 +1673,12 @@ int CMenu::_downloadBannerAsync() if(banner_location != NULL) fsop_WriteFile(banner_location, download.data, download.size); update_pThread(1);// its saved + if(download.data != NULL) + free(download.data); return 0; } + if(download.data != NULL) + free(download.data); return -3;// download failed } diff --git a/source/music/BufferCircle.cpp b/source/music/BufferCircle.cpp index 530d795f..36fb8a6b 100644 --- a/source/music/BufferCircle.cpp +++ b/source/music/BufferCircle.cpp @@ -62,6 +62,7 @@ void BufferCircle::SetBufferBlockSize(int size) void BufferCircle::Resize(int size) { + // this while() only gets done if new size is smaller than old size while(size < Size()) RemoveBuffer(Size()-1); @@ -71,6 +72,7 @@ void BufferCircle::Resize(int size) BufferSize.resize(size); BufferReady.resize(size); + // this for() only gets done if new size is bigger than old size for(int i = oldSize; i < Size(); i++) { if(BufferBlockSize > 0) diff --git a/source/music/MusicPlayer.cpp b/source/music/MusicPlayer.cpp index e95d94e3..79fbdd69 100644 --- a/source/music/MusicPlayer.cpp +++ b/source/music/MusicPlayer.cpp @@ -176,12 +176,24 @@ void Musicplayer::Stop() { if(!MusicFile.IsPlaying()) return; - MusicFile.Pause();// why not Stop() + MusicFile.Pause();// pause for now CurrentPosition = SoundHandle.Decoder(MusicFile.GetVoice())->Tell(); - MusicFile.FreeMemory(); + MusicFile.FreeMemory();// does MusicFile.Stop() then frees mem MusicStopped = true; } +void Musicplayer::Pause() +{ + if(!MusicFile.IsPlaying()) + return; + MusicFile.Pause(); +} + +void Musicplayer::Resume() +{ + MusicFile.Resume(); +} + void Musicplayer::Tick(bool attenuate)// attenuate means fade to zero volume { if(FileNames.empty()) diff --git a/source/music/MusicPlayer.hpp b/source/music/MusicPlayer.hpp index fead9de6..238097c7 100644 --- a/source/music/MusicPlayer.hpp +++ b/source/music/MusicPlayer.hpp @@ -41,6 +41,8 @@ public: void Previous(); void Next(); void Stop(); + void Pause(); + void Resume(); bool IsStopped() { return MusicStopped; }; diff --git a/source/music/gui_sound.cpp b/source/music/gui_sound.cpp index e523adbe..6fcfc0dd 100644 --- a/source/music/gui_sound.cpp +++ b/source/music/gui_sound.cpp @@ -48,7 +48,7 @@ static bool VoiceUsed[MAX_SND_VOICES] = static inline int GetFirstUnusedVoice() { - for(u8 i = 0; i < MAX_SND_VOICES; i++) + for(u8 i = 2; i < MAX_SND_VOICES; i++)// voice 0 is bg music, voice 1 is gamesound { if(VoiceUsed[i] == false) return i; diff --git a/source/music/gui_sound.h b/source/music/gui_sound.h index 5ea10f12..dd1299bd 100644 --- a/source/music/gui_sound.h +++ b/source/music/gui_sound.h @@ -38,9 +38,12 @@ public: //!Copy Constructor GuiSound(GuiSound *g); //!Constructor + //!\param file path + //!\param voice number - if blank defaults to first unused voice 2-15 + GuiSound(const char *path, int voice = -1); + //!Constructor //!\param sound Pointer to the sound data //!\param filesize Length of sound data - GuiSound(const char *path, int voice = -1); GuiSound(const u8 * snd, u32 len, const char *name, bool allocated = false, int voice = -1); //!Stops sound and frees all memory/closes files void FreeMemory();