Re: Link to CoreMIDI from CFM?
Re: Link to CoreMIDI from CFM?
- Subject: Re: Link to CoreMIDI from CFM?
- From: Lubor Prikryl <email@hidden>
- Date: Wed, 26 Jun 2002 22:15:56 +0200
Hi,
mach-o and pef pointers to variables are both direct, there is no need
to transform them. Only pointers to functions are indirect in PEF
(pointing to T-vector) and must be converted. Using bundles is too
complicated.
Lubor
Lubor Prikryl
DSound (CZ)
Software Developer
email@hidden
email@hidden
On Wednesday, June 26, 2002, at 07:50 PM, Matt Ingalls wrote:
well i have been using coreaudio and coremidi in cfm apps
using the cfmlateimport example code -- the only problem
ran into was the code thinks all symbols are functions
and the coremidi framework has some exported constants too.
anyway, i couldnt do it without help from this list and
feel i should return the favor -- i recently wrote down
how to do this as i knew i would forget, so here it is below -
maybe someone will find this useful? -- was
also thinking of making my code available, but should
probably check with the boss first... -m
+++++++++++++++++++++++++++
0) start with the CallMachOFramework example code --
its easy enough to modify CallMachOFramework.c
so that it will handle a any framework request.
1) add CallMachOFramework.c and CFMLateImport.c
to your Carbon-CFM project. also make sure all the "More"
files are in your search path.
2) form a .exp file containing a list of all the
exported functions in the framework. supposedly there
is a commandline tool to do this but i just copy the
function names over from the header files.
3) create a stub library
from MPW Shell, run this command:
MakeStub '<..fill in path here..>:filename.exp' -o NameofFrameworkLib
[type command, select it, and press the 'MPW Shell' button]
4) find where MPW created the lib and move the lib into your CW project
5) select the lib in the project window, and open the inspector window
[usually from the rightmost button on the project window toolbar]
select the "import weak" option.
6) open project settings,
+ in the C/C++ Language panel, if you are not using a prefix file that
defines already, set the prefix file to 'UseCFMLateImport.prefix'
+ in the 'PPC Linker' panel, put 'FragmentInit'
for the Initialization Entry Point. If you already have an init
routine
in your project, you need to copy the code into your routine.
7) i found no way to trick the compiler to find
something like:
#include <CoreFoundation/CoreFoundation.h>
so what i do is copy some framework header files and edit some of the
#includes - then keep adding #includes until it compiles --
there has to be a better way to do this!?
8) following the sample code example, you now should be able to directly
call the framework's functions - ALSO for any callback registration,
you MUST use the MachOFunctionPointerForCFMFunctionPointer() function.
i think it can be found in the machOtoCFM example code.
for example to register a coreaudio audio callback, you have
to do something like this:
// our callback function
OSStatus coreaudio_ioproc(...)
{
}
extern AudioDeviceID id;
void register_ioproc()
{
AudioDeviceIOProc ca_ioProc =
MachOFunctionPointerForCFMFunctionPointer( coreaudio_ioproc );
OSStatus status = AudioDeviceAddIOProc(dev_id, ca_ioProc, NULL);
}
_______________________________________________
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.
_______________________________________________
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.