- fixed issue #21 downloading covers, gametdb.zip, banners, and cheatfiles. now pausing bg music while downloading to prevent music thread from interfering with the internet network connection. also now clearing downloaded data from memory when done with it. code was missing to free the mem when done which caused out of memory issues of course. my fault i didn't see it till now.

- fixed issue #23 the progress bar and percentage when downloading covers.
- fixed issue #26 reload cache when using wii, gc, and channels plugins in plugin view.
This commit is contained in:
Fledge68 2018-11-19 12:14:40 -06:00
parent 46b4a4743c
commit 354bddc664
9 changed files with 89 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 MiB

After

Width:  |  Height:  |  Size: 3.4 MiB

View File

@ -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) void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
{ {
/*if(m_thrdWorking) if(m_thrdWorking)
{ {
if(!MusicPlayer.IsStopped()) musicPaused = true;
MusicPlayer.Stop(); MusicPlayer.Pause();
m_btnMgr.tick(); m_btnMgr.tick();
m_vid.prepare(); m_vid.prepare();
m_vid.setup2DProjection(false, true); m_vid.setup2DProjection(false, true);
@ -1618,7 +1619,12 @@ void CMenu::_mainLoopCommon(bool withCF, bool adjusting)
m_btnMgr.draw(); m_btnMgr.draw();
m_vid.render(); m_vid.render();
return; return;
}*/ }
if(musicPaused && !m_thrdWorking)
{
musicPaused = false;
MusicPlayer.Resume();
}
/* ticks - for moving and scaling covers and gui buttons and text */ /* ticks - for moving and scaling covers and gui buttons and text */
if(withCF) if(withCF)
@ -2389,16 +2395,32 @@ bool CMenu::_loadPluginList()
} }
} }
if(addHomebrew) if(addHomebrew)
{
if(updateCache)
m_cfg.setBool(HOMEBREW_DOMAIN, "update_cache", true);
_loadHomebrewList(); _loadHomebrewList();
}
if(addGamecube) if(addGamecube)
{
if(updateCache)
m_cfg.setBool(GC_DOMAIN, "update_cache", true);
_loadGamecubeList(); _loadGamecubeList();
}
if(addWii) if(addWii)
{
if(updateCache)
m_cfg.setBool(WII_DOMAIN, "update_cache", true);
_loadWiiList(); _loadWiiList();
}
if(addChannel) if(addChannel)
{
if(updateCache)
m_cfg.setBool(CHANNEL_DOMAIN, "update_cache", true);
_loadChannelList(); _loadChannelList();
}
m_cfg.remove(PLUGIN_DOMAIN, "update_cache"); m_cfg.remove(PLUGIN_DOMAIN, "update_cache");
return true; return true;

View File

@ -30,8 +30,12 @@ int CMenu::_downloadCheatFileAsync()
{ {
update_pThread(1);//its downloaded update_pThread(1);//its downloaded
fsop_WriteFile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id), cheatfile.data, cheatfile.size); fsop_WriteFile(fmt("%s/%s.txt", m_txtCheatDir.c_str(), id), cheatfile.data, cheatfile.size);
if(cheatfile.data != NULL)
free(cheatfile.data);
return 0; return 0;
} }
if(cheatfile.data != NULL)
free(cheatfile.data);
return -3;// download failed return -3;// download failed
} }

View File

