1

我有一个 AUGraph 可以使用此设置播放和录制音频:

RemoteIO      ->                                 -> RemoteIO
                  Mulichannel Mixer -> variSpeed 
Read Callback ->                                 -> Write Callback

我的问题是 kAudioUnitSubType_Varispeed 在 iOS 5.x 上不接受 StreamFormat。在 iOS 6 上是有效的。如果没有正确的 StreamFormat,AUGraph 就无法运行。

我在所有输入和输出上设置了相同的 StreamFormat:

    memset(&_audioFormat, 0, sizeof(_audioFormat));
UInt32 propertySize = sizeof(AudioStreamBasicDescription);
CheckError(AudioUnitGetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, &propertySize), "Couldn't get audio Format for io input");
_audioFormat.mChannelsPerFrame  = 1;
_audioFormat.mSampleRate = self.hardwareSampleRate;

// set audio Format for io
CheckError(AudioUnitSetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for output");
CheckError(AudioUnitSetProperty(self.io, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for input");

// set audio Format for mixer
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer 0");
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer 1");
CheckError(AudioUnitSetProperty(self.mixer, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kOutputBus, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for mixer output");

// set audio Format for speed
CheckError(AudioUnitSetProperty(self.speed, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for speed input");
CheckError(AudioUnitSetProperty(self.speed, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &_audioFormat, sizeof(_audioFormat)), "Couldn't set audio Format for speed output");

iOS 5.x 上的 CAShow:

    AudioUnitGraph 0x6CC000:
  Member Nodes:
    node 1: 'auou' 'rioc' 'appl', instance 0x18cc2a0 O I
    node 2: 'aumx' 'mcmx' 'appl', instance 0x455680 O I
    node 3: 'aufc' 'vari' 'appl', instance 0x450270 O I
  Connections:
    node   1 bus   1 => node   2 bus   1  [ 1 ch,  22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    node   2 bus   0 => node   3 bus   0  [ 2 ch,  44100 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    node   3 bus   0 => node   1 bus   0  [ 1 ch,  22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
  Input Callbacks:
    {0x53b5d, 0x454cd0} => node   2 bus   0  [1 ch, 22000 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=F

iOS 6.x 上的 CAShow:

    AudioUnitGraph 0x388000:
  Member Nodes:
    node 1: 'auou' 'rioc' 'appl', instance 0x1f03b1e0 O I
    node 2: 'aumx' 'mcmx' 'appl', instance 0x1f05fd60 O I
    node 3: 'aufc' 'vari' 'appl', instance 0x1e590b90 O I
  Connections:
    node   1 bus   1 => node   2 bus   1  [ 1 ch,  22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    node   2 bus   0 => node   3 bus   0  [ 1 ch,  22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
    node   3 bus   0 => node   1 bus   0  [ 1 ch,  22000 Hz, 'lpcm' (0x00000029) 32-bit little-endian float, deinterleaved]
  Input Callbacks:
    {0xe9b5d, 0x1e58e4e0} => node   2 bus   0  [1 ch, 22000 Hz]
  CurrentState:
    mLastUpdateError=0, eventsToProcess=F, isRunning=F

为什么速度节点不接受 iOS 5.x 上的 StreamFormat :(?有没有人可以帮助我?谢谢。

4

0 回答 0