-more memory clearing up, may fixed a bug in wait messages

This commit is contained in:
fix94.1 2012-05-16 21:52:14 +00:00
parent 7714c6e6d8
commit 907c68f074
5 changed files with 79 additions and 59 deletions

View File

@ -11,6 +11,7 @@ extern const u8 wait_02_png[];
extern const u8 wait_03_png[];
extern const u8 wait_04_png[];
extern const u8 wait_05_png[];
vector<STexture> m_defaultWaitMessages;
const float CVideo::_jitter2[2][2] = {
{ 0.246490f, 0.249999f },
@ -224,20 +225,33 @@ void CVideo::prepare(void)
void CVideo::cleanup(void)
{
gprintf("Cleaning up video...\n");
for (u32 i = 0; i < sizeof m_aaBuffer / sizeof m_aaBuffer[0]; ++i)
{
if(m_aaBuffer[i].get())
m_aaBuffer[i].release();
}
GX_InvVtxCache();
GX_InvalidateTexAll();
VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[0], COLOR_BLACK);
VIDEO_ClearFrameBuffer(m_rmode, m_frameBuf[1], COLOR_BLACK);
VIDEO_Flush();
VIDEO_WaitVSync();
if(m_rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
GX_AbortFrame();
GX_Flush();
VIDEO_SetBlack(TRUE);
VIDEO_Flush();
VIDEO_WaitVSync();
if (m_rmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
for(u8 i = 0; i < sizeof m_aaBuffer / sizeof m_aaBuffer[0]; ++i)
{
if(m_aaBuffer[i].get())
m_aaBuffer[i].release();
}
for(u8 i = 0; i < m_defaultWaitMessages.size(); i++)
{
if(m_defaultWaitMessages[i].data.get())
m_defaultWaitMessages[i].data.release();
}
free(MEM_K1_TO_K0(m_frameBuf[0]));
free(MEM_K1_TO_K0(m_frameBuf[1]));
MEM1_free(m_stencil);
MEM1_free(m_fifo);
}
void CVideo::prepareAAPass(int aaStep)
@ -502,7 +516,6 @@ void CVideo::_showWaitMessages(CVideo *m)
}
if (m->m_useWiiLight)
wiiLightOff();
m->m_waitMessages.clear();
m->m_showingWaitMessages = false;
gprintf("Stop showing images\n");
}
@ -530,13 +543,22 @@ void CVideo::CheckWaitThread(bool force)
if(waitThreadStack.get())
waitThreadStack.release();
waitThread = LWP_THREAD_NULL;
m_waitMessages.clear();
}
}
void CVideo::waitMessage(float delay)
{
if(m_defaultWaitMessages.size() == 0)
{
STexture m_wTextures[5];
m_wTextures[0].fromPNG(wait_01_png);
m_wTextures[1].fromPNG(wait_02_png);
m_wTextures[2].fromPNG(wait_03_png);
m_wTextures[3].fromPNG(wait_04_png);
m_wTextures[4].fromPNG(wait_05_png);
for (int i = 0; i < 5; i++)
m_defaultWaitMessages.push_back(m_wTextures[i]);
}
waitMessage(vector<STexture>(), delay);
}
@ -548,14 +570,7 @@ void CVideo::waitMessage(const vector<STexture> &tex, float delay, bool useWiiLi
if (tex.size() == 0)
{
STexture m_wTextures[5];
m_wTextures[0].fromPNG(wait_01_png);
m_wTextures[1].fromPNG(wait_02_png);
m_wTextures[2].fromPNG(wait_03_png);
m_wTextures[3].fromPNG(wait_04_png);
m_wTextures[4].fromPNG(wait_05_png);
for (int i = 0; i < 5; i++)
m_waitMessages.push_back(m_wTextures[i]);
m_waitMessages = m_defaultWaitMessages;
m_waitMessageDelay = 0.3f;
}
else

View File

@ -163,7 +163,6 @@ void __Disc_SetVMode(void)
/* Set video mode register */
*(vu32 *)0x800000CC = vmode_reg;
DCFlushRange((void *)(0x800000CC), 4);
ICInvalidateRange((void *)(0x800000CC), 4);
/* Set video mode */
if (disc_vmode != 0)
@ -364,7 +363,6 @@ s32 Disc_BootPartition()
__Disc_SetVMode();
/* Shutdown IOS subsystems */
__dsp_shutdown();
u32 level = IRQ_Disable();
__IOS_ShutdownSubsystems();
__exception_closeall();

View File

@ -467,17 +467,21 @@ void CMenu::init(void)
void CMenu::cleanup(bool ios_reload)
{
m_cf.stopCoverLoader();
m_cf.clear();
m_plugin.Cleanup();
_stopSounds();
if (!ios_reload)
m_cameraSound.release();
m_plugin.Cleanup();
MusicPlayer::DestroyInstance();
SoundHandler::DestroyInstance();
soundDeinit();
__dsp_shutdown();
DeviceHandler::DestroyInstance();
if(!m_reload)
m_vid.cleanup();

View File

@ -1290,11 +1290,10 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
cleanup();
// wifi-gecko can no longer function after cleanup
Close_Inputs();
USBStorage_Deinit();
if(currentPartition == 0)
SDHC_Init();
usleep(100 * 1000);
/* Find game partition offset */
u64 offset;
s32 ret = Disc_FindPartition(&offset);
@ -1302,8 +1301,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
return;
RunApploader(offset, videoMode, vipatch, countryPatch, patchVidMode, aspectRatio);
DeviceHandler::DestroyInstance();
USBStorage_Deinit();
gprintf("Booting game\n");
Disc_BootPartition();
}

View File

@ -60,7 +60,10 @@ SoundHandler::~SoundHandler()
LWP_JoinThread(SoundThread, NULL);
SoundThread = LWP_THREAD_NULL;
if(ThreadStack != NULL)
{
MEM1_free(ThreadStack);
ThreadStack = NULL;
}
ClearDecoderList();
gprintf("SHND: Stopped sound thread\n");
@ -69,68 +72,71 @@ SoundHandler::~SoundHandler()
SoundHandler * SoundHandler::Instance()
{
if (instance == NULL)
{
instance = new SoundHandler();
}
return instance;
}
void SoundHandler::DestroyInstance()
{
if(instance)
{
delete instance;
}
instance = NULL;
if(instance)
{
delete instance;
instance = NULL;
}
}
void SoundHandler::AddDecoder(int voice, const char * filepath)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
DecoderList[voice] = GetSoundDecoder(filepath);
DecoderList[voice] = GetSoundDecoder(filepath);
}
void SoundHandler::AddDecoder(int voice, const u8 * snd, int len)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(voice < 0 || voice >= MAX_DECODERS)
return;
if (snd == NULL || len == 0)
return;
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
if(DecoderList[voice] != NULL)
RemoveDecoder(voice);
DecoderList[voice] = GetSoundDecoder(snd, len);
DecoderList[voice] = GetSoundDecoder(snd, len);
}
void SoundHandler::RemoveDecoder(int voice)
{
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(voice < 0 || voice >= MAX_DECODERS)
return;
if(DecoderList[voice] != NULL)
{
if(DecoderList[voice]->GetSoundType() == SOUND_OGG) delete ((OggDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_MP3) delete ((Mp3Decoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_WAV) delete ((WavDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_AIF) delete ((AifDecoder *) DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_BNS) delete ((BNSDecoder *) DecoderList[voice]);
else delete DecoderList[voice];
if(DecoderList[voice]->GetSoundType() == SOUND_OGG)
delete ((OggDecoder *)DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_MP3)
delete ((Mp3Decoder *)DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_WAV)
delete ((WavDecoder *)DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_AIF)
delete ((AifDecoder *)DecoderList[voice]);
else if(DecoderList[voice]->GetSoundType() == SOUND_BNS)
delete ((BNSDecoder *)DecoderList[voice]);
else
delete DecoderList[voice];
DecoderList[voice] = NULL;
}
DecoderList[voice] = NULL;
}
void SoundHandler::ClearDecoderList()
{
for(u32 i = 0; i < MAX_DECODERS; ++i)
RemoveDecoder(i);
for(u32 i = 0; i < MAX_DECODERS; ++i)
RemoveDecoder(i);
}
static inline bool CheckMP3Signature(const u8 * buffer)