Update of /cvsroot/playerstage/code/player/libplayercore
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10464/player/libplayercore

Modified Files:
        device.cc device.h devicetable.cc driver.cc driver.h 
        message.cc message.h 
Log Message:
applied Toby's autopointer patches

Index: message.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/message.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** message.h   10 Jul 2007 09:01:52 -0000      1.19
--- message.h   23 Aug 2007 19:58:42 -0000      1.20
***************
*** 57,60 ****
--- 57,109 ----
  class MessageQueue;
  
+ /** @brief An autopointer for the message queue
+ 
+ Using an autopointer allows the queue to be released by the client and still 
exist 
+ until no drivers have messages relating to the queue still pending.
+ 
+ **/
+ class QueuePointer
+ {
+   public:
+     /// Create a NULL autopointer;
+     QueuePointer();
+     /// Create an empty message queue and an auto pointer to it.
+     QueuePointer(bool _Replace, size_t _Maxlen);
+     /// Destroy our reference to the message queue.
+       ~QueuePointer();
+       /// Create a new reference to a message queue
+       QueuePointer(const QueuePointer & CopyFrom);
+       
+       /// assign reference to our message queue
+       QueuePointer & operator = (const QueuePointer & rhs);
+       /// retrieve underlying object for use
+       MessageQueue * operator -> ();
+       /// retrieve underlying object for use
+       MessageQueue & operator * ();
+       /// check if pointers are equal
+       bool operator == (const QueuePointer & rhs);
+       /// check if pointers are equal
+       bool operator == (void * pointer);
+       /// check if pointers are equal
+       bool operator != (const QueuePointer & rhs);
+       /// check if pointers are equal
+       bool operator != (void * pointer);
+       
+   private:
+     /// Decrement ref count
+     void DecRef();
+ 
+     /// The queue we are pointing to
+     MessageQueue * Queue;
+ 
+     /// Reference count.
+     unsigned int * RefCount;
+ 
+     /// Used to lock access to refcount.
+     pthread_mutex_t * Lock;
+ };
+ 
+ 
+ 
  /** @brief Reference-counted message objects
  
***************
*** 78,83 ****
              const void* data,
              unsigned int data_size,
-             MessageQueue* _queue = NULL,
              bool do_deepcopy = true);
      /// Copy pointers from existing message and increment refcount.
      Message(const Message & rhs);
--- 127,139 ----
              const void* data,
              unsigned int data_size,
              bool do_deepcopy = true);
+ 
+     /// Create a new message with an associated queue
+     Message(const struct player_msghdr & Header,
+             const void* data,
+             unsigned int data_size,
+             QueuePointer &_queue,
+             bool do_deepcopy = true);
+ 
      /// Copy pointers from existing message and increment refcount.
      Message(const Message & rhs);
***************
*** 126,130 ****
  
      /// queue to which any response to this message should be directed
!     MessageQueue* Queue;
  
      /// Reference count.
--- 182,186 ----
  
      /// queue to which any response to this message should be directed
!     QueuePointer Queue;
  
      /// Reference count.
***************
*** 372,374 ****
--- 428,433 ----
  };
  
+ 
+ 
+ 
  #endif

Index: driver.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/driver.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** driver.h    20 Aug 2007 06:37:26 -0000      1.21
--- driver.h    23 Aug 2007 19:58:42 -0000      1.22
***************
*** 164,168 ****
      by non-threaded drivers to cache the return address for requests
      that get forwarded to other devices. */
!     MessageQueue* ret_queue;
  
      /** @brief Publish a message via one of this driver's interfaces.
--- 164,168 ----
      by non-threaded drivers to cache the return address for requests
      that get forwarded to other devices. */
!     QueuePointer ret_queue;
  
      /** @brief Publish a message via one of this driver's interfaces.
***************
*** 180,184 ****
      current time will be filled in) */
      void Publish(player_devaddr_t addr,
!                  MessageQueue* queue,
                   uint8_t type,
                   uint8_t subtype,
--- 180,184 ----
      current time will be filled in) */
      void Publish(player_devaddr_t addr,
!                  QueuePointer &queue,
                   uint8_t type,
                   uint8_t subtype,
***************
*** 187,202 ****
                   double* timestamp=NULL);
  
      /** @brief Publish a message via one of this driver's interfaces.
  
      Use this form of Publish if you already have the message header
!     assembled.
!     @param queue If non-NULL, the target queue; if NULL,
!     then the message is sent to all interested parties.
      @param hdr The message header
      @param src The message body */
