Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stefan Strogin
flac
Commits
98587b14
Commit
98587b14
authored
Feb 02, 2005
by
Josh Coalson
Browse files
better randomness on MSVC
parent
a5127138
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/test_seeking/main.c
View file @
98587b14
...
...
@@ -228,10 +228,12 @@ static FLAC__bool seek_barrage_native_flac(const char *filename, off_t filesize,
return
die_f_
(
"FLAC__file_decoder_process_until_end_of_metadata() FAILED"
,
decoder
);
printf
(
"file's total_samples is %llu
\n
"
,
decoder_client_data
.
total_samples
);
#if !defined _MSC_VER && !defined __MINGW32__
if
(
decoder_client_data
.
total_samples
>
(
FLAC__uint64
)
RAND_MAX
)
{
printf
(
"ERROR: must be total_samples < %u
\n
"
,
(
unsigned
)
RAND_MAX
);
return
false
;
}
#endif
n
=
(
long
int
)
decoder_client_data
.
total_samples
;
/* if we don't have a total samples count, just guess based on the file size */
...
...
@@ -239,8 +241,10 @@ static FLAC__bool seek_barrage_native_flac(const char *filename, off_t filesize,
if
(
n
==
0
)
{
/* 8 would imply no compression, 9 guarantees that we will get some samples off the end of the stream to test that case */
n
=
9
*
filesize
/
(
decoder_client_data
.
channels
*
decoder_client_data
.
bits_per_sample
);
#if !defined _MSC_VER && !defined __MINGW32__
if
(
n
>
RAND_MAX
)
n
=
RAND_MAX
;
#endif
}
printf
(
"Begin seek barrage, count=%u
\n
"
,
count
);
...
...
@@ -262,9 +266,10 @@ static FLAC__bool seek_barrage_native_flac(const char *filename, off_t filesize,
}
else
{
#if !defined _MSC_VER && !defined __MINGW32__
pos
=
(
FLAC__uint64
)(
random
()
%
n
);
#else
pos
=
(
FLAC__uint64
)(
rand
()
%
n
);
#else
/* RAND_MAX is only 32767 in my MSVC */
pos
=
(
FLAC__uint64
)((
random
()
<<
15
|
random
())
%
n
);
#endif
}
...
...
@@ -371,18 +376,22 @@ static FLAC__bool seek_barrage_ogg_flac(const char *filename, off_t filesize, un
return
die_of_
(
"OggFLAC__file_decoder_process_until_end_of_metadata() FAILED"
,
decoder
);
printf
(
"file's total_samples is %llu
\n
"
,
decoder_client_data
.
total_samples
);
#if !defined _MSC_VER && !defined __MINGW32__
if
(
decoder_client_data
.
total_samples
>
(
FLAC__uint64
)
RAND_MAX
)
{
printf
(
"ERROR: must be total_samples < %u
\n
"
,
(
unsigned
)
RAND_MAX
);
return
false
;
}
#endif
n
=
(
long
int
)
decoder_client_data
.
total_samples
;
/* if we don't have a total samples count, just guess based on the file size */
if
(
n
==
0
)
{
/* 8 would imply no compression, 9 guarantees that we will get some samples off the end of the stream to test that case */
n
=
9
*
filesize
/
(
decoder_client_data
.
channels
*
decoder_client_data
.
bits_per_sample
);
#if !defined _MSC_VER && !defined __MINGW32__
if
(
n
>
RAND_MAX
)
n
=
RAND_MAX
;
#endif
}
printf
(
"Begin seek barrage, count=%u
\n
"
,
count
);
...
...
@@ -404,9 +413,10 @@ static FLAC__bool seek_barrage_ogg_flac(const char *filename, off_t filesize, un
}
else
{
#if !defined _MSC_VER && !defined __MINGW32__
pos
=
(
FLAC__uint64
)(
random
()
%
n
);
#else
pos
=
(
FLAC__uint64
)(
rand
()
%
n
);
#else
/* RAND_MAX is only 32767 in my MSVC */
pos
=
(
FLAC__uint64
)((
random
()
<<
15
|
random
())
%
n
);
#endif
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment