Update of /cvsroot/playerstage/code/player/client_libs/libplayerc
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10759/client_libs/libplayerc

Modified Files:
        client.c mclient.c 
Log Message:
fixed push/pull, and vfh

Index: mclient.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/mclient.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** mclient.c   2 Nov 2007 18:09:20 -0000       1.9
--- mclient.c   7 Dec 2007 01:50:14 -0000       1.10
***************
*** 133,143 ****
      mclient->pollfd[i].events = POLLIN;
      mclient->pollfd[i].revents = 0;
!     // If the client is in a PULL mode, first request a round of data.
!     if(mclient->client[i]->mode == PLAYER_DATAMODE_PULL)
      {
        if(playerc_client_requestdata(mclient->client[i]) < 0)
-       {
          PLAYERC_ERR("playerc_client_requestdata errored");
-       }
      }
    }
--- 133,141 ----
      mclient->pollfd[i].events = POLLIN;
      mclient->pollfd[i].revents = 0;
!     if(!mclient->client[i]->qlen)
      {
+       // In case the client is in a PULL mode, first request a round of data.
        if(playerc_client_requestdata(mclient->client[i]) < 0)
          PLAYERC_ERR("playerc_client_requestdata errored");
      }
    }
***************
*** 152,158 ****
  
    // Now read from each of the waiting sockets 
    for (i = 0; i < mclient->client_count; i++)
    {
!     if ((mclient->pollfd[i].revents & POLLIN) > 0)
      {
        if(playerc_client_read_nonblock(mclient->client[i]))
--- 150,158 ----
  
    // Now read from each of the waiting sockets 
+   count = 0;
    for (i = 0; i < mclient->client_count; i++)
    {
!     if(mclient->client[i]->qlen ||
!        (mclient->pollfd[i].revents & POLLIN) > 0)
      {
        if(playerc_client_read_nonblock(mclient->client[i]))
***************
*** 161,164 ****
--- 161,165 ----
          if(mclient->client[i]->datatime > mclient->time)
            mclient->time = mclient->client[i]->datatime;
+         count++;
        }
        else

Index: client.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/client_libs/libplayerc/client.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** client.c    3 Dec 2007 01:31:14 -0000       1.90
--- client.c    7 Dec 2007 01:50:14 -0000       1.91
***************
*** 78,82 ****
  void dummy(int sig)
  {
-   printf("got %d\n", sig);
  }
  
--- 78,81 ----
***************
*** 323,330 ****
    }
  
-   puts("calling connect");
    ret = connect(client->sock, (struct sockaddr*)&client->server,
                  sizeof(client->server));
-   puts("done");
  
    /* Turn off timer */
--- 322,327 ----
***************
*** 411,415 ****
      else
      {
-       puts("playerc_client_connect() succeeded");
        /* Clean out buffers */
        client->read_xdrdata_len = 0;
--- 408,411 ----
***************
*** 512,519 ****
    player_null_t req;
  
! //  req.subtype = htons(PLAYER_PLAYER_DATA_REQ);
!   if(client->data_requested)
      return(0);
!   ret = playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DATA, &req, 
NULL);
    if(ret == 0)
    {
--- 508,516 ----
    player_null_t req;
  
!   if(client->mode != PLAYER_DATAMODE_PULL || client->data_requested)
      return(0);
! 
!   ret = playerc_client_request(client, NULL, PLAYER_PLAYER_REQ_DATA, 
!                                &req, NULL);
    if(ret == 0)
    {
***************
*** 528,535 ****
  int playerc_client_peek(playerc_client_t *client, int timeout)
  {
!   if (!client->data_requested)
!   {
!         playerc_client_requestdata(client);
!   }
    return playerc_client_internal_peek(client, timeout);
  }
--- 525,535 ----
  int playerc_client_peek(playerc_client_t *client, int timeout)
  {
!   // First check the message queue
!   if (client->qlen > 0)
!     return(1);
! 
!   // In case we're in PULL mode, first request a round of data.
!   playerc_client_requestdata(client);
! 
    return playerc_client_internal_peek(client, timeout);
  }
***************
*** 540,557 ****
    int count;
    struct pollfd fd;
-   playerc_client_item_t *item;
    
    if (client->sock < 0)
    {
!     PLAYERC_WARN("no socket to write to");
      return -1;
    }
  
-   if (client->qlen > 0)
-   {
-     item = client->qitems + client->qfirst;
-     return(item->header.size);
-   }
- 
    fd.fd = client->sock;
    //fd.events = POLLIN | POLLHUP;
--- 540,550 ----
    int count;
    struct pollfd fd;
    
    if (client->sock < 0)
    {
!     PLAYERC_WARN("no socket to peek at");
      return -1;
    }
  
    fd.fd = client->sock;
    //fd.events = POLLIN | POLLHUP;
***************
*** 590,601 ****
    for(;;)
    {
!     // If we're in a PULL mode, first request a round of data.
!     if((client->mode == PLAYER_DATAMODE_PULL))
!     {
!       if(playerc_client_requestdata(client) < 0)
!         return NULL;
!     }
      ret = playerc_client_read_nonblock(client);
!     if(ret != NULL)
        break;
      nanosleep(&sleeptime,NULL);
--- 583,591 ----
    for(;;)
    {
!     // In case we're in PULL mode, first request a round of data.
!     if(playerc_client_requestdata(client) < 0)
!       return NULL;
      ret = playerc_client_read_nonblock(client);
!     if((ret != NULL) || (client->sock < 0))
        break;
      nanosleep(&sleeptime,NULL);
***************
*** 613,626 ****
      // See if there is any queued data.
      if (playerc_client_pop (client, &header, client->data) < 0)
!       {
!         // If there is no queued data, peek at the socket
!         if(playerc_client_internal_peek(client,0) <= 0)
!           return NULL;
!         // There's data on the socket, so read a packet (blocking).
!         if (playerc_client_readpacket (client, &header, client->data) < 0)
!           return NULL;
!       }
          
!     // One way or another, we got a new packet into (header,client->data), so 
process it
      switch(header.type)
      {
--- 603,617 ----
      // See if there is any queued data.
      if (playerc_client_pop (client, &header, client->data) < 0)
!     {
!       // If there is no queued data, peek at the socket
!       if(playerc_client_internal_peek(client,0) <= 0)
!         return NULL;
!       // There's data on the socket, so read a packet (blocking).
!       if(playerc_client_readpacket (client, &header, client->data) < 0)
!         return NULL;
!     }
          
!     // One way or another, we got a new packet into (header,client->data), 
!     // so process it
      switch(header.type)
      {
***************
*** 632,636 ****
          if(!client->data_received)
          {
!           PLAYERC_WARN ("No Data recieved with SYNC");
            return NULL;
          }
--- 623,627 ----
          if(!client->data_received)
          {
!           PLAYERC_WARN ("No data recieved with SYNC");
            return NULL;
          }
***************
*** 707,710 ****
--- 698,702 ----
  {
    double t;
+   int peek;
    struct timeval last;
    struct timeval curr;
***************
*** 712,715 ****
--- 704,708 ----
    memset(&req_header, 0, sizeof(req_header));
  
+ 
    if(deviceinfo == NULL)
    {
***************
*** 734,751 ****
    while(t >= 0)
    {
-     int peek;
      gettimeofday(&last,NULL);
-     peek = playerc_client_internal_peek(client,10);
-     gettimeofday(&curr,NULL);
-     t -= ((curr.tv_sec + curr.tv_usec/1e6) -
-           (last.tv_sec + last.tv_usec/1e6));
  
!     if(peek < 0)
        return -1;
      else if(peek == 0)
        continue;
  
!     if (playerc_client_readpacket(client, &rep_header, client->data) < 0)
        return -1;
  
      if (rep_header.type == PLAYER_MSGTYPE_DATA || rep_header.type == 
PLAYER_MSGTYPE_SYNCH)
--- 727,744 ----
    while(t >= 0)
    {
      gettimeofday(&last,NULL);
  
!     // Peek at the socket
!     if((peek = playerc_client_internal_peek(client,10)) < 0)
        return -1;
      else if(peek == 0)
        continue;
  
!     // There's data on the socket, so read a packet (blocking).
!     if(playerc_client_readpacket(client, &rep_header, client->data) < 0)
        return -1;
+     gettimeofday(&curr,NULL);
+     t -= ((curr.tv_sec + curr.tv_usec/1e6) -
+           (last.tv_sec + last.tv_usec/1e6));
  
      if (rep_header.type == PLAYER_MSGTYPE_DATA || rep_header.type == 
PLAYER_MSGTYPE_SYNCH)
***************
*** 1000,1004 ****
    if (client->sock < 0)
    {
!     PLAYERC_WARN("no socket to write to");
      return -1;
    }
--- 993,997 ----
    if (client->sock < 0)
    {
!     PLAYERC_WARN("no socket to read from");
      return -1;
    }


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to