mrp: MSRP: bugfix for 4 listener stream case
authorAndrew Elder <aelder@audioscience.com>
Fri, 29 Mar 2013 21:11:13 +0000 (17:11 -0400)
committerAndrew Elder <aelder@audioscience.com>
Mon, 20 May 2013 20:42:09 +0000 (16:42 -0400)
This checkin fixes 2 issues in msrp_emit_listenvectors():
1) when listener streams with incrementing stream ID are registered
the attributes are aggregated, but there was no test for whether the
attribute had already been tx'd, so stream declarations were repeated.
The fix is to mark all attributes for tx before looping through the tx
pack operation and then test the tx flag inside the tx pack loop.
2) incorrect conditional in vect_4pack operation

daemons/mrpd/msrp.c

index e2101ef..967199c 100644 (file)
@@ -1580,6 +1580,9 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
                 */
 
                vectidx = 4;
+
+/* pending review and deletion */
+#ifdef MSRP_AGGREGATE_DOMAINS_VECTORS
                vattrib = attrib->next;
 
                while (NULL != vattrib) {
@@ -1658,6 +1661,7 @@ msrp_emit_domainvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
 
                        vattrib = vattrib->next;
                }
+#endif
 
                /* handle any trailers */
                if (vectevt_idx > 0) {
@@ -2038,8 +2042,18 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
        if (NULL == listen_declare)
                goto oops;
 
+       /* if we have a listener type registered, always send out an update,
+        * so mark all as ready.
+        */
        attrib = MSRP_db->attrib_list;
+       while(attrib) {
+               if (MSRP_LISTENER_TYPE == attrib->type) {
+                       attrib->applicant.tx = 1;
+               }
+               attrib = attrib->next;
+       }
 
+       attrib = MSRP_db->attrib_list;
        mrpdu_vectorptr = (mrpdu_vectorattrib_t *) & (mrpdu_msg->Data[2]);
 
        while ((mrpdu_msg_ptr < (mrpdu_msg_eof - 2)) && (NULL != attrib)) {
@@ -2049,6 +2063,11 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
                        continue;
                }
 
+               if (0 == attrib->applicant.tx) {
+                       attrib = attrib->next;
+                       continue;
+               }
+
                listen_declare_idx = 0;
 
                /* if we have a listener type registered, we always will
@@ -2237,8 +2256,7 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
                            > (mrpdu_msg_eof - 2))
                                goto oops;
 
-                       if (vectevt_idx > 3) {
-                               vect_4pack =
+                       vect_4pack =
                                    MRPDU_4PACK_ENCODE(listen_declare
                                                       [listen_declare_idx],
                                                       listen_declare
@@ -2249,15 +2267,13 @@ msrp_emit_listenvectors(unsigned char *msgbuf, unsigned char *msgbuf_eof,
                                                       [listen_declare_idx +
                                                        3]);
 
-                               mrpdu_vectorptr->FirstValue_VectorEvents
+                       mrpdu_vectorptr->FirstValue_VectorEvents
                                    [vectidx] = vect_4pack;
-                               vectidx++;
-                       }
+                       vectidx++;
 
                        if (&(mrpdu_vectorptr->FirstValue_VectorEvents[vectidx])
                            > (mrpdu_msg_eof - 3))
                                goto oops;
-
                }
 
                /* handle any trailers */