From: Jonas Holmberg Date: Tue, 1 Sep 2009 08:39:52 +0000 (+0200) Subject: basertppayload: Make instance init faster by not reading /dev/urandom 3 times X-Git-Tag: 1.19.3~511^2~9283 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ec91d508af9fb359ebab7240497bd043d84d652e;p=platform%2Fupstream%2Fgstreamer.git basertppayload: Make instance init faster by not reading /dev/urandom 3 times ... which is the default seed when creating a new GRand. Because GLib in older versions used buffered IO this would take a lot of time. Instead use the global GRand for getting random numbers and keep the three instance GRand for backward compatibility with a simple seed. Fixes bug #593284. --- diff --git a/gst-libs/gst/rtp/gstbasertppayload.c b/gst-libs/gst/rtp/gstbasertppayload.c index 861bb60..f01b1a5 100644 --- a/gst-libs/gst/rtp/gstbasertppayload.c +++ b/gst-libs/gst/rtp/gstbasertppayload.c @@ -241,9 +241,9 @@ gst_basertppayload_init (GstBaseRTPPayload * basertppayload, gpointer g_class) gst_basertppayload_chain); gst_element_add_pad (GST_ELEMENT (basertppayload), basertppayload->sinkpad); - basertppayload->seq_rand = g_rand_new (); - basertppayload->ssrc_rand = g_rand_new (); - basertppayload->ts_rand = g_rand_new (); + basertppayload->seq_rand = g_rand_new_with_seed (g_random_int ()); + basertppayload->ssrc_rand = g_rand_new_with_seed (g_random_int ()); + basertppayload->ts_rand = g_rand_new_with_seed (g_random_int ()); basertppayload->mtu = DEFAULT_MTU; basertppayload->pt = DEFAULT_PT; @@ -902,20 +902,19 @@ gst_basertppayload_change_state (GstElement * element, gst_segment_init (&basertppayload->segment, GST_FORMAT_UNDEFINED); if (priv->seqnum_offset_random) - basertppayload->seqnum_base = - g_rand_int_range (basertppayload->seq_rand, 0, G_MAXUINT16); + basertppayload->seqnum_base = g_random_int_range (0, G_MAXUINT16); else basertppayload->seqnum_base = basertppayload->seqnum_offset; priv->next_seqnum = basertppayload->seqnum_base; basertppayload->seqnum = basertppayload->seqnum_base; if (priv->ssrc_random) - basertppayload->current_ssrc = g_rand_int (basertppayload->ssrc_rand); + basertppayload->current_ssrc = g_random_int (); else basertppayload->current_ssrc = basertppayload->ssrc; if (priv->ts_offset_random) - basertppayload->ts_base = g_rand_int (basertppayload->ts_rand); + basertppayload->ts_base = g_random_int (); else basertppayload->ts_base = basertppayload->ts_offset; basertppayload->timestamp = basertppayload->ts_base; diff --git a/gst-libs/gst/rtp/gstbasertppayload.h b/gst-libs/gst/rtp/gstbasertppayload.h index b790bb7..18d3778 100644 --- a/gst-libs/gst/rtp/gstbasertppayload.h +++ b/gst-libs/gst/rtp/gstbasertppayload.h @@ -79,6 +79,7 @@ struct _GstBaseRTPPayload GstPad *sinkpad; GstPad *srcpad; + /* FIXME 0.11: none of these GRands are used anymore, remove them */ GRand *seq_rand; GRand *ssrc_rand; GRand *ts_rand;