• 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
Re: Getting an AudioDeviceID from device unique identifier (UID)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting an AudioDeviceID from device unique identifier (UID)


  • Subject: Re: Getting an AudioDeviceID from device unique identifier (UID)
  • From: Jeff Moore <email@hidden>
  • Date: Thu, 24 Apr 2003 11:25:32 -0700

It is my opinion that a proper API only returns errors when errors actually occur. Errors are like C++ exceptions, they should only be used when something actually went wrong. The should not be used as an alternative return path for information that has a perfectly acceptable return path already. Overloading things like that in an API is a bad practice that my experience has shown leads to inconsistent APIs that are more difficult to use and harder still to maintain over time.

In this case no error has occurred. The AudioDeviceID that matches any UID that doesn't exist is kAudioDeviceUnknown. The fact that the HAL wasn't returning kAudioDeviceUnknown in those cases was a bug.

On Thursday, April 24, 2003, at 10:32 AM, Sean McBride wrote:

B.J. Buchalter (email@hidden) wrote on Thu, 24 Apr 2003 13:02:45 -0400:

Cool! It is definitely better to return a sentinel value if the device is
not found. But I still don't understand why it is not appropriate to return
an error in this case. Basically, I am using this API to say "Find This
Thing For Me". If you can't find it, shouldn't you return an error like
"kAudioDeviceNotFoundError" or "kGUIDDoesNotExistError" -- sort of like the
File Manager returns fnfError (-43) if you try to open a file that does not
exist? Why is it not an error to ask for the device ID of a device that does
not exist in the system?

I agree. It also makes AudioHardwareGetProperty() harder to use, because
one has to check BOTH the error and the device id to see if it succeeded.
I'd much rather check only one... Reminds me of this:

h = NewHandle()
if ((h != nil) && (MemError() != noErr))
...

Which I've seen a lot....


--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Mac Software Designer +1-514-822-6000
Matrox Electronic Systems Ltd. Montrial, Quibec, Canada
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.



--

Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Getting an AudioDeviceID from device unique identifier (UID)
      • From: Kurt Bigler <email@hidden>
References: 
 >Re: Getting an AudioDeviceID from device unique identifier (UID) (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: Getting an AudioDeviceID from device unique identifier (UID)
  • Next by Date: Re: Getting an AudioDeviceID from device unique identifier (UID)
  • Previous by thread: Re: Getting an AudioDeviceID from device unique identifier (UID)
  • Next by thread: Re: Getting an AudioDeviceID from device unique identifier (UID)
  • Index(es):
    • Date
    • Thread