diff --git a/source/devicemounter/libwbfs/libwbfs_os.h b/source/devicemounter/libwbfs/libwbfs_os.h index ef527d1c..47d3cc98 100644 --- a/source/devicemounter/libwbfs/libwbfs_os.h +++ b/source/devicemounter/libwbfs/libwbfs_os.h @@ -14,11 +14,11 @@ #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_malloc(x) MEM2_alloc(x) -#define wbfs_free(x) MEM2_free(x) +#define wbfs_malloc(x) MEM1_alloc(x) +#define wbfs_free(x) MEM1_free(x) -#define wbfs_ioalloc(x) MEM2_alloc(((x) + 31) & ~31) -#define wbfs_iofree(x) MEM2_free(x) +#define wbfs_ioalloc(x) MEM1_memalign(32, x) +#define wbfs_iofree(x) MEM1_free(x) #define wbfs_be16(x) (*((u16*)(x))) #define wbfs_be32(x) (*((u32*)(x))) diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index f5ec588a..5ec4475c 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -1749,8 +1749,8 @@ void CMenu::_mainLoopCommon(bool withCF, bool blockReboot, bool adjusting) m_gameSound.Play(m_bnrSndVol); m_gamesound_changed = false; } - else if (!m_gameSelected) - m_gameSound.Stop(); + else if(!m_gameSelected) + m_gameSound.FreeMemory(); CheckThreads(); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 02382b68..8aa1c048 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -380,7 +380,7 @@ void CMenu::_game(bool launch) } if (BTN_HOME_PRESSED || BTN_B_PRESSED) { - m_gameSound.Stop(); + m_gameSound.FreeMemory(); CheckGameSoundThread(); break; } diff --git a/source/music/SoundHandler.cpp b/source/music/SoundHandler.cpp index 6342e2f6..cbdb55db 100644 --- a/source/music/SoundHandler.cpp +++ b/source/music/SoundHandler.cpp @@ -115,12 +115,23 @@ void SoundHandler::RemoveDecoder(int voice) if(voice < 0 || voice >= MAX_DECODERS) return; - if(DecoderList[voice] != NULL) - { + if(DecoderList[voice] != NULL) + { (*DecoderList[voice]).ClearBuffer(); - 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; - } + } } void SoundHandler::ClearDecoderList() diff --git a/source/music/gui_sound.h b/source/music/gui_sound.h index 67a0a2c4..652efacd 100644 --- a/source/music/gui_sound.h +++ b/source/music/gui_sound.h @@ -40,9 +40,10 @@ class GuiSound //!Constructor //!\param sound Pointer to the 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); - + //!Stops sound and frees all memory/closes files + void FreeMemory(); //!Destructor ~GuiSound(); //!Load a file and replace the old one @@ -84,13 +85,10 @@ class GuiSound //!Initializes the GuiSound object by setting the default values void Init(); //!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: - //!Stops sound and frees all memory/closes files - void FreeMemory(); - std::string filepath; - u8 * sound; //!< Pointer to the sound data + u8 *sound; //!< Pointer to the sound data u32 length; //!< Length of sound data s32 voice; //!< Currently assigned ASND voice channel int volume; //!< Sound volume (0-100)