Skip to content

Commit

Permalink
HLE log rename part 1: Remove duplicate log functions. Return type sh…
Browse files Browse the repository at this point in the history
…ould be determined by metadata.
  • Loading branch information
hrydgard committed Jan 29, 2025
1 parent b9decb2 commit 28b2c7f
Show file tree
Hide file tree
Showing 42 changed files with 402 additions and 409 deletions.
6 changes: 3 additions & 3 deletions Core/HLE/AtracCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ int Atrac::SetData(u32 buffer, u32 readSize, u32 bufferSize, int outputChannels,
Memory::Memcpy(dataBuf_, buffer, copybytes, "AtracSetData");
}
CreateDecoder();
return hleLogSuccessInfoI(Log::ME, successCode, "%s %s audio", codecName, channelName);
return hleLogInfo(Log::ME, successCode, "%s %s audio", codecName, channelName);
}

u32 Atrac::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) {
Expand All @@ -714,7 +714,7 @@ u32 Atrac::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) {
second_.addr = secondBuffer;
second_.size = secondBufferSize;
second_.fileoffset = secondFileOffset;
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

int AtracBase::GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) {
Expand All @@ -727,7 +727,7 @@ int AtracBase::GetSecondBufferInfo(u32 *fileOffset, u32 *desiredSize) {

*fileOffset = track_.FileOffsetBySample(track_.loopEndSample - track_.firstSampleOffset);
*desiredSize = track_.fileSize - *fileOffset;
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

void Atrac::GetStreamDataInfo(u32 *writePtr, u32 *writableBytes, u32 *readOffset) {
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/AtracCtx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int Atrac2::SetData(u32 buffer, u32 readSize, u32 bufferSize, int outputChannels
} else {
bufferState_ = ATRAC_STATUS_HALFWAY_BUFFER;
}
return hleLogSuccessI(Log::ME, successCode);
return hleLogDebug(Log::ME, successCode);
}

u32 Atrac2::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) {
Expand Down
23 changes: 8 additions & 15 deletions Core/HLE/HLE.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,25 +281,18 @@ inline R hleCallImpl(std::string_view module, std::string_view funcName, F func,
// IMPORTANT: These *must* only be used directly in HLE functions. They cannot be used by utility functions
// called by them. Use regular ERROR_LOG etc for those.

#define hleLogHelper(t, level, res, retmask, ...) \
#define hleLogReturnHelper(t, level, res, retmask, ...) \
(((int)level <= MAX_LOGLEVEL) ? hleDoLog<true>(t, level, (res), __FILE__, __LINE__, nullptr, retmask, ##__VA_ARGS__) : (res))

#define hleLogError(t, res, ...) hleLogHelper(t, LogLevel::LERROR, res, 'x', ##__VA_ARGS__)
#define hleLogWarning(t, res, ...) hleLogHelper(t, LogLevel::LWARNING, res, 'x', ##__VA_ARGS__)
#define hleLogVerbose(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
#define hleLogError(t, res, ...) hleLogReturnHelper(t, LogLevel::LERROR, res, 'x', ##__VA_ARGS__)
#define hleLogWarning(t, res, ...) hleLogReturnHelper(t, LogLevel::LWARNING, res, 'x', ##__VA_ARGS__)
#define hleLogDebug(t, res, ...) hleLogReturnHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
#define hleLogInfo(t, res, ...) hleLogReturnHelper(t, LogLevel::LINFO, res, 'x', ##__VA_ARGS__)
#define hleLogVerbose(t, res, ...) hleLogReturnHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)

// If res is negative, log warn/error, otherwise log debug.
#define hleLogSuccessOrWarn(t, res, ...) hleLogHelper(t, ((int)res < 0 ? LogLevel::LWARNING : HLE_LOG_LDEBUG), res, 'x', ##__VA_ARGS__)
#define hleLogSuccessOrError(t, res, ...) hleLogHelper(t, ((int)res < 0 ? LogLevel::LERROR : HLE_LOG_LDEBUG), res, 'x', ##__VA_ARGS__)

// NOTE: hleLogDebug is equivalent to hleLogSuccessI/X.
#define hleLogDebug(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
#define hleLogSuccessX(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'x', ##__VA_ARGS__)
#define hleLogSuccessI(t, res, ...) hleLogHelper(t, HLE_LOG_LDEBUG, res, 'i', ##__VA_ARGS__)
#define hleLogSuccessInfoX(t, res, ...) hleLogHelper(t, LogLevel::LINFO, res, 'x', ##__VA_ARGS__)
#define hleLogSuccessInfoI(t, res, ...) hleLogHelper(t, LogLevel::LINFO, res, 'i', ##__VA_ARGS__)
#define hleLogSuccessVerboseX(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'x', ##__VA_ARGS__)
#define hleLogSuccessVerboseI(t, res, ...) hleLogHelper(t, HLE_LOG_LVERBOSE, res, 'i', ##__VA_ARGS__)
#define hleLogDebugOrWarn(t, res, ...) hleLogReturnHelper(t, ((int)res < 0 ? LogLevel::LWARNING : HLE_LOG_LDEBUG), res, 'x', ##__VA_ARGS__)
#define hleLogDebugOrError(t, res, ...) hleLogReturnHelper(t, ((int)res < 0 ? LogLevel::LERROR : HLE_LOG_LDEBUG), res, 'x', ##__VA_ARGS__)

#define hleReportError(t, res, ...) hleDoLog<true>(t, LogLevel::LERROR, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
#define hleReportWarning(t, res, ...) hleDoLog<true>(t, LogLevel::LWARNING, res, __FILE__, __LINE__, "", 'x', ##__VA_ARGS__)
46 changes: 23 additions & 23 deletions Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ static u32 sceAtracGetAtracID(int codecType) {
return hleLogError(Log::ME, atracID, "no free ID");
}

return hleLogSuccessInfoI(Log::ME, atracID);
return hleLogInfo(Log::ME, atracID);
}

static u32 AtracValidateData(const AtracBase *atrac) {
Expand Down Expand Up @@ -250,7 +250,7 @@ static u32 sceAtracAddStreamData(int atracID, u32 bytesToAdd) {
if (ret < 0) {
return ret;
}
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

// Note that outAddr being null is completely valid here, used to skip data.
Expand Down Expand Up @@ -312,7 +312,7 @@ static u32 sceAtracGetBufferInfoForResetting(int atracID, int sample, u32 buffer
return hleLogWarning(Log::ME, ATRAC_ERROR_BAD_SAMPLE, "invalid sample position");
} else {
atrac->GetResetBufferInfo(bufferInfo, sample);
return hleLogSuccessInfoI(Log::ME, 0);
return hleLogInfo(Log::ME, 0);
}
}

Expand All @@ -328,7 +328,7 @@ static u32 sceAtracGetBitrate(int atracID, u32 outBitrateAddr) {

if (Memory::IsValidAddress(outBitrateAddr)) {
Memory::WriteUnchecked_U32(atrac->GetTrack().bitrate, outBitrateAddr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
} else {
return hleLogError(Log::ME, 0, "invalid address");
}
Expand All @@ -344,7 +344,7 @@ static u32 sceAtracGetChannel(int atracID, u32 channelAddr) {

if (Memory::IsValidAddress(channelAddr)){
Memory::WriteUnchecked_U32(atrac->GetTrack().channels, channelAddr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
} else {
return hleLogError(Log::ME, 0, "invalid address");
}
Expand All @@ -366,7 +366,7 @@ static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) {
Memory::WriteUnchecked_U32(1, statusAddr);
else
Memory::WriteUnchecked_U32(0, statusAddr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
} else {
return hleLogError(Log::ME, 0, "invalid address");
}
Expand Down Expand Up @@ -395,7 +395,7 @@ static u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr) {

if (Memory::IsValidAddress(maxSamplesAddr)) {
Memory::WriteUnchecked_U32(atrac->GetTrack().SamplesPerFrame(), maxSamplesAddr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
} else {
return hleLogError(Log::ME, 0, "invalid address");
}
Expand All @@ -412,10 +412,10 @@ static u32 sceAtracGetNextDecodePosition(int atracID, u32 outposAddr) {
if (Memory::IsValidAddress(outposAddr)) {
if (atrac->CurrentSample() >= atrac->GetTrack().endSample) {
Memory::WriteUnchecked_U32(0, outposAddr);
return hleLogSuccessI(Log::ME, ATRAC_ERROR_ALL_DATA_DECODED, "all data decoded - beyond endSample");
return hleLogDebug(Log::ME, ATRAC_ERROR_ALL_DATA_DECODED, "all data decoded - beyond endSample");
} else {
Memory::WriteUnchecked_U32(atrac->CurrentSample(), outposAddr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}
} else {
return hleLogError(Log::ME, 0, "invalid address");
Expand All @@ -432,14 +432,14 @@ static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) {
if (atrac->CurrentSample() >= atrac->GetTrack().endSample) {
if (Memory::IsValidAddress(outNAddr))
Memory::WriteUnchecked_U32(0, outNAddr);
return hleLogSuccessI(Log::ME, 0, "0 samples left");
return hleLogDebug(Log::ME, 0, "0 samples left");
}

u32 numSamples = atrac->GetNextSamples();

if (Memory::IsValidAddress(outNAddr))
Memory::WriteUnchecked_U32(numSamples, outNAddr);
return hleLogSuccessI(Log::ME, 0, "%d samples left", numSamples);
return hleLogDebug(Log::ME, 0, "%d samples left", numSamples);
}

// Obtains the number of frames remaining in the buffer which can be decoded.
Expand All @@ -460,7 +460,7 @@ static u32 sceAtracGetRemainFrame(int atracID, u32 remainAddr) {
}

*remainingFrames = atrac->RemainingFrames();
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

static u32 sceAtracGetSecondBufferInfo(int atracID, u32 fileOffsetAddr, u32 desiredSizeAddr) {
Expand Down Expand Up @@ -503,7 +503,7 @@ static u32 sceAtracGetSoundSample(int atracID, u32 outEndSampleAddr, u32 outLoop
if (!outEndSample.IsValid() || !outLoopStart.IsValid() || !outLoopEnd.IsValid()) {
return hleReportError(Log::ME, 0, "invalid address");
}
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

// Games call this function to get some info for add more stream data,
Expand All @@ -529,7 +529,7 @@ static u32 sceAtracGetStreamDataInfo(int atracID, u32 writePtrAddr, u32 writable
if (Memory::IsValidAddress(readOffsetAddr))
Memory::WriteUnchecked_U32(readOffset, readOffsetAddr);

return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

static u32 sceAtracReleaseAtracID(int atracID) {
Expand All @@ -541,7 +541,7 @@ static u32 sceAtracReleaseAtracID(int atracID) {
return hleLogWarning(Log::ME, result, "did not exist");
}
}
return hleLogSuccessInfoI(Log::ME, result);
return hleLogInfo(Log::ME, result);
}

// This is called when a game wants to seek (or "reset") to a specific position in the audio data.
Expand All @@ -568,7 +568,7 @@ static u32 sceAtracResetPlayPosition(int atracID, int sample, int bytesWrittenFi
return res;
}

return hleDelayResult(hleLogSuccessInfoI(Log::ME, 0), "reset play pos", 3000);
return hleDelayResult(hleLogInfo(Log::ME, 0), "reset play pos", 3000);
}

// Allowed to log like a HLE function, only called at the end of some.
Expand Down Expand Up @@ -699,7 +699,7 @@ static u32 sceAtracSetLoopNum(int atracID, int loopNum) {
}

atrac->SetLoopNum(loopNum);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
}

static int sceAtracReinit(int at3Count, int at3plusCount) {
Expand All @@ -717,7 +717,7 @@ static int sceAtracReinit(int at3Count, int at3plusCount) {
// This seems to deinit things. Mostly, it cause a reschedule on next deinit (but -1, -1 does not.)
if (at3Count == 0 && at3plusCount == 0) {
atracInited = false;
return hleDelayResult(hleLogSuccessInfoI(Log::ME, 0, "deinit"), "atrac reinit", 200);
return hleDelayResult(hleLogInfo(Log::ME, 0, "deinit"), "atrac reinit", 200);
}

// First, ATRAC3+. These IDs seem to cost double (probably memory.)
Expand All @@ -739,10 +739,10 @@ static int sceAtracReinit(int at3Count, int at3plusCount) {
int result = space >= 0 ? 0 : (int)SCE_KERNEL_ERROR_OUT_OF_MEMORY;
if (atracInited || next == 0) {
atracInited = true;
return hleLogSuccessInfoI(Log::ME, result);
return hleLogInfo(Log::ME, result);
} else {
atracInited = true;
return hleDelayResult(hleLogSuccessInfoI(Log::ME, result), "atrac reinit", 400);
return hleDelayResult(hleLogInfo(Log::ME, result), "atrac reinit", 400);
}
}

Expand All @@ -755,7 +755,7 @@ static int sceAtracGetOutputChannel(int atracID, u32 outputChanPtr) {
}
if (Memory::IsValidAddress(outputChanPtr)) {
Memory::WriteUnchecked_U32(atrac->GetOutputChannels(), outputChanPtr);
return hleLogSuccessI(Log::ME, 0);
return hleLogDebug(Log::ME, 0);
} else {
return hleLogError(Log::ME, 0, "invalid address");
}
Expand All @@ -771,7 +771,7 @@ static int sceAtracIsSecondBufferNeeded(int atracID) {

// Note that this returns true whether the buffer is already set or not.
int needed = atrac->BufferState() == ATRAC_STATUS_STREAMED_LOOP_WITH_TRAILER ? 1 : 0;
return hleLogSuccessI(Log::ME, needed);
return hleLogDebug(Log::ME, needed);
}

static int sceAtracSetMOutHalfwayBuffer(int atracID, u32 buffer, u32 readSize, u32 bufferSize) {
Expand Down Expand Up @@ -955,7 +955,7 @@ static int sceAtracLowLevelInitDecoder(int atracID, u32 paramsAddr) {

const char *codecName = atrac->GetTrack().codecType == PSP_MODE_AT_3 ? "atrac3" : "atrac3+";
const char *channelName = atrac->GetTrack().channels == 1 ? "mono" : "stereo";
return hleLogSuccessInfoI(Log::ME, 0, "%s %s audio", codecName, channelName);
return hleLogInfo(Log::ME, 0, "%s %s audio", codecName, channelName);
}

static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesConsumedAddr, u32 samplesAddr, u32 sampleBytesAddr) {
Expand Down
20 changes: 10 additions & 10 deletions Core/HLE/sceAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ static u32 sceAudioChRelease(u32 chan) {
// TODO: Does this error if busy?
chans[chan].reset();
chans[chan].reserved = false;
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioSetChannelDataLen(u32 chan, u32 len) {
Expand Down Expand Up @@ -287,7 +287,7 @@ static u32 sceAudioOutput2Reserve(u32 sampleCount) {
chan.format = PSP_AUDIO_FORMAT_STEREO;
chan.reserved = true;
__AudioSetSRCFrequency(0);
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr) {
Expand All @@ -309,7 +309,7 @@ static u32 sceAudioOutput2OutputBlocking(u32 vol, u32 dataPtr) {
int result = __AudioEnqueue(chan, PSP_AUDIO_CHANNEL_OUTPUT2, true);
if (result < 0)
return hleLogError(Log::sceAudio, result);
return hleLogSuccessI(Log::sceAudio, result);
return hleLogDebug(Log::sceAudio, result);
}

static u32 sceAudioOutput2ChangeLength(u32 sampleCount) {
Expand All @@ -318,7 +318,7 @@ static u32 sceAudioOutput2ChangeLength(u32 sampleCount) {
return hleLogError(Log::sceAudio, SCE_ERROR_AUDIO_CHANNEL_NOT_RESERVED, "channel not reserved");
}
chan.sampleCount = sampleCount;
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioOutput2GetRestSample() {
Expand All @@ -331,7 +331,7 @@ static u32 sceAudioOutput2GetRestSample() {
// If ChangeLength reduces the size, it still gets output but this return is clamped.
size = chan.sampleCount;
}
return hleLogSuccessI(Log::sceAudio, size);
return hleLogDebug(Log::sceAudio, size);
}

static u32 sceAudioOutput2Release() {
Expand All @@ -343,7 +343,7 @@ static u32 sceAudioOutput2Release() {

chan.reset();
chan.reserved = false;
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioSetFrequency(u32 freq) {
Expand Down Expand Up @@ -392,7 +392,7 @@ static u32 sceAudioSRCChReserve(u32 sampleCount, u32 freq, u32 format) {
chan.format = format == 2 ? PSP_AUDIO_FORMAT_STEREO : PSP_AUDIO_FORMAT_MONO;
// Zero means default to 44.1kHz.
__AudioSetSRCFrequency(freq);
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioSRCChRelease() {
Expand All @@ -404,7 +404,7 @@ static u32 sceAudioSRCChRelease() {

chan.reset();
chan.reserved = false;
return hleLogSuccessI(Log::sceAudio, 0);
return hleLogDebug(Log::sceAudio, 0);
}

static u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
Expand All @@ -425,14 +425,14 @@ static u32 sceAudioSRCOutputBlocking(u32 vol, u32 buf) {
int result = __AudioEnqueue(chan, PSP_AUDIO_CHANNEL_SRC, true);
if (result < 0)
return hleLogError(Log::sceAudio, result);
return hleLogSuccessI(Log::sceAudio, result);
return hleLogDebug(Log::sceAudio, result);
}

static int sceAudioInputBlocking(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
if (!Memory::IsValidAddress(bufAddr)) {
return hleLogError(Log::HLE, -1, "invalid address");
}
return hleLogSuccessInfoI(Log::HLE, __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT));
return hleLogInfo(Log::HLE, __MicInput(maxSamples, sampleRate, bufAddr, AUDIOINPUT));
}

static int sceAudioInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
Expand Down
Loading

0 comments on commit 28b2c7f

Please sign in to comment.