Skip to content

Commit 79945d6

Browse files
authored
Merge pull request #20136 from hrydgard/more-atrac-fixes
New sceAtrac impl: Fix low level decoding
2 parents c71a72c + e3297d8 commit 79945d6

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Core/HLE/AtracCtx2.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,13 @@ int Atrac2::DecodeLowLevel(const u8 *srcData, int *bytesConsumed, s16 *dstData,
10241024

10251025
const int channels = outputChannels_;
10261026
int outSamples = 0;
1027-
decoder_->Decode(srcData, info.sampleSize, bytesConsumed, channels, dstData, &outSamples);
1027+
bool success = decoder_->Decode(srcData, info.sampleSize, bytesConsumed, channels, dstData, &outSamples);
1028+
if (!success) {
1029+
ERROR_LOG(Log::ME, "Low level decoding failed: sampleSize: %d bytesConsumed: %d", info.sampleSize, *bytesConsumed);
1030+
*bytesConsumed = 0;
1031+
*bytesWritten = 0;
1032+
return SCE_ERROR_ATRAC_API_FAIL; // need to check what return value we get here.
1033+
}
10281034
*bytesWritten = outSamples * channels * sizeof(int16_t);
10291035
// TODO: Possibly return a decode error on bad data.
10301036
return 0;

Core/HLE/sceAtrac.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,8 @@ static int sceAtracLowLevelDecode(int atracID, u32 sourceAddr, u32 sourceBytesCo
10801080
int bytesWritten = 0;
10811081

10821082
int retval = atrac->DecodeLowLevel(srcp, &bytesConsumed, outp, &bytesWritten);
1083+
*srcConsumed = bytesConsumed;
1084+
*outWritten = bytesWritten;
10831085

10841086
NotifyMemInfo(MemBlockFlags::WRITE, samplesAddr, bytesWritten, "AtracLowLevelDecode");
10851087
return hleDelayResult(hleLogDebug(Log::ME, retval), "low level atrac decode data", atracDecodeDelay);

Core/HLE/sceUtility.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ static const ModuleLoadInfo moduleLoadInfo[] = {
118118
ModuleLoadInfo(0x300, 0x00000000, "av_avcodec", &NotifyLoadStatusAvcodec), // AudioCodec
119119
ModuleLoadInfo(0x301, 0x00000000, "av_sascore"),
120120
// The size varies a bit per version, from about 0x3C00 to 0x4500 bytes. We could make a lookup table...
121-
ModuleLoadInfo(0x302, 0x00004000, "av_atrac3plus", atrac3PlusModuleDeps, &NotifyLoadStatusAtrac),
121+
// Changing this breaks some bad cheats though..
122+
ModuleLoadInfo(0x302, 0x00008000, "av_atrac3plus", atrac3PlusModuleDeps, &NotifyLoadStatusAtrac),
122123
ModuleLoadInfo(0x303, 0x0000c000, "av_mpegbase", mpegBaseModuleDeps),
123124
ModuleLoadInfo(0x304, 0x00004000, "av_mp3"),
124125
ModuleLoadInfo(0x305, 0x0000a300, "av_vaudio"),

0 commit comments

Comments
 (0)