Changeset 2305


Ignore:
Timestamp:
Sep 22, 2008 9:29:50 AM (16 years ago)
Author:
bennylp
Message:

More ticket #619: disable fade-in and fade-out if the tone off duration is zero. We assume that application wants to play continuous tone in this case, and the fade in/out feature will cause click noise to be generated

File:
1 edited

Legend:

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

    r2294 r2305  
    350350    unsigned            options; 
    351351    unsigned            playback_options; 
     352    pj_bool_t           has_fading;     /* Enable fade-in and fade-out   */ 
    352353    unsigned            fade_in_len;    /* fade in for this # of samples */ 
    353354    unsigned            fade_out_len;   /* fade out for this # of samples*/ 
     
    438439    tonegen->digit_map = &digit_map; 
    439440 
     441    tonegen->has_fading = PJ_TRUE; 
    440442    tonegen->fade_in_len = PJMEDIA_TONEGEN_FADE_IN_TIME * clock_rate / 1000; 
    441443    tonegen->fade_out_len = PJMEDIA_TONEGEN_FADE_OUT_TIME * clock_rate / 1000; 
     
    644646            required -= cnt; 
    645647 
    646             if (tonegen->dig_samples == cnt) { 
     648            if (tonegen->has_fading && tonegen->dig_samples == cnt) { 
    647649                /* Fade in */ 
    648650                short *samp = (dst - cnt); 
     
    661663                    } 
    662664                } 
    663             } else if (tonegen->dig_samples == on_samp) { 
     665            } else if (tonegen->has_fading && tonegen->dig_samples==on_samp) { 
    664666                /* Fade out */ 
    665667                if (cnt > tonegen->fade_out_len) 
     
    766768              tones, count * sizeof(pjmedia_tone_desc)); 
    767769     
    768     /* Normalize volume */ 
     770    /* Normalize volume, and check if we need to disable fading. 
     771     * Disable fading if tone off time is zero. Application probably 
     772     * wants to play this tone continuously (e.g. dial tone). 
     773     */ 
     774    tonegen->has_fading = PJ_TRUE; 
    769775    for (i=0; i<count; ++i) { 
    770776        pjmedia_tone_desc *t = &tonegen->digits[i+tonegen->count]; 
     
    773779        else if (t->volume < 0) 
    774780            t->volume = (short) -t->volume; 
     781        if (t->off_msec == 0) 
     782            tonegen->has_fading = PJ_FALSE; 
    775783    } 
    776784 
Note: See TracChangeset for help on using the changeset viewer.