Changeset 2313
- Timestamp:
- Sep 24, 2008 9:38:55 AM (16 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/tonegen.h
r2284 r2313 66 66 short volume; /**< Volume (1-32767), or 0 for default, which 67 67 PJMEDIA_TONEGEN_VOLUME will be used. */ 68 short flags; /**< Currently internal flags, must be 0 */ 68 69 } pjmedia_tone_desc; 69 70 -
pjproject/trunk/pjmedia/src/pjmedia/tonegen.c
r2305 r2313 343 343 #endif 344 344 345 enum flags 346 { 347 PJMEDIA_TONE_INITIALIZED = 1, 348 PJMEDIA_TONE_ENABLE_FADE = 2 349 }; 350 345 351 struct tonegen 346 352 { … … 350 356 unsigned options; 351 357 unsigned playback_options; 352 pj_bool_t has_fading; /* Enable fade-in and fade-out */353 358 unsigned fade_in_len; /* fade in for this # of samples */ 354 359 unsigned fade_out_len; /* fade out for this # of samples*/ … … 439 444 tonegen->digit_map = &digit_map; 440 445 441 tonegen->has_fading = PJ_TRUE;442 446 tonegen->fade_in_len = PJMEDIA_TONEGEN_FADE_IN_TIME * clock_rate / 1000; 443 447 tonegen->fade_out_len = PJMEDIA_TONEGEN_FADE_OUT_TIME * clock_rate / 1000; … … 596 600 } 597 601 598 if (tonegen->cur_digit > tonegen->count) {602 if (tonegen->cur_digit >= tonegen->count) { 599 603 /* After we're finished with the last digit, we have played all 600 604 * the digits … … 621 625 622 626 while (dst < end) { 623 constpjmedia_tone_desc *dig = &tonegen->digits[tonegen->cur_digit];627 pjmedia_tone_desc *dig = &tonegen->digits[tonegen->cur_digit]; 624 628 unsigned required, cnt, on_samp, off_samp; 625 629 … … 629 633 630 634 /* Init tonegen */ 631 if (tonegen->dig_samples == 0) { 635 if (tonegen->dig_samples == 0 && 636 (tonegen->count!=1 || !(dig->flags & PJMEDIA_TONE_INITIALIZED))) 637 { 632 638 init_generate_tone(&tonegen->state, port->info.clock_rate, 633 639 dig->freq1, dig->freq2, dig->volume); 640 dig->flags |= PJMEDIA_TONE_INITIALIZED; 641 if (tonegen->cur_digit > 0) { 642 /* Clear initialized flag of previous digit */ 643 tonegen->digits[tonegen->cur_digit-1].flags &= 644 (~PJMEDIA_TONE_INITIALIZED); 645 } 634 646 } 635 647 … … 646 658 required -= cnt; 647 659 648 if (tonegen->has_fading && tonegen->dig_samples == cnt) { 660 if ((dig->flags & PJMEDIA_TONE_ENABLE_FADE) && 661 tonegen->dig_samples == cnt) 662 { 649 663 /* Fade in */ 650 664 short *samp = (dst - cnt); … … 663 677 } 664 678 } 665 } else if (tonegen->has_fading && tonegen->dig_samples==on_samp) { 679 } else if ((dig->flags & PJMEDIA_TONE_ENABLE_FADE) && 680 tonegen->dig_samples==on_samp) 681 { 666 682 /* Fade out */ 667 683 if (cnt > tonegen->fade_out_len) … … 772 788 * wants to play this tone continuously (e.g. dial tone). 773 789 */ 774 tonegen->has_fading = PJ_TRUE;775 790 for (i=0; i<count; ++i) { 776 791 pjmedia_tone_desc *t = &tonegen->digits[i+tonegen->count]; … … 779 794 else if (t->volume < 0) 780 795 t->volume = (short) -t->volume; 781 if (t->off_msec == 0) 782 tonegen->has_fading = PJ_FALSE; 796 /* Reset flags */ 797 t->flags = 0; 798 if (t->off_msec != 0) 799 t->flags |= PJMEDIA_TONE_ENABLE_FADE; 783 800 } 784 801
Note: See TracChangeset
for help on using the changeset viewer.