Delete a bunch of old audio HLE cruft.

This commit intentionally breaks audio output from HLE Zelda UCode; no other functional change.
This commit is contained in:
magumagu 2014-03-26 11:17:19 -07:00
parent ea6b37cb75
commit ae9367a89b
14 changed files with 6 additions and 168 deletions

View File

@ -99,9 +99,6 @@ unsigned int CMixer::Mix(short* samples, unsigned int numSamples, bool consider_
// Flush cached variable
Common::AtomicStore(m_indexR, indexR);
// Add the DSPHLE sound, re-sampling is done inside
Premix(samples, numSamples);
// Add the DTK Music
// Re-sampling is done inside
AudioInterface::Callback_GetStreaming(samples, numSamples, m_sampleRate);

View File

@ -26,7 +26,6 @@ public:
, m_dacSampleRate(DACSampleRate)
, m_bits(16)
, m_channels(2)
, m_HLEready(false)
, m_logAudio(0)
, m_indexW(0)
, m_indexR(0)
@ -45,7 +44,6 @@ public:
// Called from audio threads
virtual unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);
virtual void Premix(short * /*samples*/, unsigned int /*numSamples*/) {}
// Called from main thread
virtual void PushSamples(const short* samples, unsigned int num_samples);
@ -53,11 +51,6 @@ public:
void SetThrottle(bool use) { m_throttle = use;}
// TODO: do we need this
bool IsHLEReady() const { return m_HLEready;}
void SetHLEReady(bool ready) { m_HLEready = ready;}
// ---------------------
virtual void StartLogAudio(const std::string& filename)
{
@ -102,7 +95,6 @@ protected:
WaveFileWriter g_wave_writer;
bool m_HLEready;
bool m_logAudio;
bool m_throttle;

View File

@ -106,7 +106,6 @@
<ClCompile Include="HW\CPU.cpp" />
<ClCompile Include="HW\DSP.cpp" />
<ClCompile Include="HW\DSPHLE\DSPHLE.cpp" />
<ClCompile Include="HW\DSPHLE\HLEMixer.cpp" />
<ClCompile Include="HW\DSPHLE\MailHandler.cpp" />
<ClCompile Include="HW\DSPHLE\UCodes\UCodes.cpp" />
<ClCompile Include="HW\DSPHLE\UCodes\UCode_AX.cpp" />
@ -305,7 +304,6 @@
<ClInclude Include="HW\CPU.h" />
<ClInclude Include="HW\DSP.h" />
<ClInclude Include="HW\DSPHLE\DSPHLE.h" />
<ClInclude Include="HW\DSPHLE\HLEMixer.h" />
<ClInclude Include="HW\DSPHLE\MailHandler.h" />
<ClInclude Include="HW\DSPHLE\UCodes\UCodes.h" />
<ClInclude Include="HW\DSPHLE\UCodes\UCode_AX.h" />

View File

@ -347,9 +347,6 @@
<ClCompile Include="HW\DSPHLE\DSPHLE.cpp">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClCompile>
<ClCompile Include="HW\DSPHLE\HLEMixer.cpp">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClCompile>
<ClCompile Include="HW\DSPHLE\MailHandler.cpp">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClCompile>
@ -873,9 +870,6 @@
<ClInclude Include="HW\DSPHLE\DSPHLE.h">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClInclude>
<ClInclude Include="HW\DSPHLE\HLEMixer.h">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClInclude>
<ClInclude Include="HW\DSPHLE\MailHandler.h">
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE</Filter>
</ClInclude>

View File

@ -15,7 +15,6 @@
#include "Core/HW/SystemTimers.h"
#include "Core/HW/VideoInterface.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/HLEMixer.h"
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
DSPHLE::DSPHLE()
@ -266,7 +265,7 @@ void DSPHLE::InitMixer()
unsigned int AISampleRate, DACSampleRate;
AudioInterface::Callback_GetSampleRate(AISampleRate, DACSampleRate);
delete soundStream;
soundStream = AudioCommon::InitSoundStream(new HLEMixer(this, AISampleRate, DACSampleRate, 48000), m_hWnd);
soundStream = AudioCommon::InitSoundStream(new CMixer(AISampleRate, DACSampleRate, 48000), m_hWnd);
if (!soundStream) PanicAlert("Error starting up sound stream");
// Mixer is initialized
m_InitMixer = true;

View File

@ -1,19 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/HLEMixer.h"
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
void HLEMixer::Premix(short *samples, unsigned int numSamples)
{
// if this was called directly from the HLE
if (IsHLEReady())
{
IUCode *pUCode = m_DSPHLE->GetUCode();
if (pUCode && samples)
pUCode->MixAdd(samples, numSamples);
}
}

View File

@ -1,21 +0,0 @@
// Copyright 2013 Dolphin Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "AudioCommon/AudioCommon.h"
#include "AudioCommon/Mixer.h"
class DSPHLE;
class HLEMixer : public CMixer
{
public:
HLEMixer(DSPHLE *dsp_hle, unsigned int AISampleRate = 48000, unsigned int DACSampleRate = 48000, unsigned int BackendSampleRate = 32000)
: CMixer(AISampleRate, DACSampleRate, BackendSampleRate), m_DSPHLE(dsp_hle) {};
virtual void Premix(short *samples, unsigned int numSamples) override;
private:
DSPHLE *m_DSPHLE;
};

View File

@ -16,30 +16,16 @@ CUCode_AX::CUCode_AX(DSPHLE* dsp_hle, u32 crc)
: IUCode(dsp_hle, crc)
, m_work_available(false)
, m_cmdlist_size(0)
, m_run_on_thread(false)
{
WARN_LOG(DSPHLE, "Instantiating CUCode_AX: crc=%08x", crc);
m_rMailHandler.PushMail(DSP_INIT);
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
LoadResamplingCoefficients();
// DSP HLE on thread is always disabled because it causes audio
// issues/glitching (different timing characteristics). m_run_on_thread is
// always false.
if (m_run_on_thread)
m_axthread = std::thread(SpawnAXThread, this);
}
CUCode_AX::~CUCode_AX()
{
if (m_run_on_thread)
{
m_cmdlist_size = (u16)-1; // Special value to signal end
NotifyAXThread();
m_axthread.join();
}
m_rMailHandler.Clear();
}
@ -80,32 +66,6 @@ void CUCode_AX::LoadResamplingCoefficients()
m_coeffs_available = true;
}
void CUCode_AX::SpawnAXThread(CUCode_AX* self)
{
self->AXThread();
}
void CUCode_AX::AXThread()
{
while (true)
{
{
std::unique_lock<std::mutex> lk(m_cmdlist_mutex);
while (m_cmdlist_size == 0)
m_cmdlist_cv.wait(lk);
}
if (m_cmdlist_size == (u16)-1) // End of thread signal
break;
m_processing.lock();
HandleCommandList();
m_cmdlist_size = 0;
SignalWorkEnd();
m_processing.unlock();
}
}
void CUCode_AX::SignalWorkEnd()
{
// Signal end of processing
@ -113,20 +73,6 @@ void CUCode_AX::SignalWorkEnd()
DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
}
void CUCode_AX::NotifyAXThread()
{
std::unique_lock<std::mutex> lk(m_cmdlist_mutex);
m_cmdlist_cv.notify_one();
}
void CUCode_AX::StartWorking()
{
if (m_run_on_thread)
NotifyAXThread();
else
m_work_available = true;
}
void CUCode_AX::HandleCommandList()
{
// Temp variables for addresses computation
@ -660,15 +606,10 @@ void CUCode_AX::HandleMail(u32 mail)
bool set_next_is_cmdlist = false;
// Wait for DSP processing to be done before answering any mail. This is
// safe to do because it matches what the DSP does on real hardware: there
// is no interrupt when a mail from CPU is received.
m_processing.lock();
if (next_is_cmdlist)
{
CopyCmdList(mail, cmdlist_size);
StartWorking();
m_work_available = true;
}
else if (m_UploadSetupInProgress)
{
@ -682,7 +623,6 @@ void CUCode_AX::HandleMail(u32 mail)
}
else if (mail == MAIL_NEW_UCODE)
{
soundStream->GetMixer()->SetHLEReady(false);
m_UploadSetupInProgress = true;
}
else if (mail == MAIL_RESET)
@ -705,7 +645,6 @@ void CUCode_AX::HandleMail(u32 mail)
ERROR_LOG(DSPHLE, "Unknown mail sent to AX::HandleMail: %08x", mail);
}
m_processing.unlock();
next_is_cmdlist = set_next_is_cmdlist;
}
@ -722,12 +661,6 @@ void CUCode_AX::CopyCmdList(u32 addr, u16 size)
m_cmdlist_size = size;
}
void CUCode_AX::MixAdd(short* out_buffer, int nsamples)
{
// Should never be called: we do not set HLE as ready.
// We accurately send samples to RAM instead of directly to the mixer.
}
void CUCode_AX::Update(int cycles)
{
// Used for UCode switching.
@ -767,8 +700,6 @@ void CUCode_AX::DoAXState(PointerWrap& p)
void CUCode_AX::DoState(PointerWrap& p)
{
std::lock_guard<std::mutex> lk(m_processing);
DoStateShared(p);
DoAXState(p);
}

View File

@ -56,15 +56,10 @@ public:
virtual ~CUCode_AX();
virtual void HandleMail(u32 mail) override;
virtual void MixAdd(short* out_buffer, int nsamples) override;
virtual void Update(int cycles) override;
virtual void DoState(PointerWrap& p) override;
u32 GetUpdateMs() override;
// Needed because StdThread.h std::thread implem does not support member
// pointers. TODO(delroth): obsolete.
static void SpawnAXThread(CUCode_AX* self);
protected:
enum MailType
{
@ -92,19 +87,8 @@ protected:
// This flag is set if there is anything to process.
bool m_work_available;
// Volatile because it's set by HandleMail and accessed in
// HandleCommandList, which are running in two different threads.
volatile u16 m_cmdlist[512];
volatile u32 m_cmdlist_size;
bool m_run_on_thread;
// Sync objects
std::mutex m_processing;
std::condition_variable m_cmdlist_cv;
std::mutex m_cmdlist_mutex;
std::thread m_axthread;
u16 m_cmdlist[512];
u32 m_cmdlist_size;
// Table of coefficients for polyphase sample rate conversion.
// The coefficients aren't always available (they are part of the DSP DROM)
@ -125,16 +109,6 @@ protected:
// Apply updates to a PB. Generic, used in AX GC and AX Wii.
void ApplyUpdatesForMs(int curr_ms, u16* pb, u16* num_updates, u16* updates);
// Signal that we should start handling a command list. Dispatches to the
// AX thread if using a thread, else just sets a boolean flag.
void StartWorking();
// Send a notification to the AX thread to tell it a new cmdlist addr is
// available for processing.
void NotifyAXThread();
void AXThread();
virtual void HandleCommandList();
void SignalWorkEnd();

View File

@ -667,8 +667,6 @@ u32 CUCode_AXWii::GetUpdateMs()
void CUCode_AXWii::DoState(PointerWrap &p)
{
std::lock_guard<std::mutex> lk(m_processing);
DoStateShared(p);
DoAXState(p);

View File

@ -134,7 +134,6 @@ void CUCode_Zelda::HandleMail_LightVersion(u32 _uMail)
if (m_CurBuffer == m_NumBuffers)
{
soundStream->GetMixer()->SetHLEReady(true);
m_bSyncCmdPending = false;
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
}
@ -200,7 +199,6 @@ void CUCode_Zelda::HandleMail_SMSVersion(u32 _uMail)
m_rMailHandler.PushMail(DSP_FRAME_END);
// DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP);
soundStream->GetMixer()->SetHLEReady(true);
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
// soundStream->Update(); //do it in this thread to avoid sync problems
@ -330,7 +328,6 @@ void CUCode_Zelda::HandleMail_NormalVersion(u32 _uMail)
m_rMailHandler.PushMail(DSP_FRAME_END);
//g_dspInitialize.pGenerateDSPInterrupt();
soundStream->GetMixer()->SetHLEReady(true);
DEBUG_LOG(DSPHLE, "Update the SoundThread to be in sync");
// soundStream->Update(); //do it in this thread to avoid sync problems
@ -392,7 +389,6 @@ void CUCode_Zelda::HandleMail_NormalVersion(u32 _uMail)
case 0x0001: // accepts params to either dma to iram and/or dram (used for hotbooting a new ucode)
// TODO find a better way to protect from HLEMixer?
soundStream->GetMixer()->SetHLEReady(false);
m_UploadSetupInProgress = true;
return;

View File

@ -127,7 +127,6 @@ public:
void HandleMail_NormalVersion(u32 _uMail);
void Update(int cycles) override;
void MixAdd(short* buffer, int size) override;
void CopyPBsFromRAM();
void CopyPBsToRAM();

View File

@ -738,7 +738,7 @@ ContinueWithBlock:
PB.NeedsReset = 0;
}
}
#if 0
// size is in stereo samples.
void CUCode_Zelda::MixAdd(short *_Buffer, int _Size)
{
@ -788,3 +788,4 @@ void CUCode_Zelda::MixAdd(short *_Buffer, int _Size)
_Buffer += 2;
}
}
#endif

View File

@ -77,7 +77,6 @@ public:
// Cycles are out of the 81/121mhz the DSP runs at.
virtual void Update(int cycles) = 0;
virtual void MixAdd(short* buffer, int size) {}
virtual u32 GetUpdateMs() = 0;
virtual void DoState(PointerWrap &p) { DoStateShared(p); }