• 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: practical use of UID for USB devices
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: practical use of UID for USB devices


  • Subject: Re: practical use of UID for USB devices
  • From: Michael Thornburgh <email@hidden>
  • Date: Thu, 29 Sep 2005 11:41:30 -0700


i save both the UID and the device name in the user preferences. if i can't find the device by UID, then i select a device with a matching name that has at least one stream in the direction (recording or playback) that i'm interested in. if you're using MTCoreAudio, you can get the latter with +[MTCoreAudioDevice devicesWithName:havingStreamsForDirection:]. for example:


   id recordDevice;

recordDevice = [MTCoreAudioDevice deviceWithUID: @"AppleUSBAudioEngine:Plantronics:Plantronics headset:3b100000:2"];
if(!recordDevice)
recordDevice = [[MTCoreAudioDevice devicesWithName: @"Plantronics Headset" havingStreamsForDirection: kMTCoreAudioDeviceRecordDirection] lastObject];
if(!recordDevice)
recordDevice = [MTCoreAudioDevice defaultInputDevice];


note that checking for streams in the direction you care about is necessary for things like USB audio devices, where the record and playback sides appear as different audio devices.

-mike


On Sep 29, 2005, at 11:25 AM, Chris Silverberg wrote:

Hi folks,

I work on a VoIP application and use CoreAudio API's for device capture and selection. In our preferences window, the user can select their input and output devices, and I save the user's selection by storing the kAudioDevicePropertyDeviceUID property. This works pretty well, but there is a problem.

For USB devices, the UID varies based on which USB port the user selects. For example, if I connect my Plantronics headset to my PowerBook, depending on which port I plug into, I will get one of the following UIDs:

    AppleUSBAudioEngine:Plantronics:Plantronics headset:1b100000:2
    AppleUSBAudioEngine:Plantronics:Plantronics headset:3b100000:2

Clearly the second to last component of the string identifies the USB port. Although I'm sure this is useful in certain scenarios, it pretty much prevents the software from being able to save the user's selected device in a reliable mannor. With two USB ports on the side of a PowerBook, it's going to be somewhat random which port a user will use to plug in.

So, does anyone have any advice on how to handle this? Two choices come to mind... first, I could use kAudioDevicePropertyDeviceNameCFString instead of the UID which would probably solve the problem in most or all cases. Secondly, I could try to match the UID intelligently so that I ignore the difference between USB ports, but that seems a bit messy and subject to break in the future.

Is this simply a design flaw with the UID property?

thanks,
Chris
_______________________________________________
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


References: 
 >Error -10838 calling MIDIClientCreate (From: "Marco Hinic" <email@hidden>)
 >Re: Error -10838 calling MIDIClientCreate (From: Doug Wyatt <email@hidden>)
 >Re: Error -10838 calling MIDIClientCreate (From: "Marco Hinic" <email@hidden>)
 >practical use of UID for USB devices (From: Chris Silverberg <email@hidden>)

  • Prev by Date: practical use of UID for USB devices
  • Next by Date: Re: practical use of UID for USB devices
  • Previous by thread: practical use of UID for USB devices
  • Next by thread: Re: practical use of UID for USB devices
  • Index(es):
    • Date
    • Thread