| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 327 |
| 328 printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", | 328 printf("Running %d loops with %d ms sleep. Mark every %d loop. \n", |
| 329 numberOfLoops, loopSleep, markInterval); | 329 numberOfLoops, loopSleep, markInterval); |
| 330 printf("Test will take approximately %d minutes. \n", | 330 printf("Test will take approximately %d minutes. \n", |
| 331 numberOfLoops * loopSleep / 1000 / 60 + 1); | 331 numberOfLoops * loopSleep / 1000 / 60 + 1); |
| 332 | 332 |
| 333 srand((unsigned int) time(NULL)); | 333 srand((unsigned int) time(NULL)); |
| 334 int rnd(0); | 334 int rnd(0); |
| 335 | 335 |
| 336 // Start extra thread | 336 // Start extra thread |
| 337 _ptrExtraApiThread = PlatformThread::CreateThread(RunExtraApi, this, | 337 _ptrExtraApiThread.reset( |
| 338 "StressTestExtraApiThread"); | 338 new rtc::PlatformThread(RunExtraApi, this, "StressTestExtraApiThread")); |
| 339 VALIDATE_STRESS(!_ptrExtraApiThread->Start()); | 339 _ptrExtraApiThread->Start(); |
| 340 | 340 |
| 341 // Some possible extensions include: | 341 // Some possible extensions include: |
| 342 // Add more API calls to randomize | 342 // Add more API calls to randomize |
| 343 // More threads | 343 // More threads |
| 344 // Different sleep times (fixed or random). | 344 // Different sleep times (fixed or random). |
| 345 // Make sure audio is OK after test has finished. | 345 // Make sure audio is OK after test has finished. |
| 346 | 346 |
| 347 // Call random API functions here and in extra thread, ignore any error | 347 // Call random API functions here and in extra thread, ignore any error |
| 348 for (i = 0; i < numberOfLoops; ++i) { | 348 for (i = 0; i < numberOfLoops; ++i) { |
| 349 // This part should be equal to the marked part in the extra thread | 349 // This part should be equal to the marked part in the extra thread |
| 350 // --- BEGIN --- | 350 // --- BEGIN --- |
| 351 rnd = rand(); | 351 rnd = rand(); |
| 352 if (rnd < (RAND_MAX / 2)) { | 352 if (rnd < (RAND_MAX / 2)) { |
| 353 // Start playout | 353 // Start playout |
| 354 base->StartPlayout(0); | 354 base->StartPlayout(0); |
| 355 } else { | 355 } else { |
| 356 // Stop playout | 356 // Stop playout |
| 357 base->StopPlayout(0); | 357 base->StopPlayout(0); |
| 358 } | 358 } |
| 359 // --- END --- | 359 // --- END --- |
| 360 | 360 |
| 361 if (!(i % markInterval)) | 361 if (!(i % markInterval)) |
| 362 MARK(); | 362 MARK(); |
| 363 SleepMs(loopSleep); | 363 SleepMs(loopSleep); |
| 364 } | 364 } |
| 365 ANL(); | 365 ANL(); |
| 366 | 366 |
| 367 // Stop extra thread | 367 // Stop extra thread |
| 368 VALIDATE_STRESS(!_ptrExtraApiThread->Stop()); | 368 _ptrExtraApiThread->Stop(); |
| 369 | 369 |
| 370 ///////////// End test ///////////// | 370 ///////////// End test ///////////// |
| 371 | 371 |
| 372 // Terminate | 372 // Terminate |
| 373 VALIDATE_STRESS(base->Terminate()); // Deletes all channels | 373 VALIDATE_STRESS(base->Terminate()); // Deletes all channels |
| 374 | 374 |
| 375 printf("Test finished \n"); | 375 printf("Test finished \n"); |
| 376 | 376 |
| 377 return 0; | 377 return 0; |
| 378 } | 378 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 399 } else { | 399 } else { |
| 400 // Stop playout | 400 // Stop playout |
| 401 base->StopPlayout(0); | 401 base->StopPlayout(0); |
| 402 } | 402 } |
| 403 // --- END --- | 403 // --- END --- |
| 404 | 404 |
| 405 return true; | 405 return true; |
| 406 } | 406 } |
| 407 | 407 |
| 408 } // namespace voetest | 408 } // namespace voetest |
| OLD | NEW |