From 68f8400636b97c39eec9f4350f8c0db001e368f0 Mon Sep 17 00:00:00 2001 From: mightymax Date: Wed, 24 Jan 2007 18:12:05 +0000 Subject: [PATCH] fixed: select was blocking (stupid error), select is now performed less often to incerase speed --- desmume/src/wifi.c | 25 +++++++++++++++---------- desmume/src/wifi.h | 1 + 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/desmume/src/wifi.c b/desmume/src/wifi.c index f22154ec5..37320d4e1 100644 --- a/desmume/src/wifi.c +++ b/desmume/src/wifi.c @@ -580,18 +580,23 @@ void WIFI_usTrigger(wifimac_t *wifi) { WIFI_triggerIRQ(wifi,WIFI_IRQ_TIMEBEACON) ; } - /* check if data arrived in the meantime */ - rcvSize = WIFI_Host_RecvData(wifi->udpSocket,dataBuffer,0x2000) ; - if (rcvSize) + /* receive check, given a 2 mbit connection, 2 bits per usec can be transfered. /* + /* for a packet of 32 Bytes, at least 128 usec passed, we will use the 32 byte accuracy to reduce load */ + if (!(wifi->RXCheckCounter++ & 0x7F)) { - u16 i ; - /* process data, put it into mac memory */ - WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVSTART) ; - for (i=0;i<(rcvSize+1) << 1;i++) + /* check if data arrived in the meantime */ + rcvSize = WIFI_Host_RecvData(wifi->udpSocket,dataBuffer,0x2000) ; + if (rcvSize) { - WIFI_RXPutWord(wifi,((u16 *)dataBuffer)[i]) ; + u16 i ; + /* process data, put it into mac memory */ + WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVSTART) ; + for (i=0;i<(rcvSize+1) << 1;i++) + { + WIFI_RXPutWord(wifi,((u16 *)dataBuffer)[i]) ; + } + WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVCOMPLETE) ; } - WIFI_triggerIRQ(wifi,WIFI_IRQ_RECVCOMPLETE) ; } } @@ -653,7 +658,7 @@ u16 WIFI_Host_RecvData(socket_t sock, u8 *data, u16 maxLength) FD_ZERO(&dataCheck) ; FD_SET(sock,&dataCheck) ; tv.tv_sec = 0 ; - tv.tv_usec = 1 ; + tv.tv_usec = 0 ; /* check if there is data, without blocking */ if (select(1,&dataCheck,0,0,&tv)) { diff --git a/desmume/src/wifi.h b/desmume/src/wifi.h index 201629a6e..6759af007 100644 --- a/desmume/src/wifi.h +++ b/desmume/src/wifi.h @@ -375,6 +375,7 @@ typedef struct /* receiving */ u16 RXCnt ; + u16 RXCheckCounter ; /* addressing/handshaking */ union