• 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
Displaying Current Audio Output Device (take 2)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Displaying Current Audio Output Device (take 2)


  • Subject: Displaying Current Audio Output Device (take 2)
  • From: Thorrin <email@hidden>
  • Date: Wed, 11 Jul 2007 06:10:30 -0700 (PDT)

OK, I am at the point where I can get the default
output device and display the name to the screen, but
I don't get any updates as to when that device
changes.  Whatever I have set at first keeps
displaying even though I change settings in the audio
prefs panel.

It seems that I keep getting the same deviceID and
thus the same name.  I would assume that
kAudioOutputUnitProperty_CurrentDevice returned the
current device selected in the prefs window...  Should
I be using something else?

I have tried releasing the output unit and grabbing it
again, but to no avail.


Code (very hackish due to a lot of trial and error
stuff):

int main (int argc, const char * argv[]) {
	OSStatus err = noErr;
	Handle a;
	AUEventListenerRef c;
	AudioUnitEvent d;
	AudioUnitProperty e;
	AudioUnit                                InputUnit;
	AudioUnit                                OutputUnit;

	// Open the default output unit
	ComponentDescription desc, desc2;
	desc.componentType = kAudioUnitType_Output;
	desc.componentSubType =
kAudioUnitSubType_DefaultOutput;
	desc.componentManufacturer =
kAudioUnitManufacturer_Apple;
	desc.componentFlags = 0;
	desc.componentFlagsMask = 0;

	Component comp = FindNextComponent(NULL, &desc);
	a = NewHandle (0);
	GetComponentInfo(comp, &desc2,a, NULL, NULL);

	char *name;
	int len;
	len = *a;
	printf("%s\n",(unsigned char*)((int)(len+1)));


	err = noErr;
	err = OpenAComponent(comp, &OutputUnit);

	AudioDeviceID	deviceID;
	size = sizeof(AudioDeviceID);

	name = malloc (255);

	while (1) {
		deviceID = 0;
		size = sizeof(AudioDeviceID);
		result = AudioUnitGetProperty(OutputUnit,
kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global, 0, &deviceID, &size);

	AudioDeviceGetPropertyInfo(deviceID, 0, 0,
kAudioDevicePropertyDeviceName, &size, NULL);

	AudioDeviceGetProperty(deviceID, 0, 0,
kAudioDevicePropertyDeviceName, &size, name);

	printf("%s\n",name);
        sleep (1);
}
}




"Everyone is allergic to giant rocks hitting them in the head!"
-Thorrin's elf chick after casting a 'meteor swarm' spell ;)


      ____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz
 _______________________________________________
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: serial midi driver - problem solved sort of
  • Next by Date: HALPlugIn::Initialize appears to be freezing
  • Previous by thread: serial midi driver - problem solved sort of
  • Next by thread: HALPlugIn::Initialize appears to be freezing
  • Index(es):
    • Date
    • Thread