Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10043/client_libs/libplayerc
Modified Files:
client.c playerc.h
Log Message:
changed default server mode to pull with replacement
Index: client.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/client.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** client.c 1 Nov 2007 22:16:16 -0000 1.84
--- client.c 2 Nov 2007 02:41:11 -0000 1.85
***************
*** 63,66 ****
--- 63,67 ----
#include <errno.h>
#include <sys/time.h>
+ #include <time.h>
#include <unistd.h>
#include <fcntl.h>
***************
*** 168,172 ****
/* this is the server's default */
! client->mode = PLAYER_DATAMODE_PUSH;
client->transport = PLAYERC_TRANSPORT_TCP;
--- 169,173 ----
/* this is the server's default */
! client->mode = PLAYER_DATAMODE_PULL;
client->transport = PLAYERC_TRANSPORT_TCP;
***************
*** 388,391 ****
--- 389,396 ----
int i;
int j;
+ struct timespec sleeptime;
+
+ sleeptime.tv_sec = client->retry_time;
+ sleeptime.tv_nsec = 0;
/* Disconnect */
***************
*** 432,437 ****
}
! puts("sleeping");
! usleep((uint32_t)rint(client->retry_time * 1e6));
}
--- 437,441 ----
}
! nanosleep(&sleeptime,NULL);
}
***************
*** 556,562 ****
void *playerc_client_read(playerc_client_t *client)
{
player_msghdr_t header;
! // If we're in a PULL mode, first request a round of data.
if (client->mode == PLAYER_DATAMODE_PULL)
{
--- 560,585 ----
void *playerc_client_read(playerc_client_t *client)
{
+ void* ret;
+ // 10ms delay
+ struct timespec sleeptime = {0,10000000};
+
+ for(;;)
+ {
+ ret = playerc_client_read_nonblock(client);
+ if(ret != NULL)
+ break;
+ nanosleep(&sleeptime,NULL);
+ }
+
+ return(ret);
+ }
+
+ // Read and process a packet (nonblocking)
+ void *playerc_client_read_nonblock(playerc_client_t *client)
+ {
player_msghdr_t header;
+ int got_data=0;
! // If we're in a PULL mode, first request a round of data.
if (client->mode == PLAYER_DATAMODE_PULL)
{
***************
*** 564,567 ****
--- 587,596 ----
return NULL;
}
+ // Otherwise, peek at the socket
+ else
+ {
+ if(playerc_client_peek(client,0) <= 0)
+ return NULL;
+ }
while (true)
***************
*** 580,584 ****
break;
case PLAYER_MSGTYPE_SYNCH:
! return client->id;
case PLAYER_MSGTYPE_DATA:
client->lasttime = client->datatime;
--- 609,616 ----
break;
case PLAYER_MSGTYPE_SYNCH:
! if(!got_data)
! return NULL;
! else
! return client->id;
case PLAYER_MSGTYPE_DATA:
client->lasttime = client->datatime;
***************
*** 598,601 ****
--- 630,634 ----
if (result == NULL)
return NULL;
+ got_data = 1;
continue;
}
Index: playerc.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/playerc.h,v
retrieving revision 1.237
retrieving revision 1.238
diff -C2 -d -r1.237 -r1.238
*** playerc.h 1 Nov 2007 22:16:16 -0000 1.237
--- playerc.h 2 Nov 2007 02:41:11 -0000 1.238
***************
*** 702,705 ****
--- 702,707 ----
void *playerc_client_read(playerc_client_t *client);
+ // Read and process a packet (nonblocking)
+ void *playerc_client_read_nonblock(playerc_client_t *client);
/** @brief Set the timeout for client requests.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit