Double SocketAsyncEventArgs buffer length

This commit is contained in:
Travis Nickles 2020-04-06 19:28:25 -05:00
parent 082b201800
commit 40b63c9853

View File

@ -73,6 +73,7 @@ namespace DS4Windows
private SocketAsyncEventArgs[] argsList; private SocketAsyncEventArgs[] argsList;
private int listInd = 0; private int listInd = 0;
private ReaderWriterLockSlim poolLock = new ReaderWriterLockSlim(); private ReaderWriterLockSlim poolLock = new ReaderWriterLockSlim();
private const int ARG_BUFFER_LEN = 80;
public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta); public delegate void GetPadDetail(int padIdx, ref DualShockPadMeta meta);
@ -81,8 +82,8 @@ namespace DS4Windows
public UdpServer(GetPadDetail getPadDetailDel) public UdpServer(GetPadDetail getPadDetailDel)
{ {
portInfoGet = getPadDetailDel; portInfoGet = getPadDetailDel;
argsList = new SocketAsyncEventArgs[40]; argsList = new SocketAsyncEventArgs[ARG_BUFFER_LEN];
for (int num = 0; num < 40; num++) for (int num = 0; num < ARG_BUFFER_LEN; num++)
{ {
SocketAsyncEventArgs args = new SocketAsyncEventArgs(); SocketAsyncEventArgs args = new SocketAsyncEventArgs();
args.SetBuffer(new byte[100], 0, 100); args.SetBuffer(new byte[100], 0, 100);
@ -188,7 +189,7 @@ namespace DS4Windows
int temp = 0; int temp = 0;
poolLock.EnterWriteLock(); poolLock.EnterWriteLock();
temp = listInd; temp = listInd;
listInd = ++listInd % 40; listInd = ++listInd % ARG_BUFFER_LEN;
SocketAsyncEventArgs args = argsList[temp]; SocketAsyncEventArgs args = argsList[temp];
poolLock.ExitWriteLock(); poolLock.ExitWriteLock();
@ -682,7 +683,7 @@ namespace DS4Windows
int temp = 0; int temp = 0;
poolLock.EnterWriteLock(); poolLock.EnterWriteLock();
temp = listInd; temp = listInd;
listInd = ++listInd % 40; listInd = ++listInd % ARG_BUFFER_LEN;
SocketAsyncEventArgs args = argsList[temp]; SocketAsyncEventArgs args = argsList[temp];
poolLock.ExitWriteLock(); poolLock.ExitWriteLock();