-set the wait message priority to the highest, that should remove

the problem of the lagging wait message (since the wait message
doesnt take much wii power wiiflows speed should be the same)
-set down wait message stack and also removed the reallocation of
the stack again and again on every display of it
-added security check that the wait message thread is finished 
before removing the thread (should prevent freezes)
-removed a few more unneeded lines of code
This commit is contained in:
fix94.1 2012-08-15 17:43:10 +00:00
parent 056c47124d
commit 6963b0c637
5 changed files with 20 additions and 39 deletions

View File

@ -44,9 +44,6 @@
#define RF_NEWS_CHANNEL 0x48414741
#define RF_FORECAST_CHANNEL 0x48414641
extern "C" void ShowError(const wstringEx &error);
#define error(x) //ShowError(x)
Channels::Channels()
{
}

View File

@ -1,5 +1,6 @@
#include <string.h>
#include <unistd.h>
#include "video.hpp"
#include "pngu.h"
@ -259,7 +260,7 @@ void CVideo::cleanup(void)
_clearScreen();
VIDEO_SetBlack(TRUE);
VIDEO_Flush();
hideWaitMessage();
GX_DrawDone();
GX_AbortFrame();
@ -267,13 +268,13 @@ void CVideo::cleanup(void)
{
if(m_aaBuffer[i].get())
m_aaBuffer[i].release();
m_aaBufferSize[i] = 0;
m_aaBufferSize[i] = 0;
}
for(u8 i = 0; i < m_defaultWaitMessages.size(); i++)
{
m_defaultWaitMessages[i].data.release();
}
if(waitThreadStack.get())
waitThreadStack.release();
free(MEM_K1_TO_K0(m_frameBuf[0]));
free(MEM_K1_TO_K0(m_frameBuf[1]));
free(m_stencil);
@ -498,15 +499,14 @@ void CVideo::_showWaitMessages(CVideo *m)
s16 currentLightLevel = 0;
vector<STexture>::iterator waitItr = m->m_waitMessages.begin();
gprintf("Going to show a wait message screen, delay: %d, # images: %d\n", waitFrames, m->m_waitMessages.size());
m->_clearScreen();
m->prepare();
m->setup2DProjection();
GX_SetNumChans(0);
wiiLightSetLevel(0);
wiiLightOn();
gprintf("Wait Message Thread: Start\nDelay: %d, Images: %d\n", waitFrames, m->m_waitMessages.size());
while(m->m_showWaitMessage)
{
currentLightLevel += (fadeStep * fadeDirection);
@ -530,38 +530,27 @@ void CVideo::_showWaitMessages(CVideo *m)
waitItr = m->m_waitMessages.begin();
waitFrames = frames;
}
VIDEO_WaitVSync();
else
VIDEO_WaitVSync();
waitFrames--;
}
wiiLightOff();
GX_SetNumChans(1);
gprintf("Wait Message Thread: End\n");
m->m_showingWaitMessages = false;
gprintf("Stop showing images\n");
}
void CVideo::hideWaitMessage()
{
m_showWaitMessage = false;
CheckWaitThread();
wiiLightOff();
}
void CVideo::CheckWaitThread(bool force)
{
if ((!m_showingWaitMessages && waitThread != LWP_THREAD_NULL) || force)
if(waitThread != LWP_THREAD_NULL)
{
m_showWaitMessage = false;
gprintf("Now hide wait message\n");
if(LWP_ThreadIsSuspended(waitThread))
LWP_ResumeThread(waitThread);
while(m_showingWaitMessages)
usleep(100);
LWP_JoinThread(waitThread, NULL);
if(waitThreadStack.get())
waitThreadStack.release();
waitThread = LWP_THREAD_NULL;
}
waitThread = LWP_THREAD_NULL;
}
void CVideo::waitMessage(float delay)
@ -602,9 +591,9 @@ void CVideo::waitMessage(const vector<STexture> &tex, float delay)
else if(m_waitMessages.size() > 1)
{
m_showWaitMessage = true;
u32 stack_size = (u32)32768;
waitThreadStack = smartMem2Alloc(stack_size);
LWP_CreateThread(&waitThread, (void *(*)(void *))CVideo::_showWaitMessages, (void *)this, waitThreadStack.get(), stack_size, LWP_PRIO_IDLE);
if(!waitThreadStack.get())
waitThreadStack = smartMem2Alloc(8092);
LWP_CreateThread(&waitThread, (void *(*)(void *))CVideo::_showWaitMessages, (void *)this, waitThreadStack.get(), 8092, LWP_PRIO_HIGHEST);
}
}

View File

@ -64,7 +64,7 @@ public:
bool wide(void) const { return m_wide; }
bool vid_50hz(void) const { return m_50hz; }
u8 getAA(void) const { return m_aa; }
bool showingWaitMessage() { return m_showingWaitMessages; }
bool showingWaitMessage() { return m_showingWaitMessages || m_showWaitMessage; }
void set2DViewport(u32 w, u32 h, int x, int y);
void prepareStencil(void);
void renderStencil(void);
@ -73,7 +73,6 @@ public:
void waitMessage(float delay);
void waitMessage(const vector<STexture> &tex, float delay);
void waitMessage(const STexture &tex);
void CheckWaitThread(bool force = false);
s32 TakeScreenshot(const char *);
void shiftViewPort(float x, float y);
private:

View File

@ -23,11 +23,8 @@ CMenu *mainMenu;
extern "C"
{
extern void __exception_setreload(int t);
extern int mainIOS;
void ShowError(const wstringEx &error) { mainMenu->error(error); }
void HideWaitMessage() { mainMenu->_hideWaitMessage(); }
extern void __exception_setreload(int t);
extern int mainIOS;
}
int main(int argc, char **argv)

View File

@ -510,7 +510,6 @@ void CMenu::cleanup(bool hb)
if(!hb)
DeviceHandler::DestroyInstance();
m_vid.CheckWaitThread(true);
m_vid.cleanup();
m_cf.shutdown();