Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Lyoko audio softlock (now: bad playback) #19994

Open
5 tasks done
Xibancry opened this issue Feb 17, 2025 · 25 comments
Open
5 tasks done

Code Lyoko audio softlock (now: bad playback) #19994

Xibancry opened this issue Feb 17, 2025 · 25 comments
Labels
Atrac3+ Issue involves sceAtrac features.
Milestone

Comments

@Xibancry
Copy link

Game or games this happens in

ULES-01095 - Code Lyoko: Quest for Infinity

What area of the game / PPSSPP

Many areas affected. Only when some voice audio tracks play. The text box showing dialogue appears but it fails to play the voice audio preventing it from closing and effectively softlocking the game everytime it happens (this is apparently consistent with some dialogues). Only solution around it is to reset the game.

Adding a savefile previous to softlock. Softlock occurs on the third dialogue just after defeating the first enemy in the level.

ULES01095DATA00.zip

What should happen

The game should play the dialogue normally without preventing the dialogue box from closing and not softlocking the game.

Logs

ppsspplog.txt

Platform

Windows

Mobile device model or graphics card (GPU)

RTX 2080 Super

PPSSPP version affected

v1.18.1 - 0f50225

Last working version

v1.16.6

Graphics backend (3D API)

Direct3D 11

Checklist

  • Test in the latest git build in case it's already fixed.
  • Search for other reports of the same issue.
  • Try resetting settings or older versions and include if the issue is related.
  • Try without any cheats and without loading any save states.
  • Include logs or screenshots of issue.
@sum2012
Copy link
Collaborator

sum2012 commented Feb 17, 2025

@Xibancry
"Sector 5" or "Deseat sector" lock up ?
edit: should be "Sector 5"

@Xibancry
Copy link
Author

Yes, it's on sector 5 for the savefile I sent. It's not the only place it happens

@sum2012
Copy link
Collaborator

sum2012 commented Feb 17, 2025

Media log easier to check
https://gist.githubusercontent.com/sum2012/de3af54e161e8eacb48086b34315397f/raw/17207eac434bdb4fee0ab0cfb2b688f2543a19fb/gistfile1.txt

18:26:659 ATRAC3 Load D[ME]: HLE\AtracCtx.cpp:235 ATRAC analyzed: AT3Plus channels: 2 filesize: 70164 bitrate: 94 kbps jointStereo: 0
18:26:659 ATRAC3 Load D[ME]: HLE\AtracCtx.cpp:236 dataoff: 164 firstSampleOffset: 4011 endSample: 251620
18:26:659 ATRAC3 Load D[ME]: HLE\AtracCtx.cpp:237 loopStartSample: 4379 loopEndSample: 255999
18:26:659 ATRAC3 Load I[ME]: HLE\AtracCtx.cpp:699 0=sceAtracSetDataAndGetID(08a5c340, 00000800): atrac3+ stereo audio
18:26:659 ATRAC3 Load D[ME]: HLE\sceAtrac.cpp:702 00000000=sceAtracSetLoopNum(0, -1)
18:26:659 ATRAC3 Load D[ME]: HLE\sceAtrac.cpp:463 00000000=sceAtracGetRemainFrame(0, 08a5c1dc[00000002])
18:26:677 ATRAC3 play D[ME]: HLE\sceAtrac.cpp:281 00000000=sceAtracDecodeData(0, 08a7c380, 09fb7aa8[000006e5], 09fb7aac[00000000], 09fb7abc[1])
18:26:693 ATRAC3 play D[ME]: HLE\sceAtrac.cpp:532 00000000=sceAtracGetStreamDataInfo(0, 09fb7ab8[08a5c40c], 09fb7ab4[00000438], 09fb7ab0[00000800])
18:26:693 ATRAC3 play E[ME]: at3_standalone\compat.cpp:19 Atrac3/3+: Frame data doesn't match channel configuration!
18:26:693 ATRAC3 play D[ME]: HLE\sceAtrac.cpp:281 80630024=sceAtracDecodeData(0, 08a7df14, 09fb7aa8[00000000], 09fb7aac[00000001], 09fb7abc[0])
18:26:693 ATRAC3 play E[ME]: HLE\sceAtrac.cpp:382 UNIMPL sceAtracGetInternalErrorInfo(0, 09fb7aa4)
18:26:694 ATRAC3 play D[ME]: HLE\sceAtrac.cpp:253 00000000=sceAtracAddStreamData(0, 00000438)
18:26:694 ATRAC3 play D[ME]: HLE\sceAtrac.cpp:463 00000000=sceAtracGetRemainFrame(0, 09fb7abc[00000003])

ATRAC3 related

@sum2012 sum2012 added the Atrac3+ Issue involves sceAtrac features. label Feb 17, 2025
@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

Even v1.16.6 don't softlock, the voice has some problem

@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

v1.17.1-264 good
v1.17.1-268 bad
It mean #19053

@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

git bisect result: a1ac79c

@hrydgard
Copy link
Owner

Thank you for the bisect, not surprising, it's when we switched the decoder to not use ffmpeg.

I think this is another case of not detecting mono properly, so the decoder tries to parse it as stereo and fails. Will need to figure out how it worked before..

@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

@hrydgard Before it cannot decode mono correctly , but it do not have error .

@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

@hrydgard I have a idea. For streamed ATRAC3+ , I think that we do not change track_.channels , so it assume stereo.
edit: No, 8:26:659 ATRAC3 Load I[ME]: HLE\AtracCtx.cpp:699 0=sceAtracSetDataAndGetID(08a5c340, 00000800): atrac3+ stereo audio So it detect wrong the atrac as stereo not mono early ?

