Changeset 2757 for pjproject/trunk
- Timestamp:
- Jun 9, 2009 1:05:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_common.c
r2755 r2757 53 53 54 54 pjmedia_delay_buf *delay_buf; 55 pj_int16_t *frm_buf; 55 56 }; 56 57 … … 153 154 ec->pool = pool; 154 155 ec->obj_name = pool->obj_name; 156 ec->samples_per_frame = samples_per_frame; 157 ec->frm_buf = (pj_int16_t*)pj_pool_alloc(pool, samples_per_frame<<1); 155 158 pj_list_init(&ec->lat_buf); 156 159 pj_list_init(&ec->lat_free); … … 275 278 pj_int16_t *play_frm ) 276 279 { 280 /* Playing frame should be stored, as it will be used by echo_capture() 281 * as reference frame, delay buffer is used for storing the playing frames 282 * as in case there was clock drift between mic & speaker. 283 * 284 * Ticket #830: 285 * Note that pjmedia_delay_buf_put() may modify the input frame and those 286 * modified frames may not be smooth, i.e: if there were two or more 287 * consecutive pjmedia_delay_buf_get() before next pjmedia_delay_buf_put(), 288 * so we'll just feed the delay buffer with the copy of playing frame, 289 * instead of the original playing frame. However this will cause the EC 290 * uses slight 'different' frames (for reference) than actually played 291 * by the speaker. 292 */ 293 pjmedia_copy_samples(echo->frm_buf, play_frm, 294 echo->samples_per_frame); 295 pjmedia_delay_buf_put(echo->delay_buf, echo->frm_buf); 296 277 297 if (!echo->lat_ready) { 278 298 /* We've not built enough latency in the buffer, so put this frame … … 284 304 echo->lat_ready = PJ_TRUE; 285 305 PJ_LOG(5,(echo->obj_name, "Latency bufferring complete")); 286 pjmedia_delay_buf_put(echo->delay_buf, play_frm);287 306 return PJ_SUCCESS; 288 307 } … … 291 310 pj_list_erase(frm); 292 311 293 pjmedia_copy_samples(frm->buf, play_frm, echo->samples_per_frame); 312 /* Move one frame from delay buffer to the latency buffer. */ 313 pjmedia_delay_buf_get(echo->delay_buf, echo->frm_buf); 314 pjmedia_copy_samples(frm->buf, echo->frm_buf, echo->samples_per_frame); 294 315 pj_list_push_back(&echo->lat_buf, frm); 295 296 } else {297 /* Latency buffer is ready (full), so we put this frame in the298 * delay buffer.299 */300 pjmedia_delay_buf_put(echo->delay_buf, play_frm);301 316 } 302 317
Note: See TracChangeset
for help on using the changeset viewer.