Skip to content

Commit

Permalink
Merge pull request #20014 from sum2012/atrac-log
Browse files Browse the repository at this point in the history
Add logging of Additional chunk data
  • Loading branch information
hrydgard authored Feb 21, 2025
2 parents 4565cc2 + e62e515 commit c95d2ad
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions Core/HLE/AtracCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "Core/HLE/AtracCtx.h"
#include "Core/HW/Atrac3Standalone.h"
#include "Core/HLE/sceKernelMemory.h"
#include <sstream>
#include <iomanip>

const size_t overAllocBytes = 16384;

Expand Down Expand Up @@ -357,8 +359,23 @@ int AnalyzeAtracTrack(u32 addr, u32 size, Track *track) {
// This is the offset to the jointStereo_ field.
track->jointStereo = Memory::Read_U32(addr + offset + 24);
}
if (chunkSize > 16) {
std::stringstream restChunkStream;

// Read and format extra bytes as hexadecimal
for (int i = 16; i < chunkSize; ++i) {
unsigned char byte = Memory::Read_U8(addr + offset + i);
restChunkStream << " " << std::hex << std::uppercase << std::setw(2) << std::setfill('0') << (int)byte;
}

std::string restChunk = restChunkStream.str();
if (!restChunk.empty()) {
DEBUG_LOG(Log::ME, "Additional chunk data:%s", restChunk.c_str());
}

}
break;
}
break;
case FACT_CHUNK_MAGIC:
{
track->endSample = Memory::Read_U32(addr + offset);
Expand All @@ -369,8 +386,8 @@ int AnalyzeAtracTrack(u32 addr, u32 size, Track *track) {
u32 largerOffset = Memory::Read_U32(addr + offset + 8);
sampleOffsetAdjust = track->firstSampleOffset - largerOffset;
}
break;
}
break;
case SMPL_CHUNK_MAGIC:
{
if (chunkSize < 32) {
Expand Down Expand Up @@ -400,8 +417,8 @@ int AnalyzeAtracTrack(u32 addr, u32 size, Track *track) {
return hleReportError(Log::ME, ATRAC_ERROR_BAD_CODEC_PARAMS, "loop starts after it ends");
}
}
break;
}
break;
case DATA_CHUNK_MAGIC:
{
bfoundData = true;
Expand Down

0 comments on commit c95d2ad

Please sign in to comment.