!     void Publish(MessageQueue* queue,
                   player_msghdr_t* hdr,
                   void* src);
  
  
      /** @brief Default device address (single-interface drivers) */
--- 187,231 ----
                   double* timestamp=NULL);
  
+      /** @brief Publish a message via one of this driver's interfaces.
+      
+      This form of Publish will assemble the message header for you.
+      The message is broadcast to all interested parties
+      
+      @param addr The origin address
+      @param type The message type
+      @param subtype The message subtype
+      @param src The message body
+      @param len Length of the message body
+      @param timestamp Timestamp for the message body (if NULL, then the
+      current time will be filled in) */
+      void Publish(player_devaddr_t addr, 
+                   uint8_t type, 
+                   uint8_t subtype,
+                   void* src=NULL, 
+                   size_t len=0,
+                   double* timestamp=NULL);
+  
+  
+ 
      /** @brief Publish a message via one of this driver's interfaces.
  
      Use this form of Publish if you already have the message header
!     assembled and have a target queue to send to.
!     @param queue the target queue.
      @param hdr The message header
      @param src The message body */
!     void Publish(QueuePointer &queue,
                   player_msghdr_t* hdr,
                   void* src);
  
+     /** @brief Publish a message via one of this driver's interfaces.
+ 
+     Use this form of Publish if you already have the message header
+     assembled and wish to broadcast the message to all subscribed parties.
+     @param hdr The message header
+     @param src The message body */
+     void Publish(player_msghdr_t* hdr,
+                  void* src);
+ 
  
      /** @brief Default device address (single-interface drivers) */
***************
*** 220,224 ****
  
      /** @brief Queue for all incoming messages for this driver */
!     MessageQueue* InQueue;
  
      /** @brief Constructor for single-interface drivers.
--- 249,253 ----
  
      /** @brief Queue for all incoming messages for this driver */
!     QueuePointer InQueue;
  
      /** @brief Constructor for single-interface drivers.
***************
*** 329,333 ****
      @param hdr The message header
      @param data The message body */
!     virtual int ProcessMessage(MessageQueue* resp_queue, player_msghdr * hdr,
                                 void * data);
  
--- 358,362 ----
      @param hdr The message header
      @param data The message body */
!     virtual int ProcessMessage(QueuePointer &resp_queue, player_msghdr * hdr,
                                 void * data);
  
***************
*** 346,350 ****
      @param hdr The message header
      @param data The message body */
!     virtual int ProcessInternalMessages(MessageQueue* resp_queue,
                                          player_msghdr * hdr,
                                          void * data);
--- 375,379 ----
      @param hdr The message header
      @param data The message body */
!     virtual int ProcessInternalMessages(QueuePointer& resp_queue,
                                          player_msghdr * hdr,
                                          void * data);

