More cleanup

This commit is contained in:
Henrik Rydgard 2015-01-11 20:25:45 +01:00
parent 51f352ee26
commit 26e4cb4a21
4 changed files with 5 additions and 56 deletions

View File

@ -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 <typename T>
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 <typename T>
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 <typename T, typename U>
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 <typename T, typename U>
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 <typename T, typename U>

View File

@ -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;
*/
}

View File

@ -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;
}

View File

@ -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)
};