Code cleanup, removed extern declaration in sound streams
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4688 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
4fe3e46725
commit
afef9fb5f0
|
@ -19,12 +19,9 @@
|
|||
|
||||
#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;
|
||||
|
@ -54,8 +51,7 @@ void AOSound::SoundLoop()
|
|||
{
|
||||
soundCriticalSection.Enter();
|
||||
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
|
||||
if(!g_muted)
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
|
||||
soundCriticalSection.Leave();
|
||||
|
||||
if (! threadData)
|
||||
|
@ -86,19 +82,6 @@ void AOSound::Update()
|
|||
soundSyncEvent.Set();
|
||||
}
|
||||
|
||||
void AOSound::Clear()
|
||||
{
|
||||
if(!*g_dspInitialize.pEmulatorState)
|
||||
{
|
||||
g_muted = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_muted = true;
|
||||
}
|
||||
Update();
|
||||
}
|
||||
|
||||
void AOSound::Stop()
|
||||
{
|
||||
soundCriticalSection.Enter();
|
||||
|
|
|
@ -52,8 +52,6 @@ public:
|
|||
|
||||
virtual void Stop();
|
||||
|
||||
virtual void Clear();
|
||||
|
||||
static bool isValid() {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -17,14 +17,11 @@
|
|||
|
||||
#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];
|
||||
|
@ -55,18 +52,6 @@ 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.
|
||||
|
@ -76,12 +61,12 @@ void AlsaSound::Update()
|
|||
void AlsaSound::SoundLoop()
|
||||
{
|
||||
AlsaInit();
|
||||
// nakee: What is the optimal value?
|
||||
int frames_to_deliver = BUFFER_SIZE;
|
||||
while (!thread_data)
|
||||
{
|
||||
// nakee: What is the optimal value?
|
||||
int frames_to_deliver = 4096;
|
||||
m_mixer->Mix(reinterpret_cast<short *>(mix_buffer), frames_to_deliver);
|
||||
int rc = g_muted ? 1337 : snd_pcm_writei(handle, mix_buffer, frames_to_deliver);
|
||||
int rc = m_muted ? 1337 : snd_pcm_writei(handle, mix_buffer, frames_to_deliver);
|
||||
if (rc == -EPIPE)
|
||||
{
|
||||
// Underrun
|
||||
|
|
|
@ -37,7 +37,6 @@ public:
|
|||
virtual bool Start();
|
||||
virtual void SoundLoop();
|
||||
virtual void Stop();
|
||||
virtual void Clear();
|
||||
|
||||
static bool isValid() {
|
||||
return true;
|
||||
|
|
|
@ -18,10 +18,8 @@
|
|||
#include <windows.h>
|
||||
#include <cmath>
|
||||
#include <dxerr.h>
|
||||
#include "AudioCommon.h"
|
||||
#include "DSoundStream.h"
|
||||
#include "../../../PluginSpecs/pluginspecs_dsp.h"
|
||||
|
||||
extern DSPInitialize g_dspInitialize;
|
||||
|
||||
bool DSound::CreateBuffer()
|
||||
{
|
||||
|
@ -169,15 +167,16 @@ void DSound::Update()
|
|||
soundSyncEvent.Set();
|
||||
}
|
||||
|
||||
void DSound::Clear()
|
||||
void DSound::Clear(bool mute)
|
||||
{
|
||||
if(!*g_dspInitialize.pEmulatorState)
|
||||
m_muted = mute;
|
||||
if (m_muted)
|
||||
{
|
||||
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
dsBuffer->Stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
dsBuffer->Stop();
|
||||
dsBuffer->Play(0, 0, DSBPLAY_LOOPING);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
virtual void SoundLoop();
|
||||
virtual void SetVolume(int volume);
|
||||
virtual void Stop();
|
||||
virtual void Clear();
|
||||
virtual void Clear(bool mute);
|
||||
static bool isValid() { return true; }
|
||||
virtual bool usesMixer() const { return true; }
|
||||
virtual void Update();
|
||||
|
|
|
@ -17,15 +17,12 @@
|
|||
|
||||
#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;
|
||||
|
@ -97,15 +94,16 @@ void OpenALStream::Update()
|
|||
}
|
||||
}
|
||||
|
||||
void OpenALStream::Clear()
|
||||
void OpenALStream::Clear(bool mute)
|
||||
{
|
||||
if(!*g_dspInitialize.pEmulatorState)
|
||||
m_muted = mute;
|
||||
if(m_muted)
|
||||
{
|
||||
alSourcePlay(g_uiSource);
|
||||
alSourceStop(g_uiSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
alSourceStop(g_uiSource);
|
||||
alSourcePlay(g_uiSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "SoundStream.h"
|
||||
#include "Thread.h"
|
||||
|
||||
|
||||
#if defined HAVE_OPENAL && HAVE_OPENAL
|
||||
#ifdef _WIN32
|
||||
#include "../../../../Externals/OpenAL/include/al.h"
|
||||
|
@ -39,7 +38,6 @@
|
|||
#define OAL_BUFFER_SIZE 1024*1024
|
||||
#endif
|
||||
|
||||
|
||||
class OpenALStream: public SoundStream
|
||||
{
|
||||
#if defined HAVE_OPENAL && HAVE_OPENAL
|
||||
|
@ -50,7 +48,7 @@ public:
|
|||
virtual bool Start();
|
||||
virtual void SoundLoop();
|
||||
virtual void Stop();
|
||||
virtual void Clear();
|
||||
virtual void Clear(bool mute);
|
||||
static bool isValid() { return true; }
|
||||
virtual bool usesMixer() const { return true; }
|
||||
virtual void Update();
|
||||
|
@ -70,7 +68,4 @@ public:
|
|||
#endif // HAVE_OPENAL
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // OPENALSTREAM
|
||||
|
|
|
@ -32,10 +32,10 @@ protected:
|
|||
volatile int threadData;
|
||||
bool m_logAudio;
|
||||
WaveFileWriter g_wave_writer;
|
||||
bool g_muted;
|
||||
bool m_muted;
|
||||
|
||||
public:
|
||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), g_muted(false) {}
|
||||
SoundStream(CMixer *mixer) : m_mixer(mixer), threadData(0), m_muted(false) {}
|
||||
virtual ~SoundStream() { delete m_mixer;}
|
||||
|
||||
static bool isValid() { return false; }
|
||||
|
@ -45,7 +45,7 @@ public:
|
|||
virtual void SoundLoop() {}
|
||||
virtual void Stop() {}
|
||||
virtual void Update() {}
|
||||
virtual void Clear() {}
|
||||
virtual void Clear(bool mute) { m_muted = mute; }
|
||||
virtual void StartLogAudio(const char *filename) {
|
||||
if (! m_logAudio) {
|
||||
m_logAudio = true;
|
||||
|
|
|
@ -205,8 +205,6 @@ void Initialize(void *init)
|
|||
{
|
||||
g_dspInitialize = *(DSPInitialize*)init;
|
||||
|
||||
g_bMuted = false;
|
||||
|
||||
g_Config.Load();
|
||||
g_pMemory = g_dspInitialize.pGetMemoryPointer(0);
|
||||
|
||||
|
@ -367,5 +365,5 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
|||
void DSP_ClearAudioBuffer()
|
||||
{
|
||||
if (soundStream)
|
||||
soundStream->Clear();
|
||||
soundStream->Clear(*g_dspInitialize.pEmulatorState);
|
||||
}
|
||||
|
|
|
@ -370,6 +370,6 @@ void DSP_SendAIBuffer(unsigned int address, int sample_rate)
|
|||
void DSP_ClearAudioBuffer()
|
||||
{
|
||||
if(soundStream)
|
||||
soundStream->Clear();
|
||||
soundStream->Clear(*g_dspInitialize.pEmulatorState);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue