Ignore:
Timestamp:
Apr 24, 2012 1:09:14 PM (13 years ago)
Author:
bennylp
Message:

Re #1474: merged r4054-r4079

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

  • pjproject/trunk/pjmedia/src/pjmedia/sound_port.c

    r3999 r4082  
    5353    unsigned             bits_per_sample; 
    5454    unsigned             options; 
     55    unsigned             prm_ec_options; 
    5556 
    5657    /* software ec */ 
     
    188189} 
    189190 
     191/* Initialize with default values (zero) */ 
     192PJ_DEF(void) pjmedia_snd_port_param_default(pjmedia_snd_port_param *prm) 
     193{ 
     194    pj_bzero(prm, sizeof(*prm)); 
     195} 
     196 
    190197/* 
    191198 * Start the sound stream. 
     
    227234    if (param_copy.flags & PJMEDIA_AUD_DEV_CAP_EC) { 
    228235        /* EC is wanted */ 
    229         if (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC) { 
     236        if ((snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) == 0 && 
     237            snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC) 
     238        { 
    230239            /* Device supports EC */ 
    231240            /* Nothing to do */ 
    232241        } else { 
    233             /* Device doesn't support EC, remove EC settings from 
     242            /* Application wants to use software EC or device 
     243             * doesn't support EC, remove EC settings from 
    234244             * device parameters 
    235245             */ 
     
    263273                                  snd_port->samples_per_frame); 
    264274 
    265     /* Create software EC if parameter specifies EC but device  
    266      * doesn't support EC. Only do this if the format is PCM! 
     275    /* Create software EC if parameter specifies EC and 
     276     * (app specifically requests software EC or device 
     277     * doesn't support EC). Only do this if the format is PCM! 
    267278     */ 
    268279    if ((snd_port->aud_param.flags & PJMEDIA_AUD_DEV_CAP_EC) && 
    269         (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC)==0 && 
     280        ((snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC)==0 || 
     281         (snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) != 0) && 
    270282        param_copy.ext_fmt.id == PJMEDIA_FORMAT_PCM) 
    271283    { 
     
    278290             
    279291        status = pjmedia_snd_port_set_ec(snd_port, pool,  
    280                                          snd_port->aud_param.ec_tail_ms, 0); 
     292                                         snd_port->aud_param.ec_tail_ms, 
     293                                         snd_port->prm_ec_options); 
    281294        if (status != PJ_SUCCESS) { 
    282295            pjmedia_aud_stream_destroy(snd_port->aud_stream); 
     
    339352    pj_status_t status; 
    340353 
    341     PJ_UNUSED_ARG(options); 
     354    pjmedia_snd_port_param_default(&param); 
    342355 
    343356    status = pjmedia_aud_dev_default_param(rec_id, &param.base); 
     
    353366    param.base.bits_per_sample = bits_per_sample; 
    354367    param.options = options; 
     368    param.ec_options = 0; 
    355369 
    356370    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    372386    pj_status_t status; 
    373387 
    374     PJ_UNUSED_ARG(options); 
     388    pjmedia_snd_port_param_default(&param); 
    375389 
    376390    status = pjmedia_aud_dev_default_param(dev_id, &param.base); 
     
    385399    param.base.bits_per_sample = bits_per_sample; 
    386400    param.options = options; 
     401    param.ec_options = 0; 
    387402 
    388403    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    405420    pj_status_t status; 
    406421 
    407     PJ_UNUSED_ARG(options); 
     422    pjmedia_snd_port_param_default(&param); 
    408423 
    409424    status = pjmedia_aud_dev_default_param(dev_id, &param.base); 
     
    418433    param.base.bits_per_sample = bits_per_sample; 
    419434    param.options = options; 
     435    param.ec_options = 0; 
    420436 
    421437    return pjmedia_snd_port_create2(pool, &param, p_port); 
     
    446462    snd_port->samples_per_frame = prm->base.samples_per_frame; 
    447463    snd_port->bits_per_sample = prm->base.bits_per_sample; 
    448     pj_memcpy(&snd_port->aud_param, prm, sizeof(snd_port->aud_param)); 
     464    pj_memcpy(&snd_port->aud_param, &prm->base, sizeof(snd_port->aud_param)); 
    449465    snd_port->options = prm->options; 
     466    snd_port->prm_ec_options = prm->ec_options; 
    450467 
    451468    ptime_usec = prm->base.samples_per_frame * 1000 / prm->base.channel_count / 
     
    510527 
    511528    /* Determine whether we use device or software EC */ 
    512     if (snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC) { 
     529    if ((snd_port->prm_ec_options & PJMEDIA_ECHO_USE_SW_ECHO) == 0 && 
     530        snd_port->aud_caps & PJMEDIA_AUD_DEV_CAP_EC) 
     531    { 
    513532        /* We use device EC */ 
    514533        pj_bool_t ec_enabled; 
Note: See TracChangeset for help on using the changeset viewer.