Index: message.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/message.cc,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** message.cc  20 Aug 2007 19:42:47 -0000      1.23
--- message.cc  23 Aug 2007 19:58:42 -0000      1.24
***************
*** 56,62 ****
  
  Message::Message(const struct player_msghdr & Header,
                   const void * data,
                   unsigned int data_size,
!                  MessageQueue* _queue,
                   bool do_deepcopy)
  {
--- 56,99 ----
  
  Message::Message(const struct player_msghdr & Header,
+                   const void * data,
+                   unsigned int data_size,
+                   bool do_deepcopy)
+ {
+   this->Lock = new pthread_mutex_t;
+   assert(this->Lock);
+   pthread_mutex_init(this->Lock,NULL);
+   this->Size = sizeof(struct player_msghdr)+data_size;
+   assert(this->Size);
+   this->Data = new unsigned char[this->Size];
+   assert(this->Data);
+ 
+   // copy the header and then the data into out message data buffer
+   memcpy(this->Data,&Header,sizeof(struct player_msghdr));
+   // Force header size to be same as data size
+   ((player_msghdr *) Data)->size = data_size;
+ 
+   memcpy(&this->Data[sizeof(struct player_msghdr)],data,data_size);
+   if (do_deepcopy && data != NULL)
+   {
+     player_dpcpy_fn_t dpcpyfunc = NULL;
+     if((dpcpyfunc = playerxdr_get_dpcpyfunc(Header.addr.interf, Header.type, 
Header.subtype)) != NULL)
+     {
+       if((this->DynDataSize = (*dpcpyfunc)(data, this->GetPayload())) == 0)
+       {
+         // Possible error
+         PLAYER_WARN3 ("copied zero bytes in deep copy of message %s: %s, %d", 
interf_to_str (Header.addr.interf), msgtype_to_str (Header.type), 
Header.subtype);
+       }
+     }
+   }
+ 
+   this->RefCount = new unsigned int;
+   assert(this->RefCount);
+   *this->RefCount = 1;
+ }
+ 
+ Message::Message(const struct player_msghdr & Header,
                   const void * data,
                   unsigned int data_size,
!                  QueuePointer &_queue,
                   bool do_deepcopy)
  {
***************
*** 144,151 ****
--- 181,191 ----
        playerxdr_delete_message (this->GetPayload(), 
this->GetHeader()->addr.interf, this->GetHeader()->type, 
this->GetHeader()->subtype);
      delete [] Data;
+     Data = NULL;
      delete RefCount;
+     RefCount = NULL;
      pthread_mutex_unlock(Lock);
      pthread_mutex_destroy(Lock);
      delete Lock;
+     Lock = NULL;
    }
    else
***************
*** 251,254 ****
--- 291,295 ----
    for(MessageReplaceRule* curr=this->replaceRules;curr;curr=curr->next)
    {
+       assert(curr);
      if(curr->Match(hdr))
        return(curr->replace);
***************
*** 533,534 ****
--- 574,718 ----
  }
  
+ /// Create an empty message queue and an auto pointer to it.
+ QueuePointer::QueuePointer()
+ {
+   Lock = NULL;
+   RefCount = NULL;
+   Queue = NULL;
+ }
+ 
+ /// Create an empty message queue and an auto pointer to it.
+ QueuePointer::QueuePointer(bool _Replace, size_t _Maxlen)
+ {
+   this->Lock = new pthread_mutex_t;
+   assert(this->Lock);
+   pthread_mutex_init(this->Lock,NULL);
+   this->Queue = new MessageQueue(_Replace, _Maxlen);
+   assert(this->Queue);
+ 
+   this->RefCount = new unsigned int;
+   assert(this->RefCount);
+   *this->RefCount = 1;                
+ }
+ 
+ /// Destroy our reference to the message queue.
+ /// and our queue if there are no more references
+ QueuePointer::~QueuePointer()
+ {
+       DecRef();
+ }
+ 
+ /// Create a new reference to a message queue
+ QueuePointer::QueuePointer(const QueuePointer & rhs)
+ {
+   if (rhs.Queue == NULL)
+   {
+     Lock = NULL;
+     RefCount = NULL;
+     Queue = NULL;             
+   }
+   else
+   {
+     assert(rhs.Lock);
+     pthread_mutex_lock(rhs.Lock);
+ 
+     assert(rhs.Queue);
+     assert(rhs.RefCount);
+     assert(*(rhs.RefCount));
+     Lock = rhs.Lock;
+     Queue = rhs.Queue;
+     RefCount = rhs.RefCount;
+     (*RefCount)++;
+     pthread_mutex_unlock(Lock);       
+   }
+ }
+       
+ /// assign reference to our message queue
+ QueuePointer & QueuePointer::operator = (const QueuePointer & rhs)
+ {
+   // first remove our current reference
+   DecRef();
+   
+   if (rhs.Queue == NULL)
+       return *this;
+   
+   // then copy the rhs
+   assert(rhs.Lock);
+   pthread_mutex_lock(rhs.Lock);
+ 
+   assert(rhs.Queue);
+   assert(rhs.RefCount);
+   assert(*(rhs.RefCount));
+   Lock = rhs.Lock;
+   Queue = rhs.Queue;
+   RefCount = rhs.RefCount;
+   (*RefCount)++;
+   pthread_mutex_unlock(Lock); 
+   return *this;
+ }
+ 
+ /// retrieve underlying object for use
+ MessageQueue * QueuePointer::operator -> ()
+ {
+   assert(Queue);
+   return Queue;               
+ }
+ 
+ /// retrieve underlying object for use
+ MessageQueue & QueuePointer::operator * ()
+ {
+   assert(Queue);
+   return *Queue;              
+ }
+ 
+ /// check if pointers are equal
+ bool QueuePointer::operator == (const QueuePointer & rhs)
+ {
+   return rhs.Queue == Queue;  
+ }
+ 
+ /// check if pointers are equal
+ bool QueuePointer::operator == (void * pointer)
+ {
+   return Queue == pointer;    
+ }
+ 
+ /// check if pointers are equal
+ bool QueuePointer::operator != (const QueuePointer & rhs)
+ {
+   return rhs.Queue != Queue;  
+ }
+ 
+ /// check if pointers are equal
+ bool QueuePointer::operator != (void * pointer)
+ {
+   return Queue != pointer;    
+ }
+ 
+ void QueuePointer::DecRef()
+ {
+   if (Queue == NULL)
+     return;
+     
+   pthread_mutex_lock(Lock);
+   (*RefCount)--;
+   assert((*RefCount) >= 0);
+   if((*RefCount)==0)
+   {
+     delete Queue;
+     Queue = NULL;
+     delete RefCount;
+     RefCount = NULL;
+     pthread_mutex_unlock(Lock);
+     pthread_mutex_destroy(Lock);
+     delete Lock;
+     Lock = NULL;
+   }
+   else
+   {
+     Queue = NULL;
+     RefCount = NULL;
+     pthread_mutex_unlock(Lock);               
+     Lock = NULL;
+   }
+ }

Index: driver.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/driver.cc,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** driver.cc   13 Aug 2007 07:06:03 -0000      1.30
--- driver.cc   23 Aug 2007 19:58:42 -0000      1.31
***************
*** 71,75 ****
  Driver::Driver(ConfigFile *cf, int section,
                 bool overwrite_cmds, size_t queue_maxlen,
!                int interf)
  {
    this->error = 0;
--- 71,75 ----
  Driver::Driver(ConfigFile *cf, int section,
                 bool overwrite_cmds, size_t queue_maxlen,
!                int interf) : InQueue(overwrite_cmds, queue_maxlen)
  {
    this->error = 0;
***************
*** 88,95 ****
    this->alwayson = false;
  
-   // The InQueue MUST be created before calling AddInterface
-   this->InQueue = new MessageQueue(overwrite_cmds, queue_maxlen);
-   assert(InQueue);
- 
    // Create an interface
    if(this->AddInterface(this->device_addr) != 0)
--- 88,91 ----
***************
*** 104,108 ****
  // this is the other constructor, used by multi-interface drivers.
  Driver::Driver(ConfigFile *cf, int section,
!                bool overwrite_cmds, size_t queue_maxlen)
  {
    this->error = 0;
--- 100,104 ----
  // this is the other constructor, used by multi-interface drivers.
  Driver::Driver(ConfigFile *cf, int section,
!                bool overwrite_cmds, size_t queue_maxlen) : 
InQueue(overwrite_cmds, queue_maxlen)
  {
    this->error = 0;
***************
*** 115,121 ****
    this->entries = 0;
  
-   this->InQueue = new MessageQueue(overwrite_cmds, queue_maxlen);
-   assert(InQueue);
- 
    pthread_mutex_init(&this->accessMutex,NULL);
  }
--- 111,114 ----
***************
*** 124,128 ****
  Driver::~Driver()
  {
-   delete this->InQueue;
  }
  
--- 117,120 ----
***************
*** 141,196 ****
  
  void
! Driver::Publish(MessageQueue* queue,
                  player_msghdr_t* hdr,
                  void* src)
  {
    Device* dev;
  
    Message msg(*hdr,src,hdr->size);
! 
!   if(queue)
    {
!     // push onto the given queue, which provides its own locking
!     if(!queue->Push(msg))
!     {
!       PLAYER_ERROR4("tried to push %d/%d from %d:%d",
!                     hdr->type, hdr->subtype,
!                     hdr->addr.interf, hdr->addr.index);
!     }
    }
!   else
    {
!     // lock here, because we're accessing our device's queue list
!     this->Lock();
!     // push onto each queue subscribed to the given device
!     if(!(dev = deviceTable->GetDevice(hdr->addr,false)))
!     {
!       // This is generally ok, because a driver might call Publish on all
!       // of its possible interfaces, even though some have not been
!       // requested.
!       //
!       //PLAYER_ERROR2("tried to publish message via non-existent device 
%d:%d", hdr->addr.interf, hdr->addr.index);
!       this->Unlock();
!       return;
!     }
!     for(size_t i=0;i<dev->len_queues;i++)
      {
!       if(dev->queues[i])
        {
!         if(!dev->queues[i]->Push(msg))
!         {
!           PLAYER_ERROR4("tried to push %d/%d from %d:%d",
!                         hdr->type, hdr->subtype,
!                         hdr->addr.interf, hdr->addr.index);
!         }
        }
      }
-     this->Unlock();
    }
  }
  
  void
  Driver::Publish(player_devaddr_t addr,
!                 MessageQueue* queue,
                  uint8_t type,
                  uint8_t subtype,
--- 133,188 ----
  
  void
! Driver::Publish(QueuePointer &queue,
                  player_msghdr_t* hdr,
                  void* src)
  {
+   Message msg(*hdr,src,hdr->size);
+   // push onto the given queue, which provides its own locking
+   if(!queue->Push(msg))
+   {
+     PLAYER_ERROR4("tried to push %d/%d from %d:%d",
+                   hdr->type, hdr->subtype,
+                   hdr->addr.interf, hdr->addr.index);
+   }
+ }
+ 
+ void
+ Driver::Publish(player_msghdr_t* hdr,
+                 void* src)
+ {
    Device* dev;
  
    Message msg(*hdr,src,hdr->size);
!   // lock here, because we're accessing our device's queue list
!   this->Lock();
!   // push onto each queue subscribed to the given device
!   if(!(dev = deviceTable->GetDevice(hdr->addr,false)))
    {
!     // This is generally ok, because a driver might call Publish on all
!     // of its possible interfaces, even though some have not been
!     // requested.
!     //
!     //PLAYER_ERROR2("tried to publish message via non-existent device %d:%d", 
hdr->addr.interf, hdr->addr.index);
!     this->Unlock();
!     return;
    }
!   for(size_t i=0;i<dev->len_queues;i++)
    {
!     if(dev->queues[i] != NULL)
      {
!       if(!dev->queues[i]->Push(msg))
        {
!         PLAYER_ERROR4("tried to push %d/%d from %d:%d",
!                       hdr->type, hdr->subtype,
!                       hdr->addr.interf, hdr->addr.index);
        }
      }
    }
+   this->Unlock();
  }
  
  void
  Driver::Publish(player_devaddr_t addr,
!                 QueuePointer &queue,
                  uint8_t type,
                  uint8_t subtype,
***************
*** 218,221 ****
--- 210,240 ----
  }
  
+ void
+ Driver::Publish(player_devaddr_t addr, 
+                 uint8_t type, 
+                 uint8_t subtype,
+                 void* src, 
+                 size_t len,
+                 double* timestamp)
+ {
+   double t;
+ 
+   // Fill in the time structure if not supplied
+   if(timestamp)
+     t = *timestamp;
+   else
+     GlobalTime->GetTimeDouble(&t);
+ 
+   player_msghdr_t hdr;
+   memset(&hdr,0,sizeof(player_msghdr_t));
+   hdr.addr = addr;
+   hdr.type = type;
+   hdr.subtype = subtype;
+   hdr.timestamp = t;
+   hdr.size = len;
+ 
+   this->Publish(&hdr, src);
+ }
+ 
  void Driver::Lock()
  {
***************
*** 325,329 ****
  
  // Default message handler
! int Driver::ProcessMessage(MessageQueue* resp_queue, player_msghdr * hdr,
                             void * data)
  {
--- 344,348 ----
  
  // Default message handler
! int Driver::ProcessMessage(QueuePointer &resp_queue, player_msghdr * hdr,
                             void * data)
  {
***************
*** 383,387 ****
  }
  
! int Driver::ProcessInternalMessages(MessageQueue* resp_queue,
                                      player_msghdr * hdr, void * data)
  {
--- 402,406 ----
  }
  
! int Driver::ProcessInternalMessages(QueuePointer &resp_queue,
                                      player_msghdr * hdr, void * data)
  {

Index: devicetable.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/devicetable.cc,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** devicetable.cc      10 Jul 2007 09:01:51 -0000      1.19
--- devicetable.cc      23 Aug 2007 19:58:42 -0000      1.20
***************
*** 209,213 ****
      if(thisentry->driver->alwayson)
      {
!       if(thisentry->Subscribe(NULL) != 0)
        {
          PLAYER_ERROR2("initial subscription failed for device %s:%d",
--- 209,214 ----
      if(thisentry->driver->alwayson)
      {
!         QueuePointer Temp = QueuePointer();
!       if(thisentry->Subscribe(Temp) != 0)
        {
          PLAYER_ERROR2("initial subscription failed for device %s:%d",

Index: device.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/device.cc,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** device.cc   10 Jul 2007 09:01:51 -0000      1.20
--- device.cc   23 Aug 2007 19:58:42 -0000      1.21
***************
*** 81,86 ****
    else
    {
!     this->InQueue = new MessageQueue(false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN);
!     assert(this->InQueue);
    }
  
--- 81,85 ----
    else
    {
!     this->InQueue = QueuePointer(false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN);
    }
  
***************
*** 88,93 ****
    // necessary in the future.
    this->len_queues = 2;
!   this->queues = (MessageQueue**)calloc(this->len_queues,
!                                         sizeof(MessageQueue*));
    assert(this->queues);
  }
--- 87,92 ----
    // necessary in the future.
    this->len_queues = 2;
!   this->queues = (QueuePointer*)calloc(this->len_queues,
!                                         sizeof(QueuePointer));
    assert(this->queues);
  }
***************
*** 106,110 ****
  
  int
! Device::Subscribe(MessageQueue* sub_queue)
  {
    int retval;
--- 105,109 ----
  
  int
! Device::Subscribe(QueuePointer &sub_queue)
  {
    int retval;
***************
*** 117,121 ****
    for(i=0;i<this->len_queues;i++)
    {
!     if(!this->queues[i])
        break;
    }
--- 116,120 ----
    for(i=0;i<this->len_queues;i++)
    {
!     if(this->queues[i] == NULL)
        break;
    }
***************
*** 126,133 ****
      size_t tmp = this->len_queues;
      this->len_queues *= 2;
!     this->queues = (MessageQueue**)realloc(this->queues,
                                             (this->len_queues *
!                                             sizeof(MessageQueue*)));
!     memset(this->queues+tmp,0,(this->len_queues-tmp)*sizeof(MessageQueue*));
      assert(this->queues);
    }
--- 125,132 ----
      size_t tmp = this->len_queues;
      this->len_queues *= 2;
!     this->queues = (QueuePointer*)realloc(this->queues,
                                             (this->len_queues *
!                                             sizeof(QueuePointer)));
!     memset(this->queues+tmp,0,(this->len_queues-tmp)*sizeof(QueuePointer));
      assert(this->queues);
    }
***************
*** 141,145 ****
      {
        // remove the subscriber's queue, since the subscription failed
!       this->queues[i] = NULL;
        this->driver->Unlock();
        return(retval);
--- 140,144 ----
      {
        // remove the subscriber's queue, since the subscription failed
!       this->queues[i] = QueuePointer();
        this->driver->Unlock();
        return(retval);
***************
*** 153,157 ****
  
  int
! Device::Unsubscribe(MessageQueue* sub_queue)
  {
    int retval;
--- 152,156 ----
  
  int
! Device::Unsubscribe(QueuePointer &sub_queue)
  {
    int retval;
***************
*** 172,176 ****
      if(this->queues[i] == sub_queue)
      {
!       this->queues[i] = NULL;
        if(this->driver)
          this->driver->Unlock();
--- 171,175 ----
      if(this->queues[i] == sub_queue)
      {
!       this->queues[i] = QueuePointer();
        if(this->driver)
          this->driver->Unlock();
***************
*** 185,189 ****
  
  void
! Device::PutMsg(MessageQueue* resp_queue,
                 player_msghdr_t* hdr,
                 void* src)
--- 184,188 ----
  
  void
! Device::PutMsg(QueuePointer &resp_queue,
                 player_msghdr_t* hdr,
                 void* src)
***************
*** 203,207 ****
  
  void
! Device::PutMsg(MessageQueue* resp_queue,
                 uint8_t type,
                 uint8_t subtype,
--- 202,206 ----
  
  void
! Device::PutMsg(QueuePointer &resp_queue,
                 uint8_t type,
                 uint8_t subtype,
***************
*** 235,239 ****
  
  Message*
! Device::Request(MessageQueue* resp_queue,
                  uint8_t type,
                  uint8_t subtype,
--- 234,238 ----
  
  Message*
! Device::Request(QueuePointer &resp_queue,
                  uint8_t type,
                  uint8_t subtype,

Index: device.h
===================================================================
RCS file: /cvsroot/playerstage/code/player/libplayercore/device.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** device.h    10 Jul 2007 09:01:51 -0000      1.14
--- device.h    23 Aug 2007 19:58:42 -0000      1.15
***************
*** 77,86 ****
      ///
      /// @returns 0 on success, non-zero otherwise.
!     int Subscribe(MessageQueue* sub_queue);
  
      /// @brief Unsubscribe the given queue from this device.
      ///
      /// @returns 0 on success, non-zero otherwise.
!     int Unsubscribe(MessageQueue* sub_queue);
  
      /// @brief Send a message to this device.
--- 77,86 ----
      ///
      /// @returns 0 on success, non-zero otherwise.
!     int Subscribe(QueuePointer &sub_queue);
  
      /// @brief Unsubscribe the given queue from this device.
      ///
      /// @returns 0 on success, non-zero otherwise.
!     int Unsubscribe(QueuePointer &sub_queue);
  
      /// @brief Send a message to this device.
***************
*** 97,101 ****
      /// @param timestamp : If non-NULL, the timestamp to attach to the
      /// message; otherwise, the current time is filled in.
!     void PutMsg(MessageQueue* resp_queue,
                  uint8_t type, 
                  uint8_t subtype,
--- 97,101 ----
      /// @param timestamp : If non-NULL, the timestamp to attach to the
      /// message; otherwise, the current time is filled in.
!     void PutMsg(QueuePointer &resp_queue,
                  uint8_t type, 
                  uint8_t subtype,
***************
*** 112,116 ****
      /// @param hdr The message header.
      /// @param src The message body (its size is stored in hdr->size).
!     void PutMsg(MessageQueue* resp_queue,
                  player_msghdr_t* hdr,
                  void* src);
--- 112,116 ----
      /// @param hdr The message header.
      /// @param src The message body (its size is stored in hdr->size).
!     void PutMsg(QueuePointer &resp_queue,
                  player_msghdr_t* hdr,
                  void* src);
***************
*** 138,142 ****
      /// @returns A pointer to the reply message.  The caller is responsible
      ///          for deleting this pointer.
!     Message* Request(MessageQueue* resp_queue,
                       uint8_t type,
                       uint8_t subtype,
--- 138,142 ----
      /// @returns A pointer to the reply message.  The caller is responsible
      ///          for deleting this pointer.
!     Message* Request(QueuePointer &resp_queue,
                       uint8_t type,
                       uint8_t subtype,
***************
*** 180,187 ****
      
      /// Pointer to the underlying driver's queue
!     MessageQueue* InQueue;
  
      /// Linked list of subscribed queues
!     MessageQueue** queues;
  
      /// Length of @p queues
--- 180,187 ----
      
      /// Pointer to the underlying driver's queue
!     QueuePointer InQueue;
  
      /// Linked list of subscribed queues
!     QueuePointer* queues;
  
      /// Length of @p queues


-------------------------------------------------------------------------
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

Reply via email to