Commit 275a5d4a authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

ASF: thread-safe pseudo-random numbers

parent 6268a229
......@@ -26,6 +26,7 @@
#endif
#include <vlc_common.h>
#include <vlc_rand.h>
#include "asf.h"
#include "buffer.h"
......@@ -47,18 +48,10 @@ static int CmpGuid( const guid_t *p_guid1, const guid_t *p_guid2 )
void GenerateGuid ( guid_t *p_guid )
{
int i;
srand( mdate() & 0xffffffff );
/* FIXME should be generated using random data */
p_guid->v1 = 0xbabac001;
p_guid->v2 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
p_guid->v3 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
for( i = 0; i < 8; i++ )
{
p_guid->v4[i] = ( (uint64_t)rand() * 256 ) / RAND_MAX;
}
vlc_rand_bytes(&p_guid->v2, sizeof(p_guid->v2));
vlc_rand_bytes(&p_guid->v3, sizeof(p_guid->v3));
vlc_rand_bytes(p_guid->v4, sizeof(p_guid->v4));
}
void asf_HeaderParse ( asf_header_t *hdr,
......
......@@ -38,6 +38,7 @@
#include <vlc_block.h>
#include <vlc_codecs.h>
#include <vlc_arrays.h>
#include <vlc_rand.h>
typedef GUID guid_t;
......@@ -228,14 +229,10 @@ static int Open( vlc_object_t *p_this )
p_sys->i_packet_count= 0;
/* Generate a random fid */
srand( mdate() & 0xffffffff );
p_sys->fid.Data1 = 0xbabac001;
p_sys->fid.Data2 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
p_sys->fid.Data3 = ( (uint64_t)rand() << 16 ) / RAND_MAX;
for( i = 0; i < 8; i++ )
{
p_sys->fid.Data4[i] = ( (uint64_t)rand() << 8 ) / RAND_MAX;
}
vlc_rand_bytes(&p_sys->fid.Data2, sizeof(p_sys->fid.Data2));
vlc_rand_bytes(&p_sys->fid.Data3, sizeof(p_sys->fid.Data3));
vlc_rand_bytes(p_sys->fid.Data4, sizeof(p_sys->fid.Data4));
/* Meta data */
p_sys->psz_title = var_GetString( p_mux, SOUT_CFG_PREFIX "title" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment