-fixed freeze when switching through game views

-fixed wrong banner sound played (issue 7)
This commit is contained in:
fix94.1 2012-02-17 21:40:38 +00:00
parent 05c007582d
commit 7905a0a9b0
3 changed files with 18 additions and 24 deletions

View File

@ -432,8 +432,6 @@ void CMenu::cleanup(bool ios_reload)
{
m_cf.stopCoverLoader();
CheckGameSoundThread(true);
_stopSounds();
if (!ios_reload)
@ -1512,7 +1510,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
Sys_Test();
}
if (withCF && m_gameSelected && m_gamesound_changed && (m_gameSoundHdr == NULL) && !m_gameSound.IsPlaying() && MusicPlayer::Instance()->GetVolume() == 0)
if (withCF && m_gameSelected && m_gamesound_changed && (!m_gameSoundHdr) && !m_gameSound.IsPlaying() && MusicPlayer::Instance()->GetVolume() == 0)
{
m_gameSound.Play(m_bnrSndVol);
m_gamesound_changed = false;

View File

@ -1,7 +1,7 @@
#ifndef __MENU_HPP
#define __MENU_HPP
//#define SHOWMEM 1
//#define SHOWMEMGECKO
#define SHOWMEMGECKO
#include <wiiuse/wpad.h>
#include <ogc/pad.h>
@ -932,14 +932,14 @@ private:
static int _GCgameInstaller(void *obj);
wstringEx _optBoolToString(int b);
void _stopSounds(void);
//
static u32 _downloadCheatFileAsync(void *obj);
//
void _playGameSound(void);
void CheckGameSoundThread(bool force = false);
void CheckThreads(bool force = false);
void CheckGameSoundThread(void);
void CheckThreads(void);
static void _gameSoundThread(CMenu *m);
//
static void _load_installed_cioses();
//
struct SOption { const char id[10]; const wchar_t text[16]; };

View File

@ -305,6 +305,7 @@ void CMenu::_game(bool launch)
if (!launch)
{
SetupInput();
CheckGameSoundThread();
_playGameSound();
_showGame();
m_gameSelected = true;
@ -320,6 +321,7 @@ void CMenu::_game(bool launch)
if (startGameSound == -5)
{
CheckGameSoundThread();
_playGameSound();
_showGame();
}
@ -393,7 +395,6 @@ void CMenu::_game(bool launch)
if (!m_locked)
{
_hideGame();
CheckGameSoundThread(true);
if (_wbfsOp(CMenu::WO_REMOVE_GAME))
{
m_gameSound.Stop();
@ -849,7 +850,6 @@ void CMenu::_launchChannel(dir_discHdr *hdr)
IOS_Close(ESHandle);
}
CheckGameSoundThread(true);
cleanup();
Close_Inputs();
USBStorage_Deinit();
@ -979,7 +979,6 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd)
u32 cheatSize = 0, gameconfigSize = 0;
bool iosLoaded = false;
CheckGameSoundThread(true);
if (videoMode == 0) videoMode = (u8)min((u32)m_cfg.getInt("GENERAL", "video_mode", 0), ARRAY_SIZE(CMenu::_videoModes) - 1);
if (language == 0) language = min((u32)m_cfg.getInt("GENERAL", "game_language", 0), ARRAY_SIZE(CMenu::_languages) - 1);
m_cfg.setString("GAMES", "current_item", id);
@ -1229,30 +1228,27 @@ void CMenu::_gameSoundThread(CMenu *m)
Banner *banner = m->m_current_view == COVERFLOW_USB ?
_extractBnr(m->m_gameSoundHdr) : m->m_current_view == COVERFLOW_CHANNEL ?
_extractChannelBnr(m->m_gameSoundHdr->hdr.chantitle) : NULL;
SAFE_DELETE(m->m_gameSoundHdr);
if (banner == NULL || !banner->IsValid())
{
gprintf("no valid banner found\n");
SAFE_DELETE(banner);
m->m_gameSoundHdr = NULL;
return;
}
_extractBannerTitle(banner, GetLanguage(m->m_loc.getString(m->m_curLanguage, "gametdb_code", "EN").c_str()));
const u8 *soundBin = banner->GetFile((char *) "sound.bin", &sndSize);
SAFE_DELETE(banner);
if (soundBin == NULL || (((IMD5Header *)soundBin)->fcc != 'IMD5' && ((IMD5Header *)soundBin)->fcc != 'RIFF'))
{
gprintf("Failed to load banner sound!\n\n");
SAFE_DELETE(banner);
m->m_gameSoundHdr = NULL;
return;
}
m->m_gameSound.Load(soundBin, sndSize, false);
SAFE_DELETE(banner);
m->m_gamesound_changed = true;
m->m_gameSoundHdr = NULL;
}
void CMenu::_playGameSound(void)
@ -1268,9 +1264,9 @@ void CMenu::_playGameSound(void)
LWP_CreateThread(&m_gameSoundThread, (void *(*)(void *))CMenu::_gameSoundThread, (void *)this, gameSoundThreadStack.get(), stack_size, 40);
}
void CMenu::CheckGameSoundThread(bool force)
void CMenu::CheckGameSoundThread()
{
if (force || (m_gameSoundHdr == NULL && m_gameSoundThread != LWP_THREAD_NULL))
if (m_gameSoundHdr == NULL && m_gameSoundThread != LWP_THREAD_NULL)
{
if(LWP_ThreadIsSuspended(m_gameSoundThread))
LWP_ResumeThread(m_gameSoundThread);
@ -1282,9 +1278,9 @@ void CMenu::CheckGameSoundThread(bool force)
}
}
void CMenu::CheckThreads(bool force)
void CMenu::CheckThreads()
{
CheckGameSoundThread(force);
//CheckGameSoundThread(force);
//m_vid.CheckWaitThread(force);
#ifdef SHOWMEMGECKO
mem1 = SYS_GetArena1Size();