[vlc-devel] commit: SAP: no need to keep two dates per announce ( Rémi Denis-Courmont )

git version control git at videolan.org
Wed Aug 27 22:57:34 CEST 2008


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Aug 23 11:00:49 2008 +0300| [443a59d6e351ac0813403d1ddbc94e44dda99a00] | committer: Rémi Denis-Courmont 

SAP: no need to keep two dates per announce

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=443a59d6e351ac0813403d1ddbc94e44dda99a00
---

 src/stream_output/sap.c |   44 +++++++++++++++++---------------------------
 1 files changed, 17 insertions(+), 27 deletions(-)

diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c
index cc6f887..61243c6 100644
--- a/src/stream_output/sap.c
+++ b/src/stream_output/sap.c
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * sap.c : SAP announce handler
  *****************************************************************************
- * Copyright (C) 2002-2007 the VideoLAN team
+ * Copyright (C) 2002-2008 the VideoLAN team
  * $Id$
  *
  * Authors: Clément Stenac <zorglub at videolan.org>
@@ -87,7 +87,6 @@ struct sap_session_t {
     session_descriptor_t *p_sd;
 
     /* Last and next send */
-    mtime_t        i_last;
     mtime_t        i_next;
 };
 
@@ -97,8 +96,8 @@ struct sap_session_t {
 static void * RunThread( vlc_object_t *p_this);
 static int ComputeRate( sap_address_t *p_address );
 
-static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
-                                     sap_session_t *p_session );
+static void announce_SendSAPAnnounce( sap_handler_t *p_sap,
+                                      sap_session_t *p_session );
 
 
 static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
@@ -443,7 +442,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     /* If needed, build the SDP */
     assert( p_session->psz_sdp != NULL );
 
-    p_sap_session->i_last = 0;
+    p_sap_session->i_next = 0;
     p_sap_session->i_length = headsize + strlen (p_session->psz_sdp);
     p_sap_session->psz_data = malloc (p_sap_session->i_length + 1);
     if (p_sap_session->psz_data == NULL)
@@ -545,32 +544,23 @@ static int announce_SAPAnnounceDel( sap_handler_t *p_sap,
     return VLC_SUCCESS;
 }
 
-static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
-                                     sap_session_t *p_session )
+static void announce_SendSAPAnnounce( sap_handler_t *p_sap,
+                                      sap_session_t *p_session )
 {
-    /* This announce has never been sent yet */
-    if( p_session->i_last == 0 )
-    {
-        p_session->i_next = mdate()+ p_session->p_address->i_interval*1000000;
-        p_session->i_last = 1;
-        return VLC_SUCCESS;
-    }
+    mtime_t now = mdate();
+
+    if( p_session->i_next >= now )
+        return;
 
-    if( p_session->i_next < mdate() )
+    ssize_t i_ret = send( p_session->p_address->i_wfd, p_session->psz_data,
+                          p_session->i_length, 0 );
+    if( i_ret != (ssize_t)p_session->i_length )
     {
-        ssize_t i_ret = send( p_session->p_address->i_wfd, p_session->psz_data,
-                              p_session->i_length, 0 );
-        if( i_ret != (ssize_t)p_session->i_length )
-        {
-            msg_Warn( p_sap, "SAP send failed on address %s (%zd/%zu)",
-                      p_session->p_address->psz_address,
-                      i_ret, p_session->i_length );
-        }
-        p_session->i_last = p_session->i_next;
-        p_session->i_next = p_session->i_last
-                            + p_session->p_address->i_interval*1000000;
+        msg_Warn( p_sap, "SAP send failed on address %s (%zd/%zu)",
+                  p_session->p_address->psz_address,
+                  i_ret, p_session->i_length );
     }
-    return VLC_SUCCESS;
+    p_session->i_next = now + p_session->p_address->i_interval*CLOCK_FREQ;
 }
 
 static int ComputeRate( sap_address_t *p_address )




More information about the vlc-devel mailing list