My app uses Audio Unit to play mp3 files in IOS, but when the screen off, the sound stopped

StackOverflow https://stackoverflow.com/questions/18407209

  •  26-06-2022
  •  | 
  •  

문제

My app uses AudioUnit to play mp3 files, totally used RemoteIO, NewTimePitch, AUConverter and MultiChannelMixer 4 AudioUnits.

My app could play when the screen is locked, but it can NOT play while the screen is off!

Even more Strangely, this issue only happens in Iphone4S(v6.1.3), but works fine in Iphone5(v6.1.4)!

here is my audio-unit setting code:

// connect audio unit: converter -> timepitch -> output
OSExcute( AUGraphConnectNodeInput(processingGraph, converterNode, 0, timepitchNode, 0) );
OSExcute( AUGraphConnectNodeInput(processingGraph, timepitchNode, 0, mixerNode, 0) );
OSExcute( AUGraphConnectNodeInput(processingGraph, mixerNode, 0, eqNode, 0) );
OSExcute( AUGraphConnectNodeInput(processingGraph, eqNode, 0, outputNode, 0) );

// try to fix no sound issue, but does not work
UInt32 maximumFramesPerSlice = 4096;    
OSExcute( AudioUnitSetProperty(mixerUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0, &maximumFramesPerSlice, sizeof (maximumFramesPerSlice)));
도움이 되었습니까?

해결책

I have fixed this issue. The solution is: Set kAudioUnitProperty_MaximumFramesPerSlice to 4096 for EVERY audiounit except RemoteIO unit.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top