-moved a few things to mem1, seems like we have enough space

left for that still ;)
-fixed that fatal memory bug, now memory usage looks correct :)
This commit is contained in:
fix94.1 2012-05-18 18:13:49 +00:00
parent 3fc680087f
commit f8a214fb3d
5 changed files with 27 additions and 18 deletions

View File

@ -14,11 +14,11 @@
#define wbfs_fatal(x) do { gprintf(x); wd_last_error = 1; } while(0) #define wbfs_fatal(x) do { gprintf(x); wd_last_error = 1; } while(0)
#define wbfs_error(x) do { gprintf(x); wd_last_error = 2; } while(0) #define wbfs_error(x) do { gprintf(x); wd_last_error = 2; } while(0)
#define wbfs_malloc(x) MEM2_alloc(x) #define wbfs_malloc(x) MEM1_alloc(x)
#define wbfs_free(x) MEM2_free(x) #define wbfs_free(x) MEM1_free(x)
#define wbfs_ioalloc(x) MEM2_alloc(((x) + 31) & ~31) #define wbfs_ioalloc(x) MEM1_memalign(32, x)
#define wbfs_iofree(x) MEM2_free(x) #define wbfs_iofree(x) MEM1_free(x)
#define wbfs_be16(x) (*((u16*)(x))) #define wbfs_be16(x) (*((u16*)(x)))
#define wbfs_be32(x) (*((u32*)(x))) #define wbfs_be32(x) (*((u32*)(x)))

View File

@ -1750,7 +1750,7 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting)
m_gamesound_changed = false; m_gamesound_changed = false;
} }
else if(!m_gameSelected) else if(!m_gameSelected)
m_gameSound.Stop(); m_gameSound.FreeMemory();
CheckThreads(); CheckThreads();

View File

@ -380,7 +380,7 @@ void CMenu::_game(bool launch)
} }
if (BTN_HOME_PRESSED || BTN_B_PRESSED) if (BTN_HOME_PRESSED || BTN_B_PRESSED)
{ {
m_gameSound.Stop(); m_gameSound.FreeMemory();
CheckGameSoundThread(); CheckGameSoundThread();
break; break;
} }

View File

@ -118,6 +118,17 @@ void SoundHandler::RemoveDecoder(int voice)
if(DecoderList[voice] != NULL) if(DecoderList[voice] != NULL)
{ {
(*DecoderList[voice]).ClearBuffer(); (*DecoderList[voice]).ClearBuffer();
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]; delete DecoderList[voice];
DecoderList[voice] = NULL; DecoderList[voice] = NULL;
} }

View File

@ -42,7 +42,8 @@ class GuiSound
//!\param filesize Length of sound data //!\param filesize Length of sound data
GuiSound(std::string filepath, int voice = -1); GuiSound(std::string filepath, int voice = -1);
GuiSound(const u8 * snd, u32 len, std::string name, bool allocated = false, int voice = -1); GuiSound(const u8 * snd, u32 len, std::string name, bool allocated = false, int voice = -1);
//!Stops sound and frees all memory/closes files
void FreeMemory();
//!Destructor //!Destructor
~GuiSound(); ~GuiSound();
//!Load a file and replace the old one //!Load a file and replace the old one
@ -86,9 +87,6 @@ class GuiSound
//!Special sound case for sound.bin //!Special sound case for sound.bin
void UncompressSoundbin(const u8 * snd, u32 len, bool isallocated); void UncompressSoundbin(const u8 * snd, u32 len, bool isallocated);
protected: protected:
//!Stops sound and frees all memory/closes files
void FreeMemory();
std::string filepath; std::string filepath;
u8 *sound; //!< Pointer to the sound data u8 *sound; //!< Pointer to the sound data
u32 length; //!< Length of sound data u32 length; //!< Length of sound data