diff --git a/StreamingKit-head.podspec b/StreamingKit-head.podspec index 436d5c1..1911e7e 100644 --- a/StreamingKit-head.podspec +++ b/StreamingKit-head.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.platform = :ios s.requires_arc = true s.source_files = 'StreamingKit/StreamingKit/*.{h,m}' - s.ios.deployment_target = '4.3' + s.ios.deployment_target = '5.0' s.ios.frameworks = 'SystemConfiguration', 'CFNetwork', 'CoreFoundation', 'AudioToolbox' s.osx.deployment_target = '10.7' s.osx.frameworks = 'SystemConfiguration', 'CFNetwork', 'CoreFoundation', 'AudioToolbox', 'AudioUnit' diff --git a/StreamingKit.podspec b/StreamingKit.podspec index c5e80df..8f440a8 100644 --- a/StreamingKit.podspec +++ b/StreamingKit.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.platform = :ios s.requires_arc = true s.source_files = 'StreamingKit/StreamingKit/*.{h,m}' - s.ios.deployment_target = '4.3' + s.ios.deployment_target = '5.0' s.ios.frameworks = 'SystemConfiguration', 'CFNetwork', 'CoreFoundation', 'AudioToolbox' s.osx.deployment_target = '10.7' s.osx.frameworks = 'SystemConfiguration', 'CFNetwork', 'CoreFoundation', 'AudioToolbox', 'AudioUnit' diff --git a/StreamingKit/StreamingKit.xcodeproj/project.pbxproj b/StreamingKit/StreamingKit.xcodeproj/project.pbxproj index e013273..5d6b289 100644 --- a/StreamingKit/StreamingKit.xcodeproj/project.pbxproj +++ b/StreamingKit/StreamingKit.xcodeproj/project.pbxproj @@ -693,7 +693,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 4.3; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; @@ -724,7 +724,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 4.3; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; SDKROOT = iphoneos; VALIDATE_PRODUCT = YES; }; diff --git a/StreamingKit/StreamingKit/STKAudioPlayer.m b/StreamingKit/StreamingKit/STKAudioPlayer.m index 3c698e8..f9ad2ae 100755 --- a/StreamingKit/StreamingKit/STKAudioPlayer.m +++ b/StreamingKit/StreamingKit/STKAudioPlayer.m @@ -3190,6 +3190,16 @@ static OSStatus OutputRenderCallback(void* inRefCon, AudioUnitRenderActionFlags* return peakPowerDb[channelNumber]; } +-(void) setPeakPowerInDecibelsForChannel:(NSUInteger)channelNumber andPower: (Float32)power +{ + if (channelNumber >= canonicalAudioStreamBasicDescription.mChannelsPerFrame) + { + return; + } + + peakPowerDb[channelNumber] = power; +} + -(float) averagePowerInDecibelsForChannel:(NSUInteger)channelNumber { if (channelNumber >= canonicalAudioStreamBasicDescription.mChannelsPerFrame) @@ -3200,6 +3210,16 @@ static OSStatus OutputRenderCallback(void* inRefCon, AudioUnitRenderActionFlags* return averagePowerDb[channelNumber]; } +-(void) setAveragePowerInDecibelsForChannel:(NSUInteger)channelNumber andPower: (Float32)power +{ + if (channelNumber >= canonicalAudioStreamBasicDescription.mChannelsPerFrame) + { + return; + } + + averagePowerDb[channelNumber] = power; +} + -(BOOL) meteringEnabled { return self->meteringEnabled; @@ -3237,6 +3257,8 @@ static OSStatus OutputRenderCallback(void* inRefCon, AudioUnitRenderActionFlags* } else { + __weak STKAudioPlayer* weakSelf = self; + [self appendFrameFilterWithName:@"STKMeteringFilter" block:^(UInt32 channelsPerFrame, UInt32 bytesPerFrame, UInt32 frameCount, void* frames) { SInt16* samples16 = (SInt16*)frames; @@ -3279,17 +3301,17 @@ static OSStatus OutputRenderCallback(void* inRefCon, AudioUnitRenderActionFlags* return; } - peakPowerDb[0] = MIN(MAX(decibelsLeft, -60), 0); - peakPowerDb[1] = MIN(MAX(decibelsRight, -60), 0); + [weakSelf setPeakPowerInDecibelsForChannel:0 andPower:MIN(MAX(decibelsLeft, -60), 0)]; + [weakSelf setPeakPowerInDecibelsForChannel:1 andPower:MIN(MAX(decibelsRight, -60), 0)]; if (countLeft > 0) { - averagePowerDb[0] = MIN(MAX(totalValueLeft / frameCount, -60), 0); + [weakSelf setAveragePowerInDecibelsForChannel:0 andPower:MIN(MAX(totalValueLeft / frameCount, -60), 0)]; } if (countRight != 0) { - averagePowerDb[1] = MIN(MAX(totalValueRight / frameCount, -60), 0); + [weakSelf setAveragePowerInDecibelsForChannel:1 andPower:MIN(MAX(totalValueRight / frameCount, -60), 0)]; } }]; }