Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth Mac > OK, This newbie...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 117 of 157
Post > Topic >>

OK, This newbie is stumped...

by "Charles Turner" <vze26m98@[EMAIL PROTECTED] > Jul 15, 2006 at 03:58 PM

Hi all-

Working on some code to utilize the Component Manager with Carbon
MacForth, and can't figure out where I've gone wrong. Below I attach
source which has some of the Component Manager data and function
declarations and below prior.stream,, some simple code that
demonstrates where I'm stuck.

I wanted to get the number of components, in this case AU output
plug-ins and for all of them on my machine, get their name and info
string. For some reason, when I call _GetComponentInfo a second time,
it returns "zero" plug-ins, it seems because my component description
struct had gotten trashed.

The code is commented, so you should be able to Command-K it and then
step through some lines that will demonstrate my trouble.

Any thoughts on what I'm doing wrong here?

Best and thanks, Charles

- - - - - - - - - - - - - -  <snip>- - - - - - - - - - - -

\ Components
\ Created:       07/14/06  10:19:08 PM  CWT
\ Last Revision: 07/14/06  10:19:08 PM  CWT

(*
*************************************************************************

     File:       CarbonCore/Components.h

     Contains:   Component Manager Interfaces.

     Version:    CarbonCore-677~2

     Copyright:  =A9 1991-2005 by Apple Computer, Inc., all rights
reserved.

     Bugs?:      For bug reports, consult the following page on
                 the World Wide Web:

                     http://developer.apple.com/bugreporter/

*************************************************************************
*)

Only Forth Definitions
Decimal

anew --Components--

lacking CoreServices.Framework framework CoreServices.Framework

CoreServices.Framework


STRUCTURE ComponentDescription
  	LONG:	+componentType			\ A unique 4-byte code indentifying the
command set
   	LONG:	+componentSubType		\ Particular flavor of this instance
   	LONG:	+componentManufacturer	\ Vendor indentification
   	LONG:	+componentFlags			\ 8 each for
Component,Type,SubType,Manuf/revision
	LONG:	+componentFlagsMask		\ Mask for specifying which flags
									\ to consider in search, zero during registration
STRUCTURE.END

(* ******************************************************
*                                                       *
*               APPLICATION LEVEL CALLS                 *
*                                                       *
******************************************************* *)
(* ******************************************************
* Component Database Add, Delete, and Query Routines
******************************************************* *)

\  *  RegisterComponent()
\  *  RegisterComponentResource()
\  *  UnregisterComponent()

2 machofunc _FindNextComponent ( Component				aComponent
  								 ComponentDescription*	looking
  								 return					Component )

1 machofunc _CountComponents ( ComponentDescription*	looking
							   return					long )

5 machofunc _GetComponentInfo ( Component				aComponent
								ComponentDescription*	cd
								Handle					componentName
								Handle					componentInfo
								Handle					componentIcon
								return					OSErr )

\  *  GetComponentListModSeed()
\  *  GetComponentTypeModSeed()

(* *******************************************************
* Component Instance Allocation and dispatch routines
******************************************************* *)

2 machofunc _OpenAComponent ( Component				aComponent
							  ComponentInstance*	ci
							  return				OSErr )

1 machofunc _OpenComponent ( Component	aComponent
							 return		ComponentInstance )

1 machofunc _CloseComponent ( ComponentInstance	aComponentInstance
							  return			OSErr )

1 machofunc _GetComponentInstanceError (
ComponentInstance	aComponentInstance
										 return				OSErr )

(* *******************************************************
* Component aliases
******************************************************* *)

\  *  ResolveComponentAlias()

(* *******************************************************
* Component public resources and public string lists
******************************************************* *)

\  *  GetComponentPublicResource()
\  *  GetComponentPublicResourceList()
\  *  GetComponentPublicIndString()

\ and more...

\ *************** comments and/or test code below ***************
prior.stream

\ ** ENTER all the data definitions between here and the asterisks ****

0 CONSTANT nil

ascii auou constant		kAudioUnitType_Output

CREATE MyComponentDescription ComponentDescription ALLOT
kAudioUnitType_Output	MyComponentDescription 	+componentType !
					0	MyComponentDescription 	+componentSubType !
					0	MyComponentDescription 	+componentManufacturer !
					0 	MyComponentDescription 	+componentFlags !
					0 	MyComponentDescription 	+componentFlagsMask !

VARIABLE componentName 4 _NewHandle componentName !
VARIABLE componentInfo 4 _NewHandle componentInfo !
VARIABLE componentIcon 4 _NewHandle componentIcon !

\ *********************************************************************

\ ENTER these lines one at a time and observe the stack

\ returns the number of kAudioUnitType_Output
MyComponentDescription _CountComponents

\ leaves the address of the first component found on stack
nil MyComponentDescription _FindNextComponent

\ takes address of prev component on stack and finds next
MyComponentDescription _FindNextComponent

\ ...and so on. Leaves 0 when it finds no more
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent
MyComponentDescription _FindNextComponent

\ MyComponentDescription OK
MyComponentDescription 32 CHARS DUMP


\ NOW: ENTER these lines one at a time and observe the stack

\ As above...
MyComponentDescription _CountComponents
nil MyComponentDescription _FindNextComponent

\ DUP the component address because _GetComponentInfo will consume it
DUP

\ Get info. We use nil to remove the influence of the handle defined
above.
\ DROP the return code...
MyComponentDescription nil nil nil _GetComponentInfo DROP

\ Find next component. Why does it return )?
MyComponentDescription _FindNextComponent

\ MyComponentDescription is trashed...
MyComponentDescription 32 CHARS DUMP




 6 Posts in Topic:
OK, This newbie is stumped...
"Charles Turner"  2006-07-15 15:58:42 
Re: OK, This newbie is stumped...
"Charles Turner"  2006-07-15 16:25:49 
Re: OK, This newbie is stumped...
ward@[EMAIL PROTECTED] (  2006-07-15 20:04:51 
Re: OK, This newbie is stumped...
"Charles Turner"  2006-07-16 05:57:01 
Re: OK, This newbie is stumped...
ward@[EMAIL PROTECTED] (  2006-07-16 10:07:38 
Re: OK, This newbie is stumped...
"Charles Turner"  2006-07-16 10:40:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 19:34:24 CDT 2008.