Changes rand() to rand_r() 86/245186/2 submit/tizen/20201005.134301
authorJaechul Lee <jcsing.lee@samsung.com>
Mon, 5 Oct 2020 07:12:50 +0000 (16:12 +0900)
committerJaechul Lee <jcsing.lee@samsung.com>
Mon, 5 Oct 2020 07:27:31 +0000 (16:27 +0900)
SVACE warned that rand makes no guaranteee of thread safety.

[Version] 0.5.33
[Issue Type] Bug

Change-Id: I256cf902b08a7f4fd334e79ad9c249b323f31c57
Signed-off-by: Jaechul Lee <jcsing.lee@samsung.com>
packaging/capi-media-audio-io.spec
test/audio_io_test.c

index c95f45c4218dbf63bcc8c8edf4eaa623133f3bc3..ad439bc287a8e730aedf14375583cf25a91029ce 100644 (file)
@@ -1,6 +1,6 @@
 Name:           capi-media-audio-io
 Summary:        An Audio Input & Audio Output library in Tizen Native API
-Version:        0.5.32
+Version:        0.5.33
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index 5f8882674afcaeff5733b910baf06ced59abcf2e..51c82bf1f33e49f7e3beae2b3d26af540c379478 100644 (file)
@@ -731,11 +731,10 @@ static void *thread_stress_test_audio_in(void *data)
        int buffer_size;
        audio_channel_e ch;
        audio_sample_type_e type;
+       unsigned int seed = (unsigned int)time(NULL);
 
        audio_in_h input = (audio_in_h)data;
 
-       srand(time(NULL));
-
        audio_in_prepare(input);
        audio_in_get_buffer_size(input, &buffer_size);
        buf = (char *)malloc(buffer_size);
@@ -745,7 +744,7 @@ static void *thread_stress_test_audio_in(void *data)
        }
 
        for (i=0; i<TEST_COUNT; i++) {
-               switch (rand() % 8) {
+               switch (rand_r(&seed) % 8) {
                        case 0:
                                audio_in_prepare(input);
                                break;
@@ -800,6 +799,7 @@ static void *thread_stress_test_audio_out(void *data)
        int buffer_size;
        audio_channel_e ch;
        audio_sample_type_e type;
+       unsigned int seed = (unsigned int)time(NULL);
 
        audio_out_h output = (audio_out_h)data;
 
@@ -815,7 +815,7 @@ static void *thread_stress_test_audio_out(void *data)
 
        audio_out_prepare(output);
        for (i = 0; i < TEST_COUNT; i++) {
-               switch (rand() % 9) {
+               switch (rand_r(&seed) % 9) {
                        case 0:
                                audio_out_prepare(output);
                                break;