@sum2012
Copy link
Collaborator

sum2012 commented Feb 18, 2025

Force to change to mono still fail.

		if (!decoder_->Decode(indata, track_.bytesPerFrame, &bytesConsumed, outputChannels_, (int16_t*)outbuf, &outSamples)) {
			track_.channels = 1;
			if (!decoder_->Decode(indata, track_.bytesPerFrame, &bytesConsumed, outputChannels_, (int16_t*)outbuf, &outSamples)) {			
			// Decode failed.
			*SamplesNum = 0;
			*finish = 1;
			return ATRAC_ERROR_ALL_DATA_DECODED;
			}
		}

@sum2012
Copy link
Collaborator

sum2012 commented Feb 19, 2025

Ignore decode error can work around....Before v1.19 release make the hack ?

@hrydgard
Copy link
Owner

If we can't fix it, yeah.

@hrydgard hrydgard added this to the v1.19.0 milestone Feb 19, 2025
hrydgard added a commit that referenced this issue Feb 19, 2025
Now we don't generate an error code when the channel configuration doesn't match the packets.

See the code comment for what I've been able to figure out so far.

See issue #19994
@hrydgard
Copy link
Owner

#20005 will probably work as a workaround, but I don't think it'll fix broken audio.. Something is really going wrong in decoding here.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 19, 2025

#20005 work as a workaround
Jpcsp emulator play the voice correctly
PPSSPP never play the voice correctly

@sum2012
Copy link
Collaborator

sum2012 commented Feb 19, 2025

Jpcsp emulator log
https://gist.githubusercontent.com/sum2012/77328a1337e7dd96b2252bba4e7c4dd2/raw/52b997c6216503e05bbb0dbb31bb5d469a90d80d/gistfile1.txt

edit:
#20005 Warn log this two times , then it can play the bad voice
53:30:276 ATRAC3 play W[ME]: at3_standalone\compat.cpp:23 Atrac3/3+: Frame data doesn't match channel configuration! ch_block 1 >= num_channel_blocks 1,

From JPCSP emulator log, channels=2 all the times

@hrydgard
Copy link
Owner

Hm. Might have to dig into how JPCSP handles this then... Thanks for letting me know.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 19, 2025

Can you code (logging) the data of the "data chunk" in PPSPPP so that I can compare it in JPCSP emulator ?

5:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - sceAtracSetDataAndGetID buffer=0x08A5C340, bufferSize=0x800
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - FileSize 0xA5BE4
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - WAVE format: magic=0x20746D66('fmt '), chunkSize=52, compressionCode=0xFFFE, channels=2, sampleRate=44100, bitrate=12058, bytesPerFrame=0x230, hiBytesPerSample=0, codingMode=0
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - Additional chunk data: 22 00 00 08 03 00 00 00 BF AA 23 E9 58 CB 71 44 A1 19 FF FA 01 E4 CE 62 01 00 28 45 00 00 00 00 00 00 00 00
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - FACT Chunk: chunkSize=8, endSample=0x25D391, sampleOffset=0xAFE
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - Loop #0: LoopInfo[cuePointID 0, type 0, startSample 0x0, endSample 0x25D391, fraction 0, playCount 0]
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - DATA Chunk: data offset=0xA4, data size=0xA5B40
05:05:40 DEBUG hle.sceAtrac3plus - ATRAC3 Load thread - hleSetHalfwayBufferAndGetID returning atID=0x0

@anr2me
Copy link
Collaborator

anr2me commented Feb 20, 2025

I don't know this code https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/AtracCtx.cpp#L361 Why break after "}" ? Same with https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/AtracCtx.cpp#L373 https://github.com/hrydgard/ppsspp/blob/master/Core/HLE/AtracCtx.cpp#L404

Probably because you can get compilation error when declaring and initializing a variable inside case without {}

@hrydgard
Copy link
Owner

It's nicer to have the break inside the {} of the case, but it doesn't really matter.

I'll look into this more in a little while.

@hrydgard
Copy link
Owner

Hm, jpcsp seems to handle the channel blocks exactly the same:

https://github.com/jpcsp/jpcsp/blob/cd20cf312b358b4260f26f6754f9c62926c70ba6/src/jpcsp/media/codec/atrac3plus/Atrac3plusDecoder.java#L96

Wonder what is different..

@sum2012
Copy link
Collaborator

sum2012 commented Feb 21, 2025

edit last: I know what is the problem

sum2012 added a commit to sum2012/ppsspp that referenced this issue Feb 21, 2025
Easy to compare JPCSP emulator log. Debugging in hrydgard#19994
@hrydgard
Copy link
Owner

So what is it? :)

I merged your logging change.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 21, 2025

Updated PPSSPP log:
https://gist.github.com/sum2012/355e85c0347ccdacadf8a249018796e0
Our code of "Additional chunk data" is match JPCSP emulator.

@sum2012
Copy link
Collaborator

sum2012 commented Feb 22, 2025

After update source, debug build (VS2022):
34:41:289 ATRAC3 play E[HLE]: HLE\HLE.cpp:992 HLE function stack mismatch (D:\project\9\ppsspp\Core\HLE\sceAtrac.cpp:253)! stackSize = 0

@hrydgard hrydgard modified the milestones: v1.19.0, v1.20 Feb 25, 2025
@hrydgard hrydgard changed the title Code Lyoko audio softlock Code Lyoko audio softlock (now: bad playback) Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Atrac3+ Issue involves sceAtrac features.
Projects
None yet
Development

No branches or pull requests

4 participants