Changeset 947:d2ba2ac865ab in mediastreamer2
Legend:
- Unmodified
- Added
- Removed
-
src/aqsnd.c
r946 r947 72 72 #define kNumberAudioInDataBuffers 4 73 73 74 float gain_volume_in=1.0;75 float gain_volume_out=1.0;76 bool gain_changed_in = true;77 bool gain_changed_out = true;74 static float gain_volume_in=1.0; 75 static float gain_volume_out=1.0; 76 static bool gain_changed_in = true; 77 static bool gain_changed_out = true; 78 78 79 79 #ifdef TARGET_OS_IPHONE … … 151 151 case MS_SND_CARD_PLAYBACK: 152 152 case MS_SND_CARD_MASTER: 153 {154 }155 153 return (int)(gain_volume_out*100.0f); 156 154 case MS_SND_CARD_CAPTURE: -
src/macsnd.c
r945 r947 56 56 MSFilter *ms_ca_write_new(MSSndCard *card); 57 57 58 static float gain_volume_in=1.0; 59 static float gain_volume_out=1.0; 60 static bool gain_changed_in = true; 61 static bool gain_changed_out = true; 62 58 63 typedef struct CAData{ 59 64 int dev; … … 88 93 static void cacard_set_level(MSSndCard *card, MSSndCardMixerElem e, int percent) 89 94 { 95 switch(e){ 96 case MS_SND_CARD_PLAYBACK: 97 case MS_SND_CARD_MASTER: 98 gain_volume_out =((float)percent)/100.0f; 99 gain_changed_out = true; 100 return; 101 case MS_SND_CARD_CAPTURE: 102 gain_volume_in =((float)percent)/100.0f; 103 gain_changed_in = true; 104 return; 105 default: 106 ms_warning("cacard_set_level: unsupported command."); 107 } 90 108 } 91 109 92 110 static int cacard_get_level(MSSndCard *card, MSSndCardMixerElem e) 93 111 { 112 switch(e){ 113 case MS_SND_CARD_PLAYBACK: 114 case MS_SND_CARD_MASTER: 115 return (int)(gain_volume_out*100.0f); 116 case MS_SND_CARD_CAPTURE: 117 return (int)(gain_volume_in*100.0f); 118 default: 119 ms_warning("cacard_get_level: unsupported command."); 120 } 94 121 return -1; 95 122 } … … 537 564 memcpy(rm->b_wptr, d->fMSBuffer->mBuffers[0].mData, ActualOutputFrames*2); 538 565 rm->b_wptr+=ActualOutputFrames*2; 566 567 if (gain_volume_in != 1.0f) 568 { 569 int16_t *ptr=(int16_t *)rm->b_rptr; 570 for (;ptr<(int16_t *)rm->b_wptr;ptr++) 571 { 572 *ptr=(int16_t)(((float)(*ptr))*gain_volume_in); 573 } 574 } 575 539 576 ms_mutex_lock(&d->mutex); 540 577 putq(&d->rq,rm); … … 555 592 void *inInputDataProcUserData=NULL; 556 593 CAData *d=(CAData*)inRefCon; 594 if (gain_changed_out == true) 595 { 596 err = AudioUnitSetParameter(d->caOutAudioUnit, kAudioUnitParameterUnit_LinearGain, 597 kAudioUnitScope_Global, 0, (Float32)gain_volume_out, 0); 598 if(err != noErr) 599 { 600 ms_error("failed to set output volume %i", err); 601 } 602 gain_changed_out = false; 603 err= noErr; 604 } 605 606 557 607 if(d->write_started != FALSE) { 558 608 AudioStreamPacketDescription* outPacketDescription = NULL; … … 664 714 if(result != noErr) 665 715 { 666 fprintf(stderr, "failed to get audio sample size\n");716 ms_error("failed to get audio sample size"); 667 717 return -1; 668 718 } … … 671 721 if(result != noErr) 672 722 { 723 ms_error("failed to AudioUnitInitialize input %i", result); 673 724 return -1; 674 725 } … … 679 730 if(d->fAudioBuffer == NULL) 680 731 { 681 fprintf(stderr, "failed to allocate buffers\n");732 ms_error("failed to allocate buffers fAudioBuffer"); 682 733 return -1; 683 734 } … … 687 738 if(d->fMSBuffer == NULL) 688 739 { 689 fprintf(stderr, "failed to allocate buffers\n");740 ms_error("failed to allocate buffers fMSBuffer"); 690 741 return -1; 691 742 } 743 692 744 return 0; 693 745 } … … 776 828 if(result != noErr) 777 829 { 830 ms_error("failed to AudioUnitInitialize output %i", result); 778 831 return -1; 779 832 }
Note: See TracChangeset
for help on using the changeset viewer.
