• 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
Questions about AUEventListenerCreate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions about AUEventListenerCreate


  • Subject: Questions about AUEventListenerCreate
  • From: Thorrin <email@hidden>
  • Date: Mon, 9 Jul 2007 07:47:40 -0700 (PDT)

Hey,

I am trying to do a simple command line app that will
display the currently selected output device in the
preferences/sound window.  All I want it to do is run
in a loop and display the name of the new device if
the output device changes.

I looked at technical note 2104:  handling audio
events
(http://developer.apple.com/technotes/tn2002/tn2104.html)

but I can't get things working.  From stepping through
my code in the debugger, I can see that I am actually
getting the output device that I am trying to get (ie:
 OpenAComponent doesn't return an error)

I am new to the whole CFRun thing so I could be
butchering something there too, but anyway... here is
the code.  I am expecting to at least see 'sup' appear
on the screen if I change the audio device, but I get
nothing.  I would imagine that the actual name of the
device that is selected is contained in one of the
arguments passed to callback 'b', but I can cross that
bridge when I get to it.

Thanks in advance!
Thorrin

void b (void *  inCallbackRefCon,
         void *  inObject,
         const AudioUnitEvent *  inEvent,
	UInt64   inEventHostTime,
        Float32   inParameterValue)

{

	printf("Sup\n");  //this will be something real later
on.

}

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);

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

        d.mEventType =
kAudioOutputUnitProperty_CurrentDevice;
	d.mArgument.mProperty.mAudioUnit = OutputUnit;
	d.mArgument.mProperty.mScope =
kAudioUnitScope_Global;
	d.mArgument.mProperty.mElement = 0;

	AUEventListenerCreate (b,NULL,CFRunLoopGetCurrent(),
kCFRunLoopDefaultMode,.100,.100,&c);
	AUEventListenerAddEventType(c,NULL,&d);

	CFRunLoopRunInMode(kCFRunLoopDefaultMode, 2, false);

	while (1) {
		usleep (1000);
	}

}


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



____________________________________________________________________________________
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
 _______________________________________________
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: Re: Basic sample code for FFT audio frequency spectrum? Sarcasm Maybe? Thank You...
  • Next by Date: True RMS value for audio samples
  • Previous by thread: Re: auval question
  • Next by thread: True RMS value for audio samples
  • Index(es):
    • Date
    • Thread