@ -221,6 +221,8 @@ void CMenu::_showDownload(void)
m_btnMgr.show(m_downloadLblUser[i]); m_btnMgr.show(m_downloadLblUser[i]);
} }
int count, countFlat;
u32 n;
void CMenu::_download(string gameId) void CMenu::_download(string gameId)
{ {
m_coverDLGameId = gameId; m_coverDLGameId = gameId;
@ -283,14 +285,23 @@ void CMenu::_download(string gameId)
_start_pThread(); _start_pThread();
int ret = _coverDownloader(dlAll); int ret = _coverDownloader(dlAll);
_stop_pThread(); _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) if(ret == -1)
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg27", L"Not enough memory!")); m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg27", L"Not enough memory!"));
else if(ret == -2) else if(ret == -2)
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!")); m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg2", L"Network initialization failed!"));
else if(ret == -3) else if(ret == -3)
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg30", L"No covers missing.")); m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg30", L"No covers missing."));
else
m_btnMgr.setText(m_wbfsLblDialog, _t("dlmsg14", L"Done."));
dl_finished = true; dl_finished = true;
gameId.clear(); gameId.clear();
//maybe show back button //maybe show back button
@ -869,7 +880,8 @@ void CMenu::_downloadProgress(void *obj, int size, int position)
int CMenu::_coverDownloader(bool download_all) int CMenu::_coverDownloader(bool download_all)
{ {
int count = 0, countFlat = 0; count = 0;
countFlat = 0;
GameTDB c_gameTDB; GameTDB c_gameTDB;
if(m_settingsDir.size() > 0) if(m_settingsDir.size() > 0)
@ -916,7 +928,7 @@ int CMenu::_coverDownloader(bool download_all)
else else
coverIDList.push_back(m_coverDLGameId); coverIDList.push_back(m_coverDLGameId);
u32 n = coverIDList.size(); n = coverIDList.size();
m_thrdTotal = n * 3;// 3 = download cover, save png, and make wfc m_thrdTotal = n * 3;// 3 = download cover, save png, and make wfc
if(m_thrdTotal == 0) if(m_thrdTotal == 0)
@ -1106,6 +1118,8 @@ int CMenu::_coverDownloader(bool download_all)
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str()); m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str());
m_thrdMessageAdded = true; m_thrdMessageAdded = true;
CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, true);//it may fail 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; ++count;
update_pThread(1); update_pThread(1);
@ -1248,6 +1262,8 @@ int CMenu::_coverDownloader(bool download_all)
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str()); m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s.wfc"), coverID.c_str());
m_thrdMessageAdded = true; m_thrdMessageAdded = true;
CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, true);//it may fail 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); update_pThread(1);
++count; ++count;
@ -1383,6 +1399,8 @@ int CMenu::_coverDownloader(bool download_all)
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str())); m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
m_thrdMessageAdded = true; m_thrdMessageAdded = true;
CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, false);//it may fail 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; ++countFlat;
update_pThread(1); update_pThread(1);
@ -1522,6 +1540,8 @@ int CMenu::_coverDownloader(bool download_all)
m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str())); m_thrdMessage = wfmt(_fmt("dlmsg10", L"Making %s"), sfmt("%s.wfc", coverID.c_str()));
m_thrdMessageAdded = true; m_thrdMessageAdded = true;
CoverFlow.cacheCoverBuffer(fmt("%s/%s.wfc", m_cacheDir.c_str(), coverID.c_str()), download.data, false);//it may fail 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; ++countFlat;
update_pThread(1); update_pThread(1);
@ -1532,14 +1552,11 @@ int CMenu::_coverDownloader(bool download_all)
break; break;
} }
} }
if(!success)
update_pThread(3);
} }
} }
if(countFlat == 0) /* cover list done and downloading complete */
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;
if(c_gameTDB.IsLoaded()) if(c_gameTDB.IsLoaded())
c_gameTDB.CloseFile(); c_gameTDB.CloseFile();
coverIDList.clear(); coverIDList.clear();
@ -1583,6 +1600,8 @@ int CMenu::_gametdbDownloaderAsync()
m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip"); m_thrdMessage = wfmt(_fmt("dlmsg4", L"Saving %s"), "wiitdb.zip");
m_thrdMessageAdded = true; m_thrdMessageAdded = true;
res = fsop_WriteFile(zippath, download.data, download.size); res = fsop_WriteFile(zippath, download.data, download.size);
if(download.data != NULL)
free(download.data);
} }
if(res == false) if(res == false)
{ {
@ -1654,8 +1673,12 @@ int CMenu::_downloadBannerAsync()
if(banner_location != NULL) if(banner_location != NULL)
fsop_WriteFile(banner_location, download.data, download.size); fsop_WriteFile(banner_location, download.data, download.size);
update_pThread(1);// its saved update_pThread(1);// its saved
if(download.data != NULL)
free(download.data);
return 0; return 0;
} }
if(download.data != NULL)
free(download.data);
return -3;// download failed return -3;// download failed
} }

View File

@ -62,6 +62,7 @@ void BufferCircle::SetBufferBlockSize(int size)
void BufferCircle::Resize(int size) void BufferCircle::Resize(int size)
{ {
// this while() only gets done if new size is smaller than old size
while(size < Size()) while(size < Size())
RemoveBuffer(Size()-1); RemoveBuffer(Size()-1);
@ -71,6 +72,7 @@ void BufferCircle::Resize(int size)
BufferSize.resize(size); BufferSize.resize(size);
BufferReady.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++) for(int i = oldSize; i < Size(); i++)
{ {
if(BufferBlockSize > 0) if(BufferBlockSize > 0)

View File

@ -176,12 +176,24 @@ void Musicplayer::Stop()
{ {
if(!MusicFile.IsPlaying()) if(!MusicFile.IsPlaying())
return; return;
MusicFile.Pause();// why not Stop() MusicFile.Pause();// pause for now
CurrentPosition = SoundHandle.Decoder(MusicFile.GetVoice())->Tell(); CurrentPosition = SoundHandle.Decoder(MusicFile.GetVoice())->Tell();
MusicFile.FreeMemory(); MusicFile.FreeMemory();// does MusicFile.Stop() then frees mem
MusicStopped = true; 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 void Musicplayer::Tick(bool attenuate)// attenuate means fade to zero volume
{ {
if(FileNames.empty()) if(FileNames.empty())

View File

@ -41,6 +41,8 @@ public:
void Previous(); void Previous();
void Next(); void Next();
void Stop(); void Stop();
void Pause();
void Resume();
bool IsStopped() { return MusicStopped; }; bool IsStopped() { return MusicStopped; };

View File

@ -48,7 +48,7 @@ static bool VoiceUsed[MAX_SND_VOICES] =
static inline int GetFirstUnusedVoice() 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) if(VoiceUsed[i] == false)
return i; return i;

View File

@ -38,9 +38,12 @@ public:
//!Copy Constructor //!Copy Constructor
GuiSound(GuiSound *g); GuiSound(GuiSound *g);
//!Constructor //!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 sound Pointer to the sound data
//!\param filesize Length of 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); GuiSound(const u8 * snd, u32 len, const char *name, bool allocated = false, int voice = -1);
//!Stops sound and frees all memory/closes files //!Stops sound and frees all memory/closes files
void FreeMemory(); void FreeMemory();