• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Swift set AudioUnit current device failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swift set AudioUnit current device failure


  • Subject: Swift set AudioUnit current device failure
  • From: Bill Farmer <email@hidden>
  • Date: Sat, 17 Feb 2018 19:33:46 +0000 (UTC)

Hi
I am porting an app I wrote in C some years ago to Swift. The original app
still works, but one part of the port refuses to work. The code is...

        var id: AudioDeviceID? = kAudioObjectUnknown
        var size: UInt32 = 0

        // Get the default input device
        var inputDeviceAOPA: AudioObjectPropertyAddress =
          AudioObjectPropertyAddress(mSelector:
                                       kAudioHardwarePropertyDefaultInputDevice,
                                     mScope: kAudioObjectPropertyScopeGlobal,
                                     mElement:
                                       kAudioObjectPropertyElementMaster)
        // Get size
        status =
          AudioObjectGetPropertyDataSize(UInt32(kAudioObjectSystemObject),
                                         &inputDeviceAOPA,
                                         0, nil, &size)
        if (status != noErr)
        {
        // AudioObjectGetPropertyDataSize
            NSLog("Error in AudioObjectGetPropertyData: " +
                "kAudioHardwarePropertyDefaultInputDevice %d", status)
        return status
        }

        // Get device
        status =
          AudioObjectGetPropertyData(UInt32(kAudioObjectSystemObject),
                                     &inputDeviceAOPA,
                                     0, nil, &size, &id)
        if (status != noErr)
        {
        // AudioObjectGetPropertyData
            NSLog("Error in AudioObjectGetPropertyData: " +
                "kAudioHardwarePropertyDefaultInputDevice %d", status)
        return status
        }

        NSLog("System input device %d", id!)

        // Set the audio unit device
        status =
          AudioUnitSetProperty(output!,
                   kAudioOutputUnitProperty_CurrentDevice,
                   kAudioUnitScope_Global,
                               0, &id, size)
        if (status != noErr)
        {
            // AudioUnitSetProperty
            NSLog("Error in AudioUnitSetProperty: " +
                "kAudioOutputUnitProperty_CurrentDevice " +
                    AudioUnitErrString(status))
        return status
        }

The log output is...Cynthia:Tuner bill$ ./Tuner

2018-02-17 13:34:20.902 Tuner[978:27452] AudioUnit input device 71
2018-02-17 13:34:20.902 Tuner[978:27452] System input device 392018-02-17
13:34:20.903 Tuner[978:27452] Error in AudioUnitSetProperty:
kAudioOutputUnitProperty_CurrentDevice AudioUnitErr_InvalidPropertyValue

Any clue would be most welcome.
RegardsBill Farmer
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: making sense of the AudioServerPlugin API and DoIOOperation()
  • Next by Date: Re: Swift set AudioUnit current device failure
  • Previous by thread: making sense of the AudioServerPlugin API and DoIOOperation()
  • Next by thread: Re: Swift set AudioUnit current device failure
  • Index(es):
    • Date
    • Thread