- Timestamp:
- Mar 3, 2010 2:47:35 PM (15 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_common.c
r2757 r3115 25 25 #include <pj/list.h> 26 26 #include <pj/log.h> 27 #include <pj/math.h> 27 28 #include <pj/pool.h> 28 29 #include "echo_internal.h" … … 47 48 48 49 pj_bool_t lat_ready; /* lat_buf has been filled in. */ 49 unsigned lat_target_cnt;/* Target number of frames in lat_buf */50 unsigned lat_buf_cnt; /* Actual number of frames in lat_buf */51 50 struct frame lat_buf; /* Frame queue for delayed playback */ 52 51 struct frame lat_free; /* Free frame list. */ … … 145 144 pjmedia_echo_state **p_echo ) 146 145 { 147 unsigned ptime ;146 unsigned ptime, lat_cnt; 148 147 pjmedia_echo_state *ec; 149 148 pj_status_t status; … … 195 194 /* Create latency buffers */ 196 195 ptime = samples_per_frame * 1000 / clock_rate; 197 if (latency_ms == 0) { 196 if (latency_ms > ptime) { 197 /* Normalize latency with delaybuf/WSOLA latency */ 198 latency_ms -= PJ_MIN(ptime, PJMEDIA_WSOLA_DELAY_MSEC); 199 } 200 if (latency_ms < ptime) { 198 201 /* Give at least one frame delay to simplify programming */ 199 202 latency_ms = ptime; 200 203 } 201 ec->lat_target_cnt = latency_ms / ptime; 202 if (ec->lat_target_cnt != 0) { 203 unsigned i; 204 for (i=0; i < ec->lat_target_cnt; ++i) { 205 struct frame *frm; 206 207 frm = (struct frame*) pj_pool_alloc(pool, (samples_per_frame<<1) + 208 sizeof(struct frame)); 209 pj_list_push_back(&ec->lat_free, frm); 210 } 211 } else { 212 ec->lat_ready = PJ_TRUE; 204 lat_cnt = latency_ms / ptime; 205 while (lat_cnt--) { 206 struct frame *frm; 207 208 frm = (struct frame*) pj_pool_alloc(pool, (samples_per_frame<<1) + 209 sizeof(struct frame)); 210 pj_list_push_back(&ec->lat_free, frm); 213 211 } 214 212 -
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r2755 r3115 564 564 //delay_ms = (si.rec_latency + si.play_latency) * 1000 / 565 565 // snd_port->clock_rate; 566 delay_ms = prm.output_latency_ms; 566 /* Set EC latency to 3/4 of output latency to reduce the 567 * possibility of missing/late reference frame. 568 */ 569 delay_ms = prm.output_latency_ms * 3/4; 567 570 status = pjmedia_echo_create2(pool, snd_port->clock_rate, 568 571 snd_port->channel_count, -
pjproject/trunk/pjsip-apps/src/samples/aectest.c
r2394 r3115 56 56 "\n" 57 57 " options:\n" 58 " -d The delay between playback and capture in ms. Default is zero.\n" 58 " -d The delay between playback and capture in ms, at least 25 ms.\n" 59 " Default is 25 ms. See note below. \n" 59 60 " -l Set the echo tail length in ms. Default is 200 ms \n" 60 61 " -r Set repeat count (default=1) \n" 61 62 " -a Algorithm: 0=default, 1=speex, 3=echo suppress \n" 62 " -i Interactive \n"; 63 " -i Interactive \n" 64 "\n" 65 " Note that for the AEC internal buffering mechanism, it is required\n" 66 " that the echoed signal (in REC.WAV) is delayed from the \n" 67 " corresponding reference signal (in PLAY.WAV) at least as much as \n" 68 " frame time + PJMEDIA_WSOLA_DELAY_MSEC. In this application, frame \n" 69 " time is 20 ms and default PJMEDIA_WSOLA_DELAY_MSEC is 5 ms, hence \n" 70 " 25 ms delay is the minimum value. \n"; 63 71 64 72 /* … … 92 100 pjmedia_frame play_frame, rec_frame; 93 101 unsigned opt = 0; 94 unsigned latency_ms = 0;102 unsigned latency_ms = 25; 95 103 unsigned tail_ms = TAIL_LENGTH; 96 104 pj_timestamp t0, t1; … … 102 110 case 'd': 103 111 latency_ms = atoi(pj_optarg); 112 if (latency_ms < 25) { 113 puts("Invalid delay"); 114 puts(desc); 115 } 104 116 break; 105 117 case 'l': … … 128 140 repeat = atoi(pj_optarg); 129 141 if (repeat < 1) { 130 puts("Invalid algorithm");142 puts("Invalid repeat count"); 131 143 puts(desc); 132 144 return 1; … … 252 264 pj_get_timestamp(&t1); 253 265 254 i = pjmedia_wav_writer_port_get_pos(wav_out) * 1000 /266 i = pjmedia_wav_writer_port_get_pos(wav_out) / sizeof(pj_int16_t) * 1000 / 255 267 (wav_out->info.clock_rate * wav_out->info.channel_count); 256 268 PJ_LOG(3,(THIS_FILE, "Processed %3d.%03ds audio",
Note: See TracChangeset
for help on using the changeset viewer.