AMMediaboard: Improve recv/send log messages

This commit is contained in:
Sepalani 2026-02-19 18:27:23 +04:00
parent 2eeff845bd
commit 543d5f89e6

View File

@ -961,10 +961,25 @@ static void AMMBCommandRecv(u32 parameter_offset, u32 network_buffer_base)
len = 0;
}
// TODO: Might be blocking depending on the timeout (see SetTimeouts command).
const int ret = recv(fd, reinterpret_cast<char*>(s_network_buffer.data() + off), len, 0);
const int err = WSAGetLastError();
DEBUG_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: recv( {}, 0x{:08x}, {} ):{} {}", fd, off, len, ret, err);
if (ret < 0 && err != WSAEWOULDBLOCK)
{
ERROR_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: recv( {}, 0x{:08x}, {} ) failed with error {}: {}", fd,
off, len, err, Common::DecodeNetworkError(err));
}
else if (ret == 0)
{
INFO_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: recv( {}, 0x{:08x}, {} ):0 shutdown received", fd, off,
len);
}
else
{
DEBUG_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: recv( {}, 0x{:08x}, {} ):{} {}", fd, off, len, ret,
err);
}
s_media_buffer[1] = s_media_buffer[8];
s_media_buffer_32[1] = ret;
@ -990,11 +1005,20 @@ static void AMMBCommandSend(u32 parameter_offset, u32 network_buffer_base)
len = 0;
}
// TODO: Might be blocking depending on the timeout (see SetTimeouts command).
const int ret = send(fd, reinterpret_cast<char*>(s_network_buffer.data() + off), len, SEND_FLAGS);
const int err = WSAGetLastError();
DEBUG_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: send( {}({}), 0x{:08x}, {} ): {} {}", fd,
u32(guest_socket), off, len, ret, err);
if (ret < 0 && err != WSAEWOULDBLOCK)
{
ERROR_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: send( {}({}), 0x{:08x}, {} ) failed with error {}: {}",
fd, u32(guest_socket), off, len, err, Common::DecodeNetworkError(err));
}
else
{
DEBUG_LOG_FMT(AMMEDIABOARD_NET, "GC-AM: send( {}({}), 0x{:08x}, {} ): {} {}", fd,
u32(guest_socket), off, len, ret, err);
}
s_media_buffer[1] = s_media_buffer[8];
s_media_buffer_32[1] = ret;