diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-26 17:43:36 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-26 21:17:24 +0100 |
commit | a45356ce3eb14ad016732593cd5eedfd6f05df6f (patch) | |
tree | 66677957f00c90499d08c0e71ef0aa42b134b3c9 | |
parent | eb8a3e7a7c3399f0c11fbca7b15e7fc8bfc0483a (diff) |
Avoid large stack allocations on thread stacks.
OS X and Windows have small thread stacks by default. Allocating audio and video
frames (about 962KB total) on the stack overflows it.
-rw-r--r-- | auto_tests/toxav_many_test.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index d626067c..5421284b 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -134,7 +134,6 @@ void *call_thread(void *pd) | |||
134 | CallControl *BobCC = ((thread_data *) pd)->BobCC; | 134 | CallControl *BobCC = ((thread_data *) pd)->BobCC; |
135 | uint32_t friend_number = ((thread_data *) pd)->friend_number; | 135 | uint32_t friend_number = ((thread_data *) pd)->friend_number; |
136 | 136 | ||
137 | |||
138 | memset(AliceCC, 0, sizeof(CallControl)); | 137 | memset(AliceCC, 0, sizeof(CallControl)); |
139 | memset(BobCC, 0, sizeof(CallControl)); | 138 | memset(BobCC, 0, sizeof(CallControl)); |
140 | 139 | ||
@@ -163,15 +162,10 @@ void *call_thread(void *pd) | |||
163 | 162 | ||
164 | c_sleep(30); | 163 | c_sleep(30); |
165 | 164 | ||
166 | int16_t PCM[960]; | 165 | int16_t *PCM = calloc(960, sizeof(int16_t)); |
167 | uint8_t video_y[800 * 600]; | 166 | uint8_t *video_y = calloc(800 * 600, sizeof(uint8_t)); |
168 | uint8_t video_u[800 * 600 / 2]; | 167 | uint8_t *video_u = calloc(800 * 600 / 2, sizeof(uint8_t)); |
169 | uint8_t video_v[800 * 600 / 2]; | 168 | uint8_t *video_v = calloc(800 * 600 / 2, sizeof(uint8_t)); |
170 | |||
171 | memset(PCM, 0, sizeof(PCM)); | ||
172 | memset(video_y, 0, sizeof(video_y)); | ||
173 | memset(video_u, 0, sizeof(video_u)); | ||
174 | memset(video_v, 0, sizeof(video_v)); | ||
175 | 169 | ||
176 | time_t start_time = time(NULL); | 170 | time_t start_time = time(NULL); |
177 | 171 | ||
@@ -199,6 +193,11 @@ void *call_thread(void *pd) | |||
199 | 193 | ||
200 | c_sleep(30); | 194 | c_sleep(30); |
201 | 195 | ||
196 | free(PCM); | ||
197 | free(video_y); | ||
198 | free(video_u); | ||
199 | free(video_v); | ||
200 | |||
202 | printf ("Closing thread\n"); | 201 | printf ("Closing thread\n"); |
203 | pthread_exit(NULL); | 202 | pthread_exit(NULL); |
204 | } | 203 | } |