-added music resume after ios reload/enabling nand emulator

This commit is contained in:
fix94.1 2012-09-15 21:20:22 +00:00
parent 9140b17315
commit f527735c54
7 changed files with 38 additions and 3 deletions

View File

@ -91,7 +91,7 @@ bool loadIOS(int ios, bool MountDevices)
{
WDVD_Close();
Close_Inputs();
m_music.Stop();
m_music.StopAndSetPos();
gprintf("Reloading into IOS %i from %i...\n", ios, CurIOS);
ShutdownBeforeExit();
ret = IOS_ReloadIOS(ios) == 0;

View File

@ -2140,7 +2140,10 @@ bool CMenu::_loadChannelList(void)
Nand::Instance()->Disable_Emu();
if(!disable_emu)
{
_TempLoadIOS();
if(useMainIOS)
m_music.StopAndSetPos();
else
_TempLoadIOS();
if(!DeviceHandler::Instance()->IsInserted(lastPartition))
DeviceHandler::Instance()->Mount(lastPartition);

View File

@ -127,6 +127,16 @@ int OggDecoder::Rewind()
return ret;
}
int OggDecoder::Tell()
{
return ov_raw_tell(&ogg_file);
}
int OggDecoder::Seek(int pos)
{
return ov_raw_seek(&ogg_file, pos);
}
int OggDecoder::Read(u8 * buffer, int buffer_size, int)
{
if(!file_fd)

View File

@ -38,6 +38,8 @@ public:
int GetSampleRate();
int Rewind();
int Read(u8 * buffer, int buffer_size, int pos);
int Tell();
int Seek(int pos);
protected:
void OpenFile();
OggVorbis_File ogg_file;

View File

@ -83,6 +83,8 @@ public:
void SetLoop(u8 l);
//!Needed for music etc
void SetVoice(s8 v);
//!Needed for music :P
s8 GetVoice() { return voice; }
private:
//!Initializes the GuiSound object by setting the default values
void Init();

View File

@ -3,6 +3,7 @@
#include <cstdio>
#include "musicplayer.h"
#include "SoundHandler.hpp"
#include "fileOps/fileOps.h"
#include "gui/text.hpp"
@ -16,6 +17,7 @@ void MusicPlayer::cleanup()
void MusicPlayer::Init(Config &cfg, string musicDir, string themeMusicDir)
{
m_stopped = true;
CurrentPosition = 0;
m_fade_rate = cfg.getInt("GENERAL", "music_fade_rate", 8);
m_music_volume = cfg.getInt("GENERAL", "sound_volume_music", 255);
@ -78,7 +80,15 @@ void MusicPlayer::Next()
{
if(m_music_files.empty())
return;
if(CurrentPosition)
{
LoadCurrentFile();
MusicFile.Pause();
SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Seek(CurrentPosition);
CurrentPosition = 0;
MusicFile.Resume();
return;
}
m_current_music++;
if (m_current_music == m_music_files.end())
m_current_music = m_music_files.begin();
@ -86,6 +96,12 @@ void MusicPlayer::Next()
LoadCurrentFile();
}
void MusicPlayer::StopAndSetPos()
{
CurrentPosition = SoundHandler::Instance()->Decoder(MusicFile.GetVoice())->Tell();
Stop();
}
void MusicPlayer::Play()
{
SetVolume(m_music_current_volume);

View File

@ -23,6 +23,7 @@ public:
void Next();
void Play();
void Stop();
void StopAndSetPos();
bool IsStopped() { return m_stopped; };
@ -33,6 +34,7 @@ protected:
u8 m_music_volume;
u8 m_music_current_volume;
u8 m_fade_rate;
int CurrentPosition;
bool m_stopped;
GuiSound MusicFile;