Ignore:
Timestamp:
Jan 4, 2008 6:19:40 PM (14 years ago)
Author:
bennylp
Message:

Ticket #438 (Workaround for frame bursts from audio devices): added delay buffer implementation in pjmedia

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/sound_port.c

    r1296 r1664  
    1818 */ 
    1919#include <pjmedia/sound_port.h> 
     20#include <pjmedia/delaybuf.h> 
    2021#include <pjmedia/echo.h> 
    2122#include <pjmedia/errno.h> 
     
    6364    unsigned             samples_per_frame; 
    6465    unsigned             bits_per_sample; 
     66 
     67#if PJMEDIA_SOUND_USE_DELAYBUF 
     68    pjmedia_delay_buf   *delay_buf; 
     69#endif 
    6570}; 
    6671 
     
    9398    frame.timestamp.u32.hi = 0; 
    9499    frame.timestamp.u32.lo = timestamp; 
     100 
     101#if PJMEDIA_SOUND_USE_DELAYBUF 
     102    status = pjmedia_delay_buf_get(snd_port->delay_buf, (pj_int16_t*)output); 
     103    if (status != PJ_SUCCESS) { 
     104        pj_bzero(output, size); 
     105    } 
     106 
     107    pjmedia_port_put_frame(port, &frame); 
     108#endif 
    95109 
    96110    status = pjmedia_port_get_frame(port, &frame); 
     
    186200    } 
    187201 
     202#if PJMEDIA_SOUND_USE_DELAYBUF 
     203    PJ_UNUSED_ARG(size); 
     204    PJ_UNUSED_ARG(timestamp); 
     205    PJ_UNUSED_ARG(frame); 
     206    pjmedia_delay_buf_put(snd_port->delay_buf, (pj_int16_t*)input); 
     207#else 
    188208    frame.buf = (void*)input; 
    189209    frame.size = size; 
     
    192212 
    193213    pjmedia_port_put_frame(port, &frame); 
     214#endif 
    194215 
    195216    return PJ_SUCCESS; 
     
    325346{ 
    326347    pjmedia_snd_port *snd_port; 
     348    pj_status_t status; 
    327349 
    328350    PJ_ASSERT_RETURN(pool && p_port, PJ_EINVAL); 
     
    339361    snd_port->samples_per_frame = samples_per_frame; 
    340362    snd_port->bits_per_sample = bits_per_sample; 
     363     
     364#if PJMEDIA_SOUND_USE_DELAYBUF 
     365    status = pjmedia_delay_buf_create(pool, "snd_buff", samples_per_frame,  
     366                                      16, &snd_port->delay_buf); 
     367    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
     368#else 
     369    PJ_UNUSED_ARG(status); 
     370#endif 
    341371 
    342372    *p_port = snd_port; 
Note: See TracChangeset for help on using the changeset viewer.