Improved XTra.KrazzY's Mute-On-Pause a bit, so it won't cost any CPU time when it is not used.

Revert old Zelda-TP hack, though it really shouldn't be there...



git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4684 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2009-12-12 22:30:53 +00:00
parent 7be17e6531
commit fad1fa4e3d
12 changed files with 48 additions and 64 deletions

View File

@ -19,9 +19,12 @@
#include "AOSoundStream.h"
#include "Mixer.h"
#include "../../../PluginSpecs/pluginspecs_dsp.h"
#if defined(HAVE_AO) && HAVE_AO
extern DSPInitialize g_dspInitialize;
void AOSound::SoundLoop()
{
uint_32 numBytesToRender = 256;
@ -85,8 +88,14 @@ void AOSound::Update()
void AOSound::Clear()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
if(!*g_dspInitialize.pEmulatorState)
{
g_muted = false;
}
else
{
g_muted = true;
}
Update();
}
@ -107,11 +116,4 @@ AOSound::~AOSound() {
// ao_shutdown();
}
void AOSound::Mute(bool bMute) {
if((bMute && g_muted) || (!bMute && !g_muted))
return;
g_muted = bMute;
}
#endif

View File

@ -64,8 +64,6 @@ public:
virtual void Update();
virtual void Mute(bool bMute);
#else
public:
AOSound(CMixer *mixer) : SoundStream(mixer) {}

View File

@ -17,12 +17,14 @@
#include "Common.h"
#include "Thread.h"
#include "../../../PluginSpecs/pluginspecs_dsp.h"
#include "AlsaSoundStream.h"
#define BUFFER_SIZE 4096
#define BUFFER_SIZE_BYTES (BUFFER_SIZE*2*2)
extern DSPInitialize g_dspInitialize;
AlsaSound::AlsaSound(CMixer *mixer) : SoundStream(mixer), thread_data(0), handle(NULL)
{
mix_buffer = new u8[BUFFER_SIZE_BYTES];
@ -53,6 +55,18 @@ void AlsaSound::Stop()
thread = NULL;
}
void AlsaSound::Clear()
{
if(!*g_dspInitialize.pEmulatorState)
{
g_muted = false;
}
else
{
g_muted = true;
}
}
void AlsaSound::Update()
{
// don't need to do anything here.
@ -180,13 +194,6 @@ bool AlsaSound::AlsaInit()
NOTICE_LOG(AUDIO, "ALSA successfully initialized.\n");
return true;
}
void AlsaSound::Mute(bool bMute) {
if((bMute && g_muted) || (!bMute && !g_muted))
return;
g_muted = bMute;
}
void AlsaSound::AlsaShutdown()
{

View File

@ -37,6 +37,7 @@ public:
virtual bool Start();
virtual void SoundLoop();
virtual void Stop();
virtual void Clear();
static bool isValid() {
return true;
@ -47,8 +48,6 @@ public:
virtual void Update();
virtual void Mute(bool bMute);
private:
bool AlsaInit();
void AlsaShutdown();

View File

@ -19,7 +19,6 @@
#include <cmath>
#include <dxerr.h>
#include "DSoundStream.h"
#include "../../../PluginSpecs/pluginspecs_dsp.h"
extern DSPInitialize g_dspInitialize;
@ -172,9 +171,14 @@ void DSound::Update()
void DSound::Clear()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
Update();
if(!*g_dspInitialize.pEmulatorState)
{
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
}
else
{
dsBuffer->Stop();
}
}
void DSound::Stop()
@ -193,15 +197,3 @@ void DSound::Stop()
thread = NULL;
}
void DSound::Mute(bool bMute) {
if((bMute && g_muted) || (!bMute && !g_muted))
return;
if(bMute)
dsBuffer->Stop();
else
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
g_muted = bMute;
}

View File

@ -79,7 +79,6 @@ public:
virtual void SetVolume(int volume);
virtual void Stop();
virtual void Clear();
virtual void Mute(bool bMute);
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();

View File

@ -17,12 +17,15 @@
#include "aldlist.h"
#include "OpenALStream.h"
#include "../../../PluginSpecs/pluginspecs_dsp.h"
#if defined HAVE_OPENAL && HAVE_OPENAL
#define AUDIO_NUMBUFFERS (4)
//#define AUDIO_SERVICE_UPDATE_PERIOD (20)
extern DSPInitialize g_dspInitialize;
bool OpenALStream::Start()
{
ALDeviceList *pDeviceList = NULL;
@ -96,9 +99,14 @@ void OpenALStream::Update()
void OpenALStream::Clear()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
Update();
if(!*g_dspInitialize.pEmulatorState)
{
alSourcePlay(g_uiSource);
}
else
{
alSourceStop(g_uiSource);
}
}
THREAD_RETURN OpenALStream::ThreadFunc(void* args)
@ -178,17 +186,5 @@ void OpenALStream::SoundLoop()
}
void OpenALStream::Mute(bool bMute) {
if((bMute && g_muted) || (!bMute && !g_muted))
return;
if(bMute && g_uiSource)
alSourceStop(g_uiSource);
else if(g_uiSource)
alSourcePlay(g_uiSource);
g_muted = bMute;
}
#endif //HAVE_OPENAL

View File

@ -51,7 +51,6 @@ public:
virtual void SoundLoop();
virtual void Stop();
virtual void Clear();
virtual void Mute(bool bMute);
static bool isValid() { return true; }
virtual bool usesMixer() const { return true; }
virtual void Update();

View File

@ -46,7 +46,6 @@ public:
virtual void Stop() {}
virtual void Update() {}
virtual void Clear() {}
virtual void Mute(bool bMute) {}
virtual void StartLogAudio(const char *filename) {
if (! m_logAudio) {
m_logAudio = true;

View File

@ -579,6 +579,7 @@ void SetState(EState _State)
break;
case CORE_RUN:
CCPU::EnableStepping(false);
CPluginManager::GetInstance().GetDSP()->DSP_ClearAudioBuffer();
break;
default:
PanicAlert("Invalid state");

View File

@ -145,13 +145,11 @@ bool CWII_IPC_HLE_Device_FileIO::Seek(u32 _CommandAddress)
// AyuanX: this is still dubious because m_FileLength
// isn't updated on the fly when write happens
s32 NewSeekPosition = SeekPosition;
/*
if (m_FileLength > 0 && SeekPosition > m_FileLength && Mode == 0)
if (m_FileLength > 0 && SeekPosition > (s32)m_FileLength && Mode == 0)
{
NewSeekPosition = SeekPosition % m_FileLength;
}
INFO_LOG(WII_IPC_FILEIO, "FileIO: New Seek Pos: 0x%08x, Mode: %i (%s)", NewSeekPosition, Mode, m_Name.c_str());
*/
// Set seek mode
int seek_mode[3] = {SEEK_SET, SEEK_CUR, SEEK_END};

View File

@ -317,10 +317,6 @@ unsigned short DSP_ReadControlRegister()
void DSP_Update(int cycles)
{
// Handle muting
if(g_bMuted && !*g_dspInitialize.pEmulatorState && soundStream)
soundStream->Mute(g_bMuted = false);
// This is called OFTEN - better not do anything expensive!
CDSPHandler::GetInstance().Update(cycles);
}
@ -372,6 +368,4 @@ void DSP_ClearAudioBuffer()
{
if (soundStream)
soundStream->Clear();
if(*g_dspInitialize.pEmulatorState && soundStream && !g_bMuted)
soundStream->Mute(g_bMuted = true);
}