mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-11-22 02:29:15 +01:00
Formatting and clean up
This commit is contained in:
parent
2798272513
commit
dcbf322005
@ -27,8 +27,8 @@ public:
|
||||
typedef void (*Callback)(CThread *thread, void *arg);
|
||||
|
||||
//! constructor
|
||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = NULL, void *callbackArg = NULL)
|
||||
: pThread(NULL), pThreadStack(NULL), pCallback(callback), pCallbackArg(callbackArg) {
|
||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
||||
//! save attribute assignment
|
||||
iAttributes = iAttr;
|
||||
//! allocate the thread
|
||||
@ -43,7 +43,7 @@ public:
|
||||
}
|
||||
|
||||
//! destructor
|
||||
virtual ~CThread() {
|
||||
~CThread() {
|
||||
shutdownThread();
|
||||
}
|
||||
|
||||
@ -58,36 +58,37 @@ public:
|
||||
|
||||
//! Thread entry function
|
||||
virtual void executeThread() {
|
||||
if (pCallback)
|
||||
if (pCallback) {
|
||||
pCallback(this, pCallbackArg);
|
||||
}
|
||||
}
|
||||
|
||||
//! Suspend thread
|
||||
virtual void suspendThread() {
|
||||
if (isThreadSuspended()) return;
|
||||
if (pThread) OSSuspendThread(pThread);
|
||||
if (isThreadSuspended()) { return; }
|
||||
if (pThread) { OSSuspendThread(pThread); }
|
||||
}
|
||||
|
||||
//! Resume thread
|
||||
virtual void resumeThread() {
|
||||
if (!isThreadSuspended()) return;
|
||||
if (pThread) OSResumeThread(pThread);
|
||||
void resumeThread() {
|
||||
if (!isThreadSuspended()) { return; }
|
||||
if (pThread) { OSResumeThread(pThread); }
|
||||
}
|
||||
|
||||
//! Set thread priority
|
||||
virtual void setThreadPriority(int prio) {
|
||||
if (pThread) OSSetThreadPriority(pThread, prio);
|
||||
if (pThread) { OSSetThreadPriority(pThread, prio); }
|
||||
}
|
||||
|
||||
//! Check if thread is suspended
|
||||
[[nodiscard]] virtual BOOL isThreadSuspended() const {
|
||||
if (pThread) return OSIsThreadSuspended(pThread);
|
||||
if (pThread) { return OSIsThreadSuspended(pThread); }
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Check if thread is terminated
|
||||
[[nodiscard]] virtual BOOL isThreadTerminated() const {
|
||||
if (pThread) return OSIsThreadTerminated(pThread);
|
||||
if (pThread) { return OSIsThreadTerminated(pThread); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -97,19 +98,22 @@ public:
|
||||
}
|
||||
|
||||
//! Shutdown thread
|
||||
virtual void shutdownThread() {
|
||||
void shutdownThread() {
|
||||
//! wait for thread to finish
|
||||
if (pThread && !(iAttributes & eAttributeDetach)) {
|
||||
if (isThreadSuspended())
|
||||
if (isThreadSuspended()) {
|
||||
resumeThread();
|
||||
}
|
||||
|
||||
OSJoinThread(pThread, nullptr);
|
||||
}
|
||||
//! free the thread stack buffer
|
||||
if (pThreadStack)
|
||||
if (pThreadStack) {
|
||||
free(pThreadStack);
|
||||
if (pThread)
|
||||
}
|
||||
if (pThread) {
|
||||
free(pThread);
|
||||
}
|
||||
|
||||
pThread = nullptr;
|
||||
pThreadStack = nullptr;
|
||||
|
@ -73,7 +73,6 @@ void TcpReceiver::executeThread() {
|
||||
|
||||
struct sockaddr_in clientAddr{};
|
||||
memset(&clientAddr, 0, sizeof(clientAddr));
|
||||
int32_t addrlen = sizeof(struct sockaddr);
|
||||
|
||||
while (!exitRequested) {
|
||||
len = 16;
|
||||
@ -98,9 +97,6 @@ void TcpReceiver::executeThread() {
|
||||
close(serverSocket);
|
||||
}
|
||||
|
||||
|
||||
extern bool gDoRelaunch;
|
||||
|
||||
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
||||
DEBUG_FUNCTION_LINE("Loading file from ip %08X", ipAddress);
|
||||
|
||||
@ -116,10 +112,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
||||
recvwait(clientSocket, (unsigned char *) &fileSizeUnc, sizeof(fileSizeUnc)); // Compressed protocol, read another 4 bytes
|
||||
}
|
||||
|
||||
struct in_addr in{};
|
||||
uint32_t bytesRead = 0;
|
||||
in.s_addr = ipAddress;
|
||||
|
||||
DEBUG_FUNCTION_LINE("transfer start");
|
||||
|
||||
auto *loadAddress = (unsigned char *) memalign(0x40, fileSize);
|
||||
@ -130,7 +123,6 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
||||
|
||||
// Copy rpl in memory
|
||||
while (bytesRead < fileSize) {
|
||||
|
||||
uint32_t blockSize = 0x1000;
|
||||
if (blockSize > (fileSize - bytesRead))
|
||||
blockSize = fileSize - bytesRead;
|
||||
@ -270,9 +262,6 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
||||
|
||||
if (PluginUtils::LoadAndLinkOnRestart(finalList) != 0) {
|
||||
DEBUG_FUNCTION_LINE("Failed to load & link");
|
||||
} else {
|
||||
//gDoRelaunch = true;
|
||||
//DCFlushRange(&gDoRelaunch, sizeof(gDoRelaunch));
|
||||
}
|
||||
PluginUtils::destroyPluginContainer(finalList);
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef TCP_RECEIVER_H_
|
||||
#define TCP_RECEIVER_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@ -19,13 +18,9 @@ public:
|
||||
|
||||
explicit TcpReceiver(int32_t port);
|
||||
|
||||
~TcpReceiver() override;
|
||||
|
||||
//sigslot::signal2<GuiElement *, uint32_t> serverReceiveStart;
|
||||
//sigslot::signal3<GuiElement *, uint32_t, int32_t> serverReceiveFinished;
|
||||
virtual ~TcpReceiver();
|
||||
|
||||
private:
|
||||
|
||||
void executeThread() override;
|
||||
|
||||
static int32_t loadToMemory(int32_t clientSocket, uint32_t ipAddress);
|
||||
@ -34,6 +29,3 @@ private:
|
||||
int32_t serverPort;
|
||||
int32_t serverSocket;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#include <whb/log.h>
|
||||
#include "utils/logger.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user