- Timestamp:
- Dec 10, 2010 11:04:30 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip-apps/src/samples/latency.c
r2394 r3392 61 61 lat_max = 0; 62 62 63 samples_per_frame = wav->info.samples_per_frame;63 samples_per_frame = PJMEDIA_PIA_SPF(&wav->info); 64 64 frm.buf = pj_pool_alloc(pool, samples_per_frame * 2); 65 65 frm.size = samples_per_frame * 2; … … 77 77 } 78 78 79 if (read < 2 * wav->info.clock_rate) {79 if (read < 2 * PJMEDIA_PIA_SRATE(&wav->info)) { 80 80 puts("Error: too short"); 81 81 return -1; … … 83 83 84 84 start_pos = 0; 85 while (start_pos < len/2 - wav->info.clock_rate) {85 while (start_pos < len/2 - PJMEDIA_PIA_SRATE(&wav->info)) { 86 86 int max_signal = 0; 87 87 unsigned max_signal_pos = start_pos; … … 91 91 92 92 /* Get the largest signal in the next 0.7s */ 93 for (i=start_pos; i<start_pos + wav->info.clock_rate* 700 / 1000; ++i) {93 for (i=start_pos; i<start_pos + PJMEDIA_PIA_SRATE(&wav->info) * 700 / 1000; ++i) { 94 94 if (abs(buf[i]) > max_signal) { 95 95 max_signal = abs(buf[i]); … … 99 99 100 100 /* Advance 10ms from max_signal_pos */ 101 pos = max_signal_pos + 10 * wav->info.clock_rate/ 1000;101 pos = max_signal_pos + 10 * PJMEDIA_PIA_SRATE(&wav->info) / 1000; 102 102 103 103 /* Get the largest signal in the next 500ms */ 104 104 max_signal = 0; 105 105 max_echo_pos = pos; 106 for (i=pos; i<pos+ wav->info.clock_rate/2; ++i) {106 for (i=pos; i<pos+PJMEDIA_PIA_SRATE(&wav->info)/2; ++i) { 107 107 if (abs(buf[i]) > max_signal) { 108 108 max_signal = abs(buf[i]); … … 111 111 } 112 112 113 lat = (max_echo_pos - max_signal_pos) * 1000 / wav->info.clock_rate;113 lat = (max_echo_pos - max_signal_pos) * 1000 / PJMEDIA_PIA_SRATE(&wav->info); 114 114 115 115 #if 0 … … 125 125 126 126 /* Advance next loop */ 127 start_pos += wav->info.clock_rate;127 start_pos += PJMEDIA_PIA_SRATE(&wav->info); 128 128 } 129 129
Note: See TracChangeset
for help on using the changeset viewer.