X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fstream_output%2Fsap.c;h=0c4e3f9dc30bda7418b61d22ef343e7f0cca135d;hb=974a5e403890f924980be2add6983913c520c94f;hp=70b078da9aedc88613d57d59e80afbbb3bcbd1b2;hpb=838cee473b8ab2c2ed36f7c73c15ab2966329116;p=vlc diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c index 70b078da9a..0c4e3f9dc3 100644 --- a/src/stream_output/sap.c +++ b/src/stream_output/sap.c @@ -94,7 +94,7 @@ struct sap_session_t { /***************************************************************************** * Local prototypes *****************************************************************************/ -static void RunThread( vlc_object_t *p_this); +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, @@ -123,10 +123,7 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce ) p_sap = vlc_custom_create( VLC_OBJECT(p_announce), sizeof( sap_handler_t ), VLC_OBJECT_ANNOUNCE, "announce" ); if( !p_sap ) - { - msg_Err( p_announce, "out of memory" ); return NULL; - } p_sap->psz_object_name = strdup( "sap announcer" ); @@ -191,15 +188,22 @@ static void announce_SAPHandlerDestructor( vlc_object_t * p_this ) * \param p_this the SAP Handler object * \return nothing */ -static void RunThread( vlc_object_t *p_this) +static void * RunThread( vlc_object_t *p_this) { sap_handler_t *p_sap = (sap_handler_t*)p_this; sap_session_t *p_session; + int canc = vlc_savecancel (); + /* TODO: Once net_Write() is cancel-safe, so will this whole thread. + * However, there is a more serious issues here: msleep(SAP_IDLE). + * This thread should really use poll(). + */ while( !p_sap->b_die ) { int i; + msleep( SAP_IDLE ); + /* If needed, get the rate info */ if( p_sap->b_control == true ) { @@ -225,11 +229,9 @@ static void RunThread( vlc_object_t *p_this) else { vlc_object_unlock( p_sap ); - msleep( SAP_IDLE ); continue; } p_session = p_sap->pp_sessions[p_sap->i_current_session]; - vlc_object_unlock( p_sap ); /* And announce it */ if( p_session->p_address->b_enabled == true && @@ -237,9 +239,10 @@ static void RunThread( vlc_object_t *p_this) { announce_SendSAPAnnounce( p_sap, p_session ); } - - msleep( SAP_IDLE ); + vlc_object_unlock( p_sap ); } + vlc_restorecancel (canc); + return NULL; } /* Add a SAP announce */