GNOME Bugzilla – Bug 640211
oggmux: ensure serialnos are unique
Last modified: 2011-02-03 09:35:25 UTC
We do that by checking a newly generated one is not already used in an existing stream, and doing it again if it is.
Created attachment 178983 [details] [review] oggmux: ensure serialnos are unique
Instead of using rand() (only returns values between 0 and RAND_MAX) here it would be better to use g_random_int() and you could simply have an while(present) loop over the random numbers, it's extremely unlikely that this never finishes.
Created attachment 179232 [details] [review] oggmux: ensure serialnos are unique We do that by checking a newly generated one is not already used in an existing stream, and doing it again if it is. Now using g_random_int and removing the safety code.
This patch seems to depend on other oggmux modifications (pad->map)
Ah, yes: http://bugzilla-attachments.gnome.org/attachment.cgi?id=178948 found in: https://bugzilla.gnome.org/show_bug.cgi?id=629196 Note there are two patches in that bug. Do you want to review/commit these first, or should I post another patch based on a clean -base ?
Created attachment 179308 [details] [review] oggmux: ensure serialnos are unique We do that by checking a newly generated one is not already used in an existing stream, and doing it again if it is. A version that does not need my previous patches to oggmux.
Thanks, committed: commit 96a1a9dec6676826dd808d6c35a5ae3f7f276212 Author: Vincent Penquerc'h <vincent.penquerch@collabora.co.uk> Date: Fri Jan 21 18:10:29 2011 +0000 oggmux: ensure serialnos are unique We do that by checking a newly generated one is not already used in an existing stream, and doing it again if it is. https://bugzilla.gnome.org/show_bug.cgi?id=640211 I did one small change: - serialno = g_random_int(); +serialno = g_random_int_range (0, G_MAXINT32); to avoid pads named like 'sink_-418411', which is a bit awkward (generally the ogg code seems to be a bit confused about the type and sign of the serial number, and GStreamer about it's pad templates, using sink_%d when it really wants sink_%u)