- Timestamp:
- May 22, 2006 10:28:44 AM (19 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/dsound.c
r467 r469 463 463 464 464 465 /* Raise self priority */ 466 //SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 465 /* Raise self priority. We don't want the audio to be distorted by 466 * system activity. 467 */ 468 SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_HIGHEST); 467 469 468 470 /* Calculate bytes per frame */ -
pjproject/trunk/pjsip-apps/src/samples/sndtest.c
r464 r469 37 37 #define DURATION 10000 38 38 39 /* Max frames per sec. */ 39 /* Skip the first msec from the calculation */ 40 #define SKIP_DURATION 1000 41 42 /* Max frames per sec (to calculate number of delays to keep). */ 40 43 #define MAX_FRAMES_PER_SEC 100 41 44 … … 134 137 struct stream_data *strm_data = &test_data->playback_data; 135 138 139 /* Skip frames when test is not started or test has finished */ 136 140 if (!test_data->running) { 137 141 pj_memset(output, 0, size); … … 139 143 } 140 144 145 /* Save last timestamp seen (to calculate drift) */ 141 146 strm_data->last_timestamp = timestamp; 142 147 143 148 if (strm_data->last_called.u64 == 0) { 144 149 pj_get_timestamp(&strm_data->last_called); 150 /* Init min_delay to one frame */ 145 151 strm_data->min_delay = test_data->samples_per_frame * 1000000 / 146 152 test_data->clock_rate; … … 153 159 pj_get_timestamp(&now); 154 160 161 /* Calculate frame interval */ 155 162 delay = pj_elapsed_usec(&strm_data->last_called, &now); 156 163 if (delay < strm_data->min_delay) … … 161 168 strm_data->last_called = now; 162 169 170 /* Save the frame interval for later calculation */ 163 171 strm_data->delay[strm_data->counter] = delay; 164 172 ++strm_data->counter; 173 174 } else { 175 176 /* No space, can't take anymore frames */ 177 test_data->running = 0; 178 165 179 } 166 180 … … 179 193 PJ_UNUSED_ARG(size); 180 194 195 /* Skip frames when test is not started or test has finished */ 181 196 if (!test_data->running) { 182 197 return PJ_SUCCESS; 183 198 } 184 199 200 /* Save last timestamp seen (to calculate drift) */ 185 201 strm_data->last_timestamp = timestamp; 186 202 187 203 if (strm_data->last_called.u64 == 0) { 188 204 pj_get_timestamp(&strm_data->last_called); 205 /* Init min_delay to one frame */ 189 206 strm_data->min_delay = test_data->samples_per_frame * 1000000 / 190 207 test_data->clock_rate; … … 196 213 197 214 pj_get_timestamp(&now); 198 215 216 /* Calculate frame interval */ 199 217 delay = pj_elapsed_usec(&strm_data->last_called, &now); 200 218 if (delay < strm_data->min_delay) … … 205 223 strm_data->last_called = now; 206 224 225 /* Save the frame interval for later calculation */ 207 226 strm_data->delay[strm_data->counter] = delay; 208 227 ++strm_data->counter; 228 229 } else { 230 231 /* No space, can't take anymore frames */ 232 test_data->running = 0; 233 209 234 } 210 235 … … 228 253 { 229 254 unsigned i, dur; 230 unsigned min_jitter, max_jitter, avg_jitter=0;255 unsigned min_jitter, max_jitter, sum_jitter, avg_jitter=0; 231 256 232 257 PJ_LOG(3,(THIS_FILE, " %s stream report:", title)); … … 276 301 min_jitter = 0xFFFFF; 277 302 max_jitter = 0; 303 sum_jitter = 0; 278 304 279 305 for (i=1; i<strm_data->counter; ++i) { … … 285 311 if (jitter > (int)max_jitter) max_jitter = jitter; 286 312 287 avg_jitter = ((i-1) * avg_jitter + jitter) / i; 288 } 313 sum_jitter += jitter; 314 } 315 316 avg_jitter = (sum_jitter) / (strm_data->counter - 1); 317 289 318 if (max_jitter < WARN_JITTER_USEC) { 290 319 PJ_LOG(3,(THIS_FILE, … … 347 376 348 377 /* Sleep for a while to let sound device "settles" */ 349 pj_thread_sleep( 100);378 pj_thread_sleep(200); 350 379 351 380 … … 359 388 } 360 389 361 /* Let the stream runs for 1 second to get stable result. 390 PJ_LOG(3,(THIS_FILE, 391 " Please wait while test is in progress (~%d secs)..", 392 (DURATION+SKIP_DURATION)/1000)); 393 394 /* Let the stream runs for few msec/sec to get stable result. 362 395 * (capture normally begins with frames available simultaneously). 363 396 */ 364 pj_thread_sleep( 1000);397 pj_thread_sleep(SKIP_DURATION); 365 398 366 399 … … 371 404 * Let the test runs for a while. 372 405 */ 373 PJ_LOG(3,(THIS_FILE,374 " Please wait while test is in progress (~%d secs)..",375 (DURATION/1000)));376 406 pj_thread_sleep(DURATION); 377 407 … … 427 457 PJ_LOG(2,(THIS_FILE, 428 458 " Sound capture is %d samples %s than playback " 429 "at the end of the test (a t the rate about%d samples"459 "at the end of the test (average is %d samples" 430 460 " per second)", 431 461 drift, which,
Note: See TracChangeset
for help on using the changeset viewer.