Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threading Problem



Hi,

I have a plug-in that process large movie files. At present when it is called it doesn't return until the whole movie has been processed (which means that the host app is locked up). I'd like to make the movie processing a separate task and have it run in the background.

The host App would then peroodically call a "GetProcessStatus" function that would return the status saying if the task is "busy" or not.

I found some sample code and am adapting it for my own use (please see code copied below). However, I'm not sure how I get the status. The sample code waited for the task to complete before returning:

myOSStatus = MPWaitOnQueue(myTerminationQueue,NULL, NULL,(void **) &myTerminationStatus,kDurationImmediate);
if (myOSStatus == noErr)
{
myDoneFlag = true;
myOSStatus = myTerminationStatus;
}
while ((myOSStatus == noErr) && (myDoneFlag == false);
}


What is the best way to do this? Is there an API call to test if the queue would wait or not?

That way, I could just call this function in my "GetStatus()" function.

Thanks a lot
All the Best
Dave

// ************************************************************************ **********************
//**
//** ProccessMovieMPTask
//**
// ************************************************************************ **********************
static OSStatus crsUtilProccessMovieMPTask(char* theProcessParameters)
{
return(noErr);
}


#define kCopyFileTaskStackSize	(32 * 1024)


// ************************************************************************ **********************
//**
//** ProccessMovieMP
//**
// ************************************************************************ **********************
static OSStatus ProccessMovieMP(FSRef* theFilePathName)
{
OSStatus myOSStatus;
OSStatus myJunk;
OSStatus myTerminationStatus;
MPQueueID myTerminationQueue;
MPTaskID myTaskID;
Boolean myDoneFlag;
EventRecord myEventRecord;


myTerminationStatus = noErr;

//params.source = source;
//params.destDir = destDir;
//params.copyBuffer = copyBuffer;
//params.copyBufferSize = copyBufferSize;

// Create the termination queue and the task itself.

//**
//**  Create the termination queue and the task itself
//**
myOSStatus = MPCreateQueue(&myTerminationQueue);
if (myOSStatus != noErr)
	goto crsUtilProccessMovieMP_999;
	
myOSStatus = MPCreateTask((TaskProc) crsUtilProccessMovieMPTask,
						&params,
						kCopyFileTaskStackSize,
						myTerminationQueue,
						nil,
						nil,
						0,
						&myTaskID);
	
if (myOSStatus != noErr)
	goto crsUtilProccessMovieMP_999;

myDoneFlag = false;

//**
//** Wait for the Task to Complete
//**
do
{
myOSStatus = MPWaitOnQueue(myTerminationQueue,NULL, NULL,(void **) &myTerminationStatus,kDurationImmediate);
if (myOSStatus == noErr)
{
myDoneFlag = true;
myOSStatus = myTerminationStatus;
}
while ((myOSStatus == noErr) && (myDoneFlag == false);
}

myJunk = MPDeleteQueue(myTerminationQueue);
}


crsUtilProccessMovieMP_999:
return(myOSStatus);
}


Boolean GetMovieProcessStatusMP() {

//  return false is busy, return true if done.
}

_______________________________________________
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

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.