From ee37d51c4b861ea1d49beed4ecb07afb4db7e73b Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 24 Aug 2013 11:51:00 +0200 Subject: [PATCH] Just some formatting/cleanup --- Core/HLE/__sceAudio.cpp | 60 +++++++++++++++-------------------------- Core/HLE/sceAudio.cpp | 4 +++ 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index bec1023777..e6cbd30480 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -29,8 +29,6 @@ #include "FixedSizeQueue.h" #include "Common/Thread.h" -// #define LOW_LATENCY_AUDIO - // Should be used to lock anything related to the outAudioQueue. recursive_mutex section; @@ -49,14 +47,9 @@ static int audioHostIntervalUs; static s32 *mixBuffer; // High and low watermarks, basically. For perfect emulation, the correct values are 0 and 1, respectively. -// TODO: Tweak -#ifdef LOW_LATENCY_AUDIO -const int chanQueueMaxSizeFactor = 0; -const int chanQueueMinSizeFactor = 1; -#else -const int chanQueueMaxSizeFactor = 2; -const int chanQueueMinSizeFactor = 1; -#endif +// TODO: Tweak. Hm, there aren't actually even used currently... +static int chanQueueMaxSizeFactor; +static int chanQueueMinSizeFactor; // TODO: Need to replace this with something lockless. Mutexes in the audio pipeline // is bad mojo. @@ -91,9 +84,13 @@ void __AudioInit() { mixFrequency = 44100; if (g_Config.bLowLatencyAudio) { + chanQueueMaxSizeFactor = 1; + chanQueueMinSizeFactor = 0; hwBlockSize = 16; hostAttemptBlockSize = 256; } else { + chanQueueMaxSizeFactor = 2; + chanQueueMinSizeFactor = 1; hwBlockSize = 64; hostAttemptBlockSize = 512; } @@ -113,8 +110,7 @@ void __AudioInit() { memset(mixBuffer, 0, hwBlockSize * 2 * sizeof(s32)); } -void __AudioDoState(PointerWrap &p) -{ +void __AudioDoState(PointerWrap &p) { p.Do(eventAudioUpdate); CoreTiming::RestoreRegisterEvent(eventAudioUpdate, "AudioUpdate", &hleAudioUpdate); p.Do(eventHostAudioUpdate); @@ -181,17 +177,14 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) { return ret; } - if (chan.format == PSP_AUDIO_FORMAT_STEREO) - { + if (chan.format == PSP_AUDIO_FORMAT_STEREO) { const u32 totalSamples = chan.sampleCount * 2; - if (IS_LITTLE_ENDIAN) - { + if (IS_LITTLE_ENDIAN) { s16 *sampleData = (s16 *) Memory::GetPointer(chan.sampleAddress); // Walking a pointer for speed. But let's make sure we wouldn't trip on an invalid ptr. - if (Memory::IsValidAddress(chan.sampleAddress + (totalSamples - 1) * sizeof(s16))) - { + if (Memory::IsValidAddress(chan.sampleAddress + (totalSamples - 1) * sizeof(s16))) { #if 0 for (u32 i = 0; i < totalSamples; i += 2) { chan.sampleQueue.push(adjustvolume(*sampleData++, chan.leftVolume)); @@ -205,24 +198,20 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) { int rightVol = chan.rightVolume; // TODO: SSE/NEON implementations - for (u32 i = 0; i < sz1; i += 2) - { + for (u32 i = 0; i < sz1; i += 2) { buf1[i] = adjustvolume(sampleData[i], leftVol); buf1[i + 1] = adjustvolume(sampleData[i + 1], rightVol); } if (buf2) { sampleData += sz1; - for (u32 i = 0; i < sz2; i += 2) - { + for (u32 i = 0; i < sz2; i += 2) { buf2[i] = adjustvolume(sampleData[i], leftVol); buf2[i + 1] = adjustvolume(sampleData[i + 1], rightVol); } } #endif } - } - else - { + } else { for (u32 i = 0; i < totalSamples; i++) { s16 sampleL = (s16)Memory::Read_U16(chan.sampleAddress + sizeof(s16) * i); sampleL = adjustvolume(sampleL, chan.leftVolume); @@ -234,10 +223,8 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) { } } } - else if (chan.format == PSP_AUDIO_FORMAT_MONO) - { - for (u32 i = 0; i < chan.sampleCount; i++) - { + else if (chan.format == PSP_AUDIO_FORMAT_MONO) { + for (u32 i = 0; i < chan.sampleCount; i++) { // Expand to stereo s16 sample = (s16)Memory::Read_U16(chan.sampleAddress + 2 * i); chan.sampleQueue.push(adjustvolume(sample, chan.leftVolume)); @@ -247,18 +234,15 @@ u32 __AudioEnqueue(AudioChannel &chan, int chanNum, bool blocking) { return ret; } -inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) -{ +inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) { u32 error; - for (size_t w = 0; w < chan.waitingThreads.size(); ++w) - { + for (size_t w = 0; w < chan.waitingThreads.size(); ++w) { AudioChannelWaitInfo &waitInfo = chan.waitingThreads[w]; waitInfo.numSamples -= step; // If it's done (there will still be samples on queue) and actually still waiting, wake it up. u32 waitID = __KernelGetWaitID(waitInfo.threadID, WAITTYPE_AUDIOCHANNEL, error); - if (waitInfo.numSamples <= 0 && waitID != 0) - { + if (waitInfo.numSamples <= 0 && waitID != 0) { // DEBUG_LOG(HLE, "Woke thread %i for some buffer filling", waitingThread); u32 ret = result == 0 ? __KernelGetWaitValue(waitInfo.threadID, error) : SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED; __KernelResumeThreadFromWait(waitInfo.threadID, ret); @@ -271,13 +255,11 @@ inline void __AudioWakeThreads(AudioChannel &chan, int result, int step) } } -void __AudioWakeThreads(AudioChannel &chan, int result) -{ +void __AudioWakeThreads(AudioChannel &chan, int result) { __AudioWakeThreads(chan, result, 0x7FFFFFFF); } -void __AudioSetOutputFrequency(int freq) -{ +void __AudioSetOutputFrequency(int freq) { WARN_LOG(HLE, "Switching audio frequency to %i", freq); mixFrequency = freq; } diff --git a/Core/HLE/sceAudio.cpp b/Core/HLE/sceAudio.cpp index 3f0738dc4f..74877c616c 100644 --- a/Core/HLE/sceAudio.cpp +++ b/Core/HLE/sceAudio.cpp @@ -421,6 +421,8 @@ const HLEFunction sceAudio[] = {0x63f2889c, WrapU_U, "sceAudioOutput2ChangeLength"}, {0x647cef33, WrapU_V, "sceAudioOutput2GetRestSample"}, {0x43196845, WrapU_V, "sceAudioOutput2Release"}, + + // "Traditional" audio channel interface {0x80F1F7E0, WrapU_V, "sceAudioInit"}, {0x210567F7, WrapU_V, "sceAudioEnd"}, {0xA2BEAA6C, WrapU_U, "sceAudioSetFrequency"}, @@ -436,6 +438,8 @@ const HLEFunction sceAudio[] = {0xCB2E439E, WrapU_UU, "sceAudioSetChannelDataLen"}, {0x95FD0C2D, WrapU_UU, "sceAudioChangeChannelConfig"}, {0xB7E1D8E7, WrapU_UUU, "sceAudioChangeChannelVolume"}, + + // Not sure about the point of these, maybe like traditional but with ability to do sample rate conversion? {0x38553111, WrapU_UUU, "sceAudioSRCChReserve"}, {0x5C37C0AE, WrapU_V, "sceAudioSRCChRelease"}, {0xE0727056, WrapU_UU, "sceAudioSRCOutputBlocking"},