Dear All,
We've been building a plug-in for QuickTime to make an interactive
music player. We get some stuttering because we have not been able to
get the proper priority of the feeder thread. Here are some code part what we
tried out, nothing changed. Can someone help us how to set the priority of
a thread to be real-time priority?
There are lots of things which are not clear for us. For instance. What is
the difference between mach_thread_self() and pthread_mach_thread_np(feederFn) for the first parameter of the thread_policy_set(...) function? What is the range for the
thePrecedencePolicy.importance? How can we determine the right value for the
fields for theTCPolicy.period, theTCPolicy.computation,
theTCPolicy.constraint?
Many Thanks!
My thread function is declared as
follows:
void* feederFn(void* pParam);
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
thread_extended_policy_data_t theFixedPolicy; hread_precedence_policy_data_t thePrecedencePolicy;
theFixedPolicy.timeshare = 0; thread_policy_set
(pthread_mach_thread_np(feederFn)THREAD_EXTENDED_POLICY,
(thread_policy_t)&theFixedPolicy,
THREAD_EXTENDED_POLICY_COUNT); thePrecedencePolicy.importance
= 15; //what is the range of this parameter? thread_policy_set
(pthread_mach_thread_np(feederFn), THREAD_PRECEDENCE_POLICY,(thread_policy_t&thePrecedencePolicy,THREAD_PRECEDENCE_POLICY_COUNT);
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
thread_time_constraint_policy_data_t theTCPolicy;
UInt64 theComputeQuanta;
UInt64 thePeriod;
UInt64 thePeriodNanos; kern_return_t
error; thePeriodNanos = 20000000; //How can I determine this
value? theComputeQuanta = AudioConvertNanosToHostTime ( thePeriodNanos * 0.15
); thePeriod = AudioConvertNanosToHostTime
(thePeriodNanos); theTCPolicy.period
= thePeriod; theTCPolicy.computation =
theComputeQuanta; theTCPolicy.constraint =
thePeriod; theTCPolicy.preemptible = true;
error = thread_policy_set
(pthread_mach_thread_np(feederFn),
THREAD_TIME_CONSTRAINT_POLICY, (thread_policy_t)&theTCPolicy,
THREAD_TIME_CONSTRAINT_POLICY_COUNT); -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|