1

I am using SimplyCoreAudio to switch the clock source. The code is as follows:

 debugPrint("nullAudioDevice.clockSourceID \(nullAudioDevice.clockSourceID)")
 if let cid = hardwareDevice.clockSourceID {
 if nullAudioDevice.setClockSourceID(cid) {
 debugPrint("hardwareDevice.clockSourceID \(hardwareDevice.clockSourceID)")
 debugPrint("nullAudioDevice.clockSourceID \(nullAudioDevice.clockSourceID)")
 }else{
 debugPrint("false")
 }
 }

The printed result is as follows:

nullAudioDevice.clockSourceID Optional(4294967295)
hardwareDevice.clockSourceID Optional(690487296)
nullAudioDevice.clockSourceID Optional(4294967295)

Why does the ID returned after successfully setting the clock source with setClockSourceID still show the original one? Does this mean the setting was not successful? Is there a proper method to synchronize the clock source setting?

Superman
5324 silver badges23 bronze badges
asked May 22, 2025 at 8:35
4
  • 1
    Try checking with a small delay. Commented May 22, 2025 at 8:45
  • I added a 10-second delay, but it still didn't succeed in modifying Commented May 22, 2025 at 9:18
  • Are you sure you can set to this clock source? There is AudioDevice.clockSourceIDs returning a "list of all the clock source identifiers available for this audio device" . Commented May 22, 2025 at 9:31
  • @soundflix I don't know. I just wanted to know how to synchronize the clocks of two devices. And I came across this method. Can you tell me how to synchronize the clocks? Commented May 23, 2025 at 0:41

1 Answer 1

1
This is my understanding:

Setting clockSource is not available for just any audio devices, as CoreAudio.AudioHardwareDevice does not have a property clockSource; only the subclass aggregate devices have it, see: CoreAudio.AudioHardwareAggregateDevice.

You can also check this in macOS Audio MIDI Setup app: Clock source is greyed out for all devices except aggregate devices.

The CoreAudio "clock source" is not to be mixed with the actual audio clock source setting of (professional) audio hardware that provides setting it to "internal", "input", "wordclock" etc. in its driver.

So why does your code return success (true)?

In your code, nullAudioDevice.setClockSourceID(cid) returns true, which you did not expect.

The general definition of a null device is:
"the null device is a device file that discards all data written to it but reports that the write operation succeeded.".
The same applies to SimplyCoreAudio's NullAudio.device.

answered May 24, 2025 at 9:59
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.