]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/sap.c
avformat: set the "duration/length/ of a packet if known.
[vlc] / modules / services_discovery / sap.c
index ff4b739b72eec0ca3d27aa157da6d1edac525239..85f5f9bd9420f263a0d3874bf991cd2ae95c7ed1 100644 (file)
@@ -212,7 +212,7 @@ struct  sdp_t
 struct attribute_t
 {
     const char *value;
-    char name[0];
+    char name[];
 };
 
 struct sap_announce_t
@@ -481,6 +481,7 @@ static void Run( services_discovery_t *p_sd )
     char *psz_addr;
     int i;
     int timeout = -1;
+    int canc = vlc_savecancel ();
 
     /* Braindead Winsock DNS resolver will get stuck over 2 seconds per failed
      * DNS queries, even if the DNS server returns an error with milliseconds.
@@ -557,10 +558,11 @@ static void Run( services_discovery_t *p_sd )
     }
 
     /* read SAP packets */
-    while( vlc_object_alive( p_sd ) )
+    for (;;)
     {
+        vlc_restorecancel (canc);
         unsigned n = p_sd->p_sys->i_fd;
-        struct pollfd ufd[n+1];
+        struct pollfd ufd[n];
 
         for (unsigned i = 0; i < n; i++)
         {
@@ -569,12 +571,9 @@ static void Run( services_discovery_t *p_sd )
             ufd[i].revents = 0;
         }
 
-        /* Make sure we track vlc_object_signal() */
-        ufd[n].fd = vlc_object_waitpipe( p_sd );
-        ufd[n].events = POLLIN;
-        ufd[n].revents = 0;
-
-        if (poll (ufd, n+1, timeout) > 0)
+        int val = poll (ufd, n, timeout);
+        canc = vlc_savecancel ();
+        if (val > 0)
         {
             for (unsigned i = 0; i < n; i++)
             {
@@ -820,8 +819,9 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
                     p_announce->i_period_trust++;
 
                 /* Compute the average period */
-                p_announce->i_period = (p_announce->i_period + (mdate() - p_announce->i_last)) / 2;
-                p_announce->i_last = mdate();
+                mtime_t now = mdate();
+                p_announce->i_period = (p_announce->i_period + (now - p_announce->i_last)) / 2;
+                p_announce->i_last = now;
             }
             FreeSDP( p_sdp ); p_sdp = NULL;
             return VLC_SUCCESS;
@@ -854,7 +854,7 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
     p_sap->p_sdp = p_sdp;
 
     /* Released in RemoveAnnounce */
-    p_input = input_ItemNewWithType( VLC_OBJECT(p_sd),
+    p_input = input_item_NewWithType( VLC_OBJECT(p_sd),
                                      p_sap->p_sdp->psz_uri,
                                      p_sdp->psz_sessionname,
                                      0, NULL, -1, ITEM_TYPE_NET );
@@ -866,16 +866,16 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
     }
 
     if( p_sys->b_timeshift )
-        input_ItemAddOption( p_input, ":access-filter=timeshift" );
+        input_item_AddOption( p_input, ":access-filter=timeshift" );
 
     psz_value = GetAttribute( p_sap->p_sdp->pp_attributes, p_sap->p_sdp->i_attributes, "tool" );
     if( psz_value != NULL )
     {
-        input_ItemAddInfo( p_input, _("Session"), _("Tool"), "%s", psz_value );
+        input_item_AddInfo( p_input, _("Session"), _("Tool"), "%s", psz_value );
     }
     if( strcmp( p_sdp->username, "-" ) )
     {
-        input_ItemAddInfo( p_input, _("Session"), _("User"), "%s",
+        input_item_AddInfo( p_input, _("Session"), _("User"), "%s",
                            p_sdp->username );
     }