From 26e4cb4a21beb2190dcd162f0d1308a0b66ce6b8 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 11 Jan 2015 20:25:45 +0100 Subject: [PATCH] More cleanup --- Common/Atomic_Win32.h | 6 +++++- Core/HLE/__sceAudio.cpp | 38 ------------------------------------- Core/HW/StereoResampler.cpp | 7 ------- Core/HW/StereoResampler.h | 10 ---------- 4 files changed, 5 insertions(+), 56 deletions(-) diff --git a/Common/Atomic_Win32.h b/Common/Atomic_Win32.h index fadd9b11b1..b4029f2ba2 100644 --- a/Common/Atomic_Win32.h +++ b/Common/Atomic_Win32.h @@ -57,12 +57,14 @@ inline void AtomicOr(volatile u32& target, u32 value) _InterlockedOr((volatile LONG*)&target, (LONG)value); } +// For the comment below to hold, better only use this with 32-bit types.. template inline T AtomicLoad(volatile T& src) { return src; // 32-bit reads are always atomic. } +// For the comment below to hold, better only use this with 32-bit types.. template inline T AtomicLoadAcquire(volatile T& src) { @@ -71,17 +73,19 @@ inline T AtomicLoadAcquire(volatile T& src) return result; } +// For the comment below to hold, better only use this with 32-bit types.. template inline void AtomicStore(volatile T& dest, U value) { dest = (T)value; // 32-bit writes are always atomic. } +// For the comment below to hold, better only use this with 32-bit types.. template inline void AtomicStoreRelease(volatile T& dest, U value) { _WriteBarrier(); // Compiler instruction only. x86 stores always have release semantics. - dest = (T)value; // 32-bit writes are always atomic. + dest = (T)value; // 32-bit writes are always atomic } template diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 8b24bbd64e..672a7f7b18 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -410,42 +410,4 @@ void __AudioUpdate() { int __AudioMix(short *outstereo, int numFrames, int sampleRate) { resampler.Mix(outstereo, numFrames, false, sampleRate); return numFrames; - - /* - // TODO: if mixFrequency != the actual output frequency, resample! - int underrun = -1; - s16 sampleL = 0; - s16 sampleR = 0; - - const s16 *buf1 = 0, *buf2 = 0; - size_t sz1, sz2; - { - //TODO: do rigorous testing to see whether just blind locking will improve speed. - if (!__gainAudioQueueLock()){ - memset(outstereo, 0, numFrames * 2 * sizeof(short)); - return 0; - } - - resampler.Mix(outstereo, numFrames); - outAudioQueue.popPointers(numFrames * 2, &buf1, &sz1, &buf2, &sz2); - - memcpy(outstereo, buf1, sz1 * sizeof(s16)); - if (buf2) { - memcpy(outstereo + sz1, buf2, sz2 * sizeof(s16)); - } - - //release the atomic lock - __releaseAcquiredLock(); - } - - int remains = (int)(numFrames * 2 - sz1 - sz2); - if (remains > 0) - memset(outstereo + numFrames * 2 - remains, 0, remains*sizeof(s16)); - - if (sz1 + sz2 < (size_t)numFrames) { - underrun = (int)(sz1 + sz2) / 2; - VERBOSE_LOG(SCEAUDIO, "Audio out buffer UNDERRUN at %i of %i", underrun, numFrames); - } - return underrun >= 0 ? underrun : numFrames; - */ } diff --git a/Core/HW/StereoResampler.cpp b/Core/HW/StereoResampler.cpp index b08dfbe05b..fdfcb43292 100644 --- a/Core/HW/StereoResampler.cpp +++ b/Core/HW/StereoResampler.cpp @@ -54,7 +54,6 @@ inline void ClampBufferToS16(s16 *out, const s32 *in, size_t size) { void StereoResampler::MixerFifo::Clear() { memset(m_buffer, 0, sizeof(m_buffer)); - // TODO } // Executed from sound stream thread @@ -156,18 +155,12 @@ void StereoResampler::MixerFifo::PushSamples(const s32 *samples, unsigned int nu } Common::AtomicAdd(m_indexW, num_samples * 2); - - return; } void StereoResampler::PushSamples(const int *samples, unsigned int num_samples) { m_dma_mixer.PushSamples(samples, num_samples); } -void StereoResampler::SetDMAInputSampleRate(unsigned int rate) { - m_dma_mixer.SetInputSampleRate(rate); -} - void StereoResampler::MixerFifo::SetInputSampleRate(unsigned int rate) { m_input_sample_rate = rate; } diff --git a/Core/HW/StereoResampler.h b/Core/HW/StereoResampler.h index b0c1e7aeb0..38cf449f92 100644 --- a/Core/HW/StereoResampler.h +++ b/Core/HW/StereoResampler.h @@ -41,7 +41,6 @@ class StereoResampler { public: StereoResampler() : m_dma_mixer(this, 44100) - , m_speed(1.0) { } @@ -53,12 +52,6 @@ public: // Called from main thread // This clamps the samples to 16-bit before starting to work on them. virtual void PushSamples(const s32* samples, unsigned int num_samples); - unsigned int GetSampleRate() const { return m_sampleRate; } - - void SetDMAInputSampleRate(unsigned int rate); - - float GetCurrentSpeed() const { return m_speed; } - void UpdateSpeed(volatile float val) { m_speed = val; } void Clear() { m_dma_mixer.Clear(); @@ -95,7 +88,4 @@ protected: }; MixerFifo m_dma_mixer; - unsigned int m_sampleRate; - - volatile float m_speed; // Current rate of the emulation (1.0 = 100% speed) };