Commit Graph
100 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 124b0a43ae sceMp3: point the game at the end of the buffered data, not the start
sceMp3GetInfoToAddStreamData always handed back the start of the work
area, so the pointer never moved as data was added - the hardware walks
it forward past what's already buffered. AuNotifyAddStreamData now
takes the new bytes from where the game was actually told to write, and
checks that range fits the buffer rather than just comparing the size.

Also compare readPos against endPos as signed. readPos is an int and a
game can notify a negative size, which made it promote to a huge u64
and look like the end of the stream, so we reported nothing left to
write where the hardware still wanted 6721 bytes.

Fixes audio/mp3/infotoadd, moved to tests_good. audio/mp3/notifyadd
gets both of its value differences fixed but still fails: after a
decode the hardware reports no space at all, while we free what the
decode consumed, so we do one round more than it does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvJR8oJNSCimCM9KXVLjfq
2026-09-05 13:50:49 -06:00
Henrik Rydgård c5e4d0d90d Rename the get-memory-pointer functions to make it clear where CPU exceptions can happen. 2026-08-12 14:06:16 +02:00
Henrik Rydgård bfbe44ad1c SimpleAudioDec: fix unsigned underflow and unvalidated stream-data size
FindNextMp3Sync() computed `sourcebuff.size() - 2` as the loop bound;
when size() is 0 or 1 this underflows to a huge size_t, turning the
scan into an out-of-bounds read. Reachable via sceMp3NotifyAddStreamData
followed by sceMp3Decode with as little as 1 pending byte.

AuNotifyAddStreamData() trusted the game-supplied `size` outright: a
negative value would make sourcebuff.resize() attempt a huge
allocation (via size_t underflow), an unbounded positive value grows
sourcebuff without limit, and the validated range didn't match the
actual read range (checked [AuBuf, AuBuf+size) while reading from
[AuBuf+offset, AuBuf+offset+size)). Validate size is positive and
capped to the buffer's declared capacity, and validate the range
actually read.
2026-08-12 09:43:23 +02:00
Henrik Rydgård 0596ee97f6 More memory access cleanup 2026-08-11 20:14:01 +02:00
Henrik Rydgård c932c632a6 Add some sanity checks in SimpleAudioDec to avoid crashes 2025-12-30 20:31:06 +01:00
oltolm 122eddfe0f ffmpeg: update API for ffmpeg 8 2025-11-05 19:11:32 +01:00
Henrik Rydgård 6fe537df55 Revert to using FFMPEG as decoding backend for sceMp3 again, instead of minimp3. 2025-04-14 22:38:25 +02:00
Henrik Rydgård 52a7709fb5 Log cleanup. Fix very minor memory leak 2025-04-14 22:38:22 +02:00
Henrik Rydgård 200edfaa96 Add a developer setting to force using FFMPEG for audio decoding. 2025-04-12 11:35:55 +02:00
Henrik Rydgård f7ff2e2d20 Remove redundant constants 2025-04-12 11:35:55 +02:00
Henrik Rydgård f9cc797328 Fix MP3 mono playback 2025-04-11 13:12:28 +02:00
oltolm 9566065455 make compile on mingw-w64 2025-01-11 01:25:27 +01:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård 091535744b SimpleAudioDec: Fix crash in savestate load 2024-07-20 00:00:29 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 1b366afa35 Refactor: Change *outBytes to *outSamples in AudioDecoder::Decode. 2024-04-16 15:31:11 +02:00
Henrik Rydgård d402068745 Fix mono output from Atrac decoders. (sceAtrac*MOut* functions) 2024-04-15 11:50:32 +02:00
Henrik Rydgård effae82208 sceAtrac: Do some renaming to make things make more sense 2024-04-13 10:35:39 +02:00
Henrik Rydgård c2bcdd3076 Buildfix with system ffmpeg 2024-04-12 16:45:45 +02:00
Henrik Rydgård 5ed77b58ca Improve the AudioDecoder API to avoid having to call a function to get the bytes consumed 2024-04-11 16:49:00 +02:00
Henrik Rydgård bf280eb410 Remove "SetExtraData" from AudioDecoder, pass in the data at creation instead 2024-04-11 14:39:59 +02:00
Henrik Rydgård c6c67695b1 Hook up ATRAC3 too 2024-04-11 14:39:59 +02:00
Henrik Rydgård c902973688 Setup more of the setup 2024-04-11 14:39:59 +02:00
Henrik Rydgård 8d4716cab6 WIP: Add AT3/AT3plus files, get it to compile (though will fail to link if we use it) 2024-04-11 14:39:59 +02:00
Henrik Rydgård db929ea042 Use minimp3 for in-game mp3 decoding. Doesn't solve any issues it seems, but works like before. 2024-04-11 14:19:22 +02:00
Henrik Rydgård 3de85c8d14 Remove more unnecessary accessors 2024-04-11 14:18:07 +02:00
Henrik Rydgård 5b3be0d720 Update USE_FFMPEG checks 2024-04-10 18:40:02 +02:00
Henrik Rydgård 8adca6492c Move class SimpleAudio into the cpp file 2024-04-10 13:03:19 +02:00
Henrik Rydgård 1805910fac More refactoring 2024-04-10 12:22:58 +02:00
Henrik Rydgård 1938d3b876 More prep for plugging in alternate audio decoders 2024-04-10 12:14:58 +02:00
Henrik Rydgård 32ca7ab59a Minor code cleanups 2024-04-10 12:07:03 +02:00
Henrik Rydgård 88eb2c2e0b Add a virtual base class so we can implement alternative decoders 2024-04-10 00:45:02 +02:00
Henrik Rydgård ddbe0e853b Remove unused code 2024-04-10 00:40:16 +02:00
Andrew Udvare 930b7f644d ffmpeg: Improved fix for checking if const AVCodec* is necessary 2024-02-05 14:37:09 -05:00
Andrew Udvare 402f9acb5e Fix compilation with newer ffmpeg versions 2024-01-13 00:12:21 -05:00
Henrik Rydgård 0a13c78788 Revert "ffmpeg: Don't ask for multi-threaded decoding"
This reverts commit b173e0f4a4.

