On Tue, 12 Jun 2007 14:21:30 +0100, Dave <email@hidden>
wrote:
If am using MPCreateTask() to a create a task that is used to
process
a movie file. The results are stored in a big buffer (maybe 20MB in
size). How can I pass a this buffer from the task I created to the
creating task?
There's a programming axiom that says that you should always free
memory in
the same function that allocates it. Following that I'd advise
that you to
allocate the memory in the creating task and pass it to the MP thread
instead;
Is it ok to use malloc() and just pass the buffer back via a Global?
NO. ;-)
So, what method would you recommend instead?
I'm jumping into the middle of this thread, so apologies in advance
if I missed something crucial.
If you're allocating the buffer before calling MPCreateTask, you
could pass the buffer pointer (and more) to the task via the
"parameter" parameter of MPCreateTask.
Since you mentioned that you're writing a plug-in, you could also
store the buffer pointer as part of your plug-in's instance
variables, if supported. Plug-in APIs usually provide a mechanism for
you to do that (for example, a userData field in a parameter block
passed to the plug-in: you malloc storage for a struct and store it
in the PB where it's available for future calls). That way you don't
run into the issues of multiple accessors of a global.
steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden