- Timestamp:
- Jan 4, 2008 6:00:11 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/samples/sndtest.c
r974 r1663 80 80 pj_bool_t running; 81 81 pj_bool_t has_error; 82 pj_mutex_t *mutex; 82 83 83 84 struct stream_data capture_data; … … 137 138 struct stream_data *strm_data = &test_data->playback_data; 138 139 140 pj_mutex_lock(test_data->mutex); 141 139 142 /* Skip frames when test is not started or test has finished */ 140 143 if (!test_data->running) { 141 144 pj_bzero(output, size); 145 146 pj_mutex_unlock(test_data->mutex); 142 147 return PJ_SUCCESS; 143 148 } … … 180 185 181 186 pj_bzero(output, size); 187 188 pj_mutex_unlock(test_data->mutex); 189 182 190 return PJ_SUCCESS; 183 191 } … … 190 198 struct stream_data *strm_data = &test_data->capture_data; 191 199 200 pj_mutex_lock(test_data->mutex); 201 192 202 PJ_UNUSED_ARG(input); 193 203 PJ_UNUSED_ARG(size); … … 195 205 /* Skip frames when test is not started or test has finished */ 196 206 if (!test_data->running) { 207 pj_mutex_unlock(test_data->mutex); 197 208 return PJ_SUCCESS; 198 209 } … … 234 245 } 235 246 247 pj_mutex_unlock(test_data->mutex); 236 248 return PJ_SUCCESS; 237 249 } … … 354 366 355 367 356 static int perform_test( int dev_id, pjmedia_dir dir,368 static int perform_test(pj_pool_t *pool, int dev_id, pjmedia_dir dir, 357 369 unsigned clock_rate, unsigned samples_per_frame, 358 370 unsigned nchannel, int verbose) … … 362 374 struct test_data test_data; 363 375 pjmedia_snd_stream_info si; 364 365 376 366 377 /* 367 378 * Init test parameters … … 372 383 test_data.samples_per_frame = samples_per_frame; 373 384 test_data.channel_count = nchannel; 385 386 pj_mutex_create_simple(pool, "sndtest", &test_data.mutex); 374 387 375 388 /* … … 467 480 start_diff = test_data.capture_data.first_timestamp- 468 481 test_data.playback_data.first_timestamp; 469 drift = end_diff - start_diff; 482 drift = end_diff > start_diff? end_diff - start_diff : 483 start_diff - end_diff; 470 484 471 485 PJ_LOG(3,(THIS_FILE, " Checking for clock drifts:")); … … 508 522 { 509 523 pj_caching_pool cp; 524 pj_pool_t *pool; 510 525 pjmedia_endpt *med_endpt; 511 526 int id = -1, verbose = 0; … … 533 548 /* Must create a pool factory before we can allocate any memory. */ 534 549 pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0); 550 551 /* Also create pool for misc purposes */ 552 pool = pj_pool_create(&cp.factory, "sndtest", 1000, 1000, NULL); 535 553 536 554 /* … … 589 607 590 608 591 status = perform_test( id, PJMEDIA_DIR_CAPTURE_PLAYBACK,609 status = perform_test(pool, id, PJMEDIA_DIR_CAPTURE_PLAYBACK, 592 610 clock_rate, frame, channel, verbose); 593 if (status != 0) 594 return 1; 595 611 612 pjmedia_endpt_destroy(med_endpt); 613 pj_pool_release(pool); 614 pj_caching_pool_destroy(&cp); 615 pj_shutdown(); 596 616 597 return 0;617 return status == PJ_SUCCESS ? 0 : 1; 598 618 } 599 619
Note: See TracChangeset
for help on using the changeset viewer.