diff --git a/Source/Core/AudioCommon/Mixer.cpp b/Source/Core/AudioCommon/Mixer.cpp index 2b785ffaf4..fa43baeb99 100644 --- a/Source/Core/AudioCommon/Mixer.cpp +++ b/Source/Core/AudioCommon/Mixer.cpp @@ -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); diff --git a/Source/Core/AudioCommon/Mixer.h b/Source/Core/AudioCommon/Mixer.h index a892618cca..f7fcdbf14b 100644 --- a/Source/Core/AudioCommon/Mixer.h +++ b/Source/Core/AudioCommon/Mixer.h @@ -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; diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index f91087c3d2..e2b02f8a82 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -106,7 +106,6 @@ - @@ -305,7 +304,6 @@ - diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 34264a07cf..af927b7b9f 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -347,9 +347,6 @@ HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE - - HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE - HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE @@ -873,9 +870,6 @@ HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE - - HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE - HW %28Flipper/Hollywood%29\DSP Interface + HLE\HLE diff --git a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp index 0bdffb70a2..eb7ca52ab8 100644 --- a/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp +++ b/Source/Core/Core/HW/DSPHLE/DSPHLE.cpp @@ -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; diff --git a/Source/Core/Core/HW/DSPHLE/HLEMixer.cpp b/Source/Core/Core/HW/DSPHLE/HLEMixer.cpp deleted file mode 100644 index d1d51c4c85..0000000000 --- a/Source/Core/Core/HW/DSPHLE/HLEMixer.cpp +++ /dev/null @@ -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); - } -} - diff --git a/Source/Core/Core/HW/DSPHLE/HLEMixer.h b/Source/Core/Core/HW/DSPHLE/HLEMixer.h deleted file mode 100644 index 135bfe97b8..0000000000 --- a/Source/Core/Core/HW/DSPHLE/HLEMixer.h +++ /dev/null @@ -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; -}; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.cpp index f7eea84f22..379da8bab4 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.cpp @@ -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 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 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 lk(m_processing); - DoStateShared(p); DoAXState(p); } diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.h index ede8ef6aa3..f29c14659b 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AX.h @@ -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(); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AXWii.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AXWii.cpp index 8ebef6e80e..9655f99a36 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AXWii.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_AXWii.cpp @@ -667,8 +667,6 @@ u32 CUCode_AXWii::GetUpdateMs() void CUCode_AXWii::DoState(PointerWrap &p) { - std::lock_guard lk(m_processing); - DoStateShared(p); DoAXState(p); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.cpp index 62c67d7927..3019065e42 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.cpp @@ -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; diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.h index eab6de743f..1d0f1c643a 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda.h @@ -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(); diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda_Voice.cpp b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda_Voice.cpp index 4393a48f0c..0b4dbb092f 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda_Voice.cpp +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCode_Zelda_Voice.cpp @@ -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 \ No newline at end of file diff --git a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h index 73bf8795fb..40bd9e38aa 100644 --- a/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h +++ b/Source/Core/Core/HW/DSPHLE/UCodes/UCodes.h @@ -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); }