iOS: USB input channels not always made available when audio first initialized


#1

I think perhaps the AVAudioSession needs to be set to active when calls are made to channelData.reconfigure(…) … otherwise, it appears the input channels are not correctly identified and made available on all iOS devices.

I changed this in the iOSAudioIODevice::Pimpl constructor and open methods, and it seems to now work.


#2

Can you post your changes please? Sounds like the same bug we ran into recently.


#3

struct iOSAudioIODevice::Pimpl : public AudioPlayHead,
public AsyncUpdater
{
Pimpl (iOSAudioIODeviceType& ioDeviceType, iOSAudioIODevice& ioDevice)
: deviceType (ioDeviceType),
owner (ioDevice)
{
JUCE_IOS_AUDIO_LOG (“Creating iOS audio device”);

    // We need to activate the audio session here to obtain the available sample rates and buffer sizes,
    // but if we don't set a category first then background audio will always be stopped. This category
    // may be changed later.
    setAudioSessionCategory (AVAudioSessionCategoryPlayAndRecord);

    setAudioSessionActive (true);
    updateHardwareInfo();
    //setAudioSessionActive (false); //jvm
    
    channelData.reconfigure ({}, {});
    setAudioSessionActive (false); //jvm

    sessionHolder->activeDevices.add (this);
}

`    String open (const BigInteger& inputChannelsWanted,
                 const BigInteger& outputChannelsWanted,
                 double sampleRateWanted, int bufferSizeWanted)
    {
        close();

        firstHostTime = true;
        lastNumFrames = 0;
        xrun = 0;
        lastError.clear();

        requestedInputChannels  = inputChannelsWanted;
        requestedOutputChannels = outputChannelsWanted;
        targetSampleRate = sampleRateWanted;
        targetBufferSize = bufferSizeWanted > 0 ? bufferSizeWanted : defaultBufferSize;

        JUCE_IOS_AUDIO_LOG ("Opening audio device:"
                            <<  " inputChannelsWanted: "  << requestedInputChannels .toString (2)
                            << ", outputChannelsWanted: " << requestedOutputChannels.toString (2)
                            << ", targetSampleRate: " << targetSampleRate
                            << ", targetBufferSize: " << targetBufferSize);

        setAudioSessionActive (true); //jvm

        channelData.reconfigure (requestedInputChannels, requestedOutputChannels);

        setAudioSessionCategory (channelData.areInputChannelsAvailable() ? AVAudioSessionCategoryPlayAndRecord : AVAudioSessionCategoryPlayback);
        //setAudioSessionActive (true); //jvm`

#4

What audio hardware are you using?


#5

Apple USB Camera Adapter model A1619 (firmware 1.0.5, hardware 1.0.0)

Seems to appear with a variety of both UAC 1 and 2 devices, eg.

Apple devices I’ve tried that show the bug:

  • iPad mini 2 model ME281C/A (running 11.4.1)
  • iPhone S model MKU62VC/A (running 11.4.1)
  • iPhone X model MQAC2VC/A (running 11.4)

#6

OK, I’ll have a look at this next week when I have some devices available.

Have you tried disconnecting and reconnecting the hardware? Does the AudioDeviceSelectorComponent work correctly?


#7