Turns out it's not actually known to fix anything, should have closed
that old PR.
2023-01-12 16:23:39 +01:00
Henrik Rydgård b173e0f4a4 ffmpeg: Don't ask for multi-threaded decoding
For whatever reason, our version of ffmpeg has problems with it,
and I don't care enough to dig deep.

See PR #13806
2023-01-12 12:13:10 +01:00
Unknown W. Brackets c44d787df4 Mpeg: Check memory access range on GetPointer(). 2023-01-09 16:53:10 -08:00
Unknown W. Brackets a7b7bf7826 Global: Set many read-only params as const.
This makes what they do and which args to use clearer, if nothing else.
2022-12-10 21:13:36 -08:00
Henrik Rydgård e6403d7157 Split GetPointer into two versions, to help with const correctness 2022-07-24 13:26:19 +02:00
Unknown W. Brackets d45fe93588 Mp3: Output PCM data using even/odd buffer slot.
This makes sense since the audio APIs are all async.
2022-01-27 00:22:44 -08:00
Unknown W. Brackets 914d022eef Mp3: Allow decode with NULL out pointer. 2022-01-27 00:22:44 -08:00
Unknown W. Brackets 4903e14aae Mp3: Cleanup AuCtx constructor. 2022-01-27 00:22:43 -08:00
Henrik Rydgård 2f3bc2d373 Merge pull request #14056 from unknownbrackets/debugger-mem
Track memory allocations and writes for debug info
2021-02-21 10:18:11 +01:00
Unknown W. Brackets b19e39efb0 Audiocodec: Update to latest FFmpeg packet pump. 2021-02-18 00:20:27 -08:00
Unknown W. Brackets 2362d71d70 Mpeg: Remove deprecated codec register calls. 2021-02-18 00:20:27 -08:00
Unknown W. Brackets f7740edc6d Debugger: Add more metadata for memory usage. 2021-02-15 15:01:21 -08:00
Unknown W. Brackets 463fc3c792 Mp3: Allow decode without pcm pointer.
Just like other audio decoding, you're allowed to skip audio.
Also prevents a crash if the mp3 is not yet inited.
2021-01-25 23:51:55 -08:00
sum2012 942ce775cc Fix AuCheckStreamDataNeeded function
fix #13633
2020-11-08 22:47:32 +08:00
Unknown W. Brackets b8342fb8ec SaveState: Rename ChunkFile files to Serialize.
Makes more sense and less weird than ChunkFileDoMap, etc.
2020-08-10 08:04:05 +00:00