mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-05 09:05:26 -04:00
d2c5614a47
This fixes crashes when first entering North Faaron cave and Renado's Sanctuary due to system heap exhaustion resulting from multiple threads allocating on the heap at once. There's some sort of weird contention going on - for some reason the game gobbles up seemingly any amount of memory you throw at it when the two threads are competing for heap space. Using a separate heap in the async thread sidesteps the issue.
93 lines
3.0 KiB
C++
93 lines
3.0 KiB
C++
#ifndef JKRDVDRIPPER_H
|
|
#define JKRDVDRIPPER_H
|
|
|
|
#include "JSystem/JKernel/JKRCompression.h"
|
|
#include "JSystem/JSupport/JSUList.h"
|
|
|
|
enum JKRExpandSwitch {
|
|
EXPAND_SWITCH_UNKNOWN0 = 0,
|
|
EXPAND_SWITCH_UNKNOWN1 = 1,
|
|
EXPAND_SWITCH_UNKNOWN2 = 2,
|
|
};
|
|
|
|
struct SYaz0Header {
|
|
u32 signature;
|
|
u32 length;
|
|
};
|
|
|
|
/**
|
|
* @ingroup jsystem-jkernel
|
|
*
|
|
*/
|
|
class JKRDMCommand {
|
|
JKRDMCommand();
|
|
~JKRDMCommand();
|
|
};
|
|
|
|
class JKRHeap;
|
|
class JKRDvdFile;
|
|
|
|
/**
|
|
* @ingroup jsystem-jkernel
|
|
*
|
|
*/
|
|
class JKRDvdRipper {
|
|
public:
|
|
static JSUList<JKRDMCommand> sDvdAsyncList;
|
|
static u32 sSZSBufferSize;
|
|
static bool errorRetry;
|
|
#if TARGET_PC
|
|
static JKRHeap* sHeap;
|
|
#endif
|
|
|
|
enum EAllocDirection {
|
|
UNKNOWN_EALLOC_DIRECTION = 0,
|
|
ALLOC_DIRECTION_FORWARD = 1,
|
|
ALLOC_DIRECTION_BACKWARD = 2,
|
|
};
|
|
|
|
static void setSZSBufferSize(u32 size) { sSZSBufferSize = size; }
|
|
|
|
static void* loadToMainRAM(char const*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
|
|
u32, JKRCompression*, u32*);
|
|
static void* loadToMainRAM(s32, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection, u32,
|
|
JKRCompression*, u32*);
|
|
static void* loadToMainRAM(JKRDvdFile*, u8*, JKRExpandSwitch, u32, JKRHeap*, EAllocDirection,
|
|
u32, JKRCompression*, u32*);
|
|
|
|
static bool isErrorRetry(void) { return errorRetry; }
|
|
inline static u32 getSZSBufferSize() { return sSZSBufferSize; }
|
|
|
|
#if TARGET_PC
|
|
static inline JKRHeap* getHeap() { return sHeap; }
|
|
static inline void setHeap(JKRHeap* i_heap) { sHeap = i_heap; }
|
|
|
|
#endif
|
|
};
|
|
|
|
// void JKRDecompressFromDVD(JKRDvdFile*, void*, u32, u32, u32, u32, u32*);
|
|
|
|
|
|
inline void* JKRDvdToMainRam(JKRDvdFile* file, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
|
|
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
|
|
u32 offset, JKRCompression* compression, u32* returnSize) {
|
|
return JKRDvdRipper::loadToMainRAM(file, dst, expandSwitch, dstLength, heap, allocDirection,
|
|
offset, compression, returnSize);
|
|
}
|
|
|
|
inline void* JKRDvdToMainRam(s32 entryNum, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
|
|
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
|
|
u32 offset, JKRCompression* compression, u32* returnSize) {
|
|
return JKRDvdRipper::loadToMainRAM(entryNum, dst, expandSwitch, dstLength, heap, allocDirection,
|
|
offset, compression, returnSize);
|
|
}
|
|
|
|
inline void* JKRDvdToMainRam(const char* name, u8* dst, JKRExpandSwitch expandSwitch, u32 dstLength,
|
|
JKRHeap* heap, JKRDvdRipper::EAllocDirection allocDirection,
|
|
u32 offset, JKRCompression* compression, u32* returnSize) {
|
|
return JKRDvdRipper::loadToMainRAM(name, dst, expandSwitch, dstLength, heap, allocDirection,
|
|
offset, compression, returnSize);
|
|
}
|
|
|
|
#endif /* JKRDVDRIPPER_H */
|