Stability/Bug fixes; wxWidgets, compression
This commit is contained in:
parent
bef72f8e4a
commit
97f1ae087e
@ -37,7 +37,8 @@ namespace Aurora::Compression
|
||||
|
||||
struct DecompressInfo
|
||||
{
|
||||
ECompresionType alg;
|
||||
AuUInt32 internalStreamSize;
|
||||
ECompresionType alg {ECompresionType::eDeflate};
|
||||
AuUInt32 internalStreamSize {};
|
||||
bool permitResize {};
|
||||
};
|
||||
}
|
@ -14,9 +14,6 @@ namespace Aurora::Compression
|
||||
public:
|
||||
virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 bytesFromUnprocessedInputSource) = 0;
|
||||
|
||||
// You should probably check this if you don't want to be DDoS'd
|
||||
virtual AuUInt32 GetInternalBufferSize() = 0;
|
||||
|
||||
// Limited stream API
|
||||
virtual bool ReadByProcessedN (void * /*opt*/, AuUInt32 minimumProcessed, AuStreamReadWrittenPair_t &pair, bool ingestUntilEOS = true) = 0;
|
||||
virtual bool ReadByProcessedN (void * /*opt*/, AuUInt32 minimumInflated) = 0;
|
||||
|
@ -81,6 +81,7 @@ namespace Aurora::Compression
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
auto remaining = length - written;
|
||||
written = this->_outbuffer.Write(reinterpret_cast<const AuUInt8 *>(a) + written,
|
||||
remaining);
|
||||
@ -101,9 +102,8 @@ namespace Aurora::Compression
|
||||
class ZSTDInflate : public BaseStream
|
||||
{
|
||||
public:
|
||||
AuUInt32 bufferSize;
|
||||
|
||||
ZSTDInflate(AuUInt32 bufferSize) : bufferSize(bufferSize), BaseStream(bufferSize)
|
||||
DecompressInfo meta;
|
||||
ZSTDInflate(const DecompressInfo &meta) : meta(meta), BaseStream(meta.internalStreamSize)
|
||||
{}
|
||||
|
||||
~ZSTDInflate()
|
||||
@ -181,9 +181,9 @@ namespace Aurora::Compression
|
||||
class ZIPInflate : public BaseStream
|
||||
{
|
||||
public:
|
||||
AuUInt32 bufferSize;
|
||||
DecompressInfo meta;
|
||||
|
||||
ZIPInflate(AuUInt32 bufferSize) : bufferSize(bufferSize), BaseStream(bufferSize)
|
||||
ZIPInflate(const DecompressInfo &meta) : meta(meta), BaseStream(meta.internalStreamSize)
|
||||
{}
|
||||
|
||||
~ZIPInflate()
|
||||
@ -272,9 +272,9 @@ namespace Aurora::Compression
|
||||
class BZIPInflate : public BaseStream
|
||||
{
|
||||
public:
|
||||
AuUInt32 bufferSize;
|
||||
DecompressInfo meta;
|
||||
|
||||
BZIPInflate(AuUInt32 bufferSize) : bufferSize(bufferSize), BaseStream(bufferSize)
|
||||
BZIPInflate(const DecompressInfo &meta) : meta(meta), BaseStream(meta.internalStreamSize)
|
||||
{}
|
||||
|
||||
~BZIPInflate()
|
||||
@ -358,9 +358,9 @@ namespace Aurora::Compression
|
||||
{
|
||||
public:
|
||||
|
||||
AuUInt32 bufferSize;
|
||||
DecompressInfo meta;
|
||||
|
||||
LZ4Inflate(AuUInt32 bufferSize) : bufferSize(bufferSize), BaseStream(bufferSize / 2)
|
||||
LZ4Inflate(const DecompressInfo &meta) : meta(meta), BaseStream(meta.internalStreamSize)
|
||||
{}
|
||||
|
||||
~LZ4Inflate()
|
||||
@ -393,8 +393,10 @@ namespace Aurora::Compression
|
||||
size_t bytesRemInFrame {};
|
||||
LZ4F_decompressOptions_t opts {};
|
||||
|
||||
auto bufferIn = AuSPtr<char>(new char[bufferSize / 2], std::default_delete<char[]>());
|
||||
auto bufferOut = AuSPtr<char>(new char[bufferSize / 2], std::default_delete<char[]>());
|
||||
auto bufferSize = meta.internalStreamSize / 2;
|
||||
|
||||
auto bufferIn = AuSPtr<char>(new char[bufferSize], std::default_delete<char[]>());
|
||||
auto bufferOut = AuSPtr<char>(new char[bufferSize], std::default_delete<char[]>());
|
||||
|
||||
while (inputStat < input)
|
||||
{
|
||||
@ -424,7 +426,7 @@ namespace Aurora::Compression
|
||||
{
|
||||
auto mustConsume = frameSize;
|
||||
size_t frameSPtr = mustConsume;
|
||||
size_t frameS2Ptr = bufferSize / 2;
|
||||
size_t frameS2Ptr = bufferSize;
|
||||
|
||||
bytesRemInFrame = LZ4F_decompress(lz4Stream_, bufferOut.get(), &frameS2Ptr, bufferIn.get(), &frameSPtr, &opts);
|
||||
if (LZ4F_isError(bytesRemInFrame))
|
||||
@ -474,16 +476,16 @@ namespace Aurora::Compression
|
||||
switch (info.alg)
|
||||
{
|
||||
case ECompresionType::eZSTD:
|
||||
ret = new ZSTDInflate(info.internalStreamSize);
|
||||
ret = new ZSTDInflate(info);
|
||||
break;
|
||||
case ECompresionType::eBZIP2:
|
||||
ret = new BZIPInflate(info.internalStreamSize);
|
||||
ret = new BZIPInflate(info);
|
||||
break;
|
||||
case ECompresionType::eLZ4:
|
||||
ret = new LZ4Inflate(info.internalStreamSize);
|
||||
ret = new LZ4Inflate(info);
|
||||
break;
|
||||
case ECompresionType::eDeflate:
|
||||
ret = new ZIPInflate(info.internalStreamSize);
|
||||
ret = new ZIPInflate(info);
|
||||
break;
|
||||
default:
|
||||
ret = nullptr;
|
||||
|
@ -22,7 +22,9 @@ namespace Aurora::Compression
|
||||
virtual bool ReadByProcessedN(void * /*opt*/, AuUInt32 minimumInflated, AuStreamReadWrittenPair_t &pair, bool ingestUntilEOS = true) override;
|
||||
virtual bool GoBackByProcessedN(AuUInt32 offset) override;
|
||||
virtual bool GoForwardByProcessedN(AuUInt32 offset) override;
|
||||
virtual AuUInt32 GetInternalBufferSize() override;
|
||||
|
||||
/// @deprecated
|
||||
virtual AuUInt32 GetInternalBufferSize();
|
||||
|
||||
bool Write(const void *a, AuUInt32 length);
|
||||
|
||||
|
@ -692,22 +692,27 @@ namespace Aurora::Console::ConsoleWxWidgets
|
||||
|
||||
void WxWidgetsRequestExit()
|
||||
{
|
||||
gMutex.reset();
|
||||
|
||||
if (!gWxConsoleReady)
|
||||
{
|
||||
gMutex.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
gMutex->Lock();
|
||||
gWxConsoleReady = false;
|
||||
gMutex->Unlock();
|
||||
|
||||
auto window = wxTheApp->GetTopWindow();
|
||||
if (!window)
|
||||
{
|
||||
gMutex.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
window->GetEventHandler()->CallAfter([]()
|
||||
{
|
||||
wxTheApp->Exit();
|
||||
gMutex.reset();
|
||||
});
|
||||
|
||||
}
|
||||
@ -741,18 +746,27 @@ namespace Aurora::Console::ConsoleWxWidgets
|
||||
Start();
|
||||
}
|
||||
|
||||
class ConsoleMessageSubscriber : public Aurora::Console::Hooks::IConsoleSubscriber
|
||||
{
|
||||
public:
|
||||
void OnMessage(const ConsoleMessage &string) override;
|
||||
};
|
||||
|
||||
void ConsoleMessageSubscriber::OnMessage(const ConsoleMessage &string)
|
||||
{
|
||||
AU_LOCK_GUARD(gMutex);
|
||||
gPendingLines.push_back(string);
|
||||
}
|
||||
|
||||
static ConsoleMessageSubscriber gConsoleMessageSubscriber;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (std::exchange(gConsoleStarted, true)) return;
|
||||
|
||||
gMutex = Aurora::Threading::Primitives::MutexUnique();
|
||||
|
||||
Aurora::Console::Hooks::AddFunctionalHook([&](const Aurora::Console::ConsoleMessage &string) -> void
|
||||
{
|
||||
gMutex->Lock();
|
||||
gPendingLines.push_back(string);
|
||||
gMutex->Unlock();
|
||||
});
|
||||
Aurora::Console::Hooks::AddSubscription(AuUnsafeRaiiToShared(&gConsoleMessageSubscriber));
|
||||
|
||||
Aurora::Threading::Threads::AbstractThreadVectors handler;
|
||||
handler.DoRun = [](Aurora::Threading::Threads::IAuroraThread *)
|
||||
@ -798,6 +812,8 @@ namespace Aurora::Console::ConsoleWxWidgets
|
||||
{
|
||||
WxWidgetsRequestExit();
|
||||
|
||||
Aurora::Console::Hooks::RemoveSubscription(AuUnsafeRaiiToShared(&gConsoleMessageSubscriber));
|
||||
|
||||
gWxWidgetsThread.reset();
|
||||
|
||||
auto wxHandle = wxTheApp;
|
||||
|
Loading…
Reference in New Issue
Block a user