diff --git a/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp b/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp index d1e4d57f0..b0046a6ad 100644 --- a/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp +++ b/core/deps/ggpo/lib/ggpo/network/udp_proto.cpp @@ -286,14 +286,17 @@ UdpProtocol::SendMsg(UdpMsg *msg) { LogMsg("send", msg); - _packets_sent++; - _last_send_time = Platform::GetCurrentTimeMS(); - _bytes_sent += msg->PacketSize(); + { + std::lock_guard lock(_send_mutex); + _packets_sent++; + _last_send_time = Platform::GetCurrentTimeMS(); + _bytes_sent += msg->PacketSize(); - msg->hdr.magic = _magic_number; - msg->hdr.sequence_number = _next_send_seq++; + msg->hdr.magic = _magic_number; + msg->hdr.sequence_number = _next_send_seq++; - _send_queue.push(QueueEntry(Platform::GetCurrentTimeMS(), _peer_addr, msg)); + _send_queue.push(QueueEntry(Platform::GetCurrentTimeMS(), _peer_addr, msg)); + } PumpSendQueue(); } @@ -753,6 +756,7 @@ UdpProtocol::SetDisconnectNotifyStart(int timeout) void UdpProtocol::PumpSendQueue() { + std::lock_guard lock(_send_mutex); while (!_send_queue.empty()) { QueueEntry &entry = _send_queue.front(); @@ -793,6 +797,7 @@ UdpProtocol::PumpSendQueue() void UdpProtocol::ClearSendQueue() { + std::lock_guard lock(_send_mutex); while (!_send_queue.empty()) { delete _send_queue.front().msg; _send_queue.pop(); diff --git a/core/deps/ggpo/lib/ggpo/network/udp_proto.h b/core/deps/ggpo/lib/ggpo/network/udp_proto.h index 3c5f32923..00af4f8b2 100644 --- a/core/deps/ggpo/lib/ggpo/network/udp_proto.h +++ b/core/deps/ggpo/lib/ggpo/network/udp_proto.h @@ -16,6 +16,7 @@ #include "ggponet.h" #include "ring_buffer.h" #include +#include class UdpProtocol : public IPollSink { @@ -153,6 +154,7 @@ protected: UdpMsg* msg; } _oo_packet; RingBuffer _send_queue; + std::mutex _send_mutex; std::vector verification; diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index a741c36ee..ad1ef9df9 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -466,7 +466,8 @@ void rend_allow_rollback() void rend_start_rollback() { - vramRollback.Wait(); + if (config::ThreadedRendering) + vramRollback.Wait(); } void rend_serialize(void **data, unsigned int *total_size) diff --git a/core/network/ggpo.cpp b/core/network/ggpo.cpp index 0db586b19..6713f9088 100644 --- a/core/network/ggpo.cpp +++ b/core/network/ggpo.cpp @@ -159,6 +159,7 @@ struct Inputs u8 keys[6]; } u; }; +static_assert(sizeof(Inputs) == 10, "wrong Inputs size"); struct GameEvent { @@ -183,6 +184,7 @@ struct GameEvent static bool begin_game(const char *) { DEBUG_LOG(NETWORK, "Game begin"); + rend_allow_rollback(); return true; }