~ubuntu-branches/debian/sid/jackd2/sid

« back to all changes in this revision

Viewing changes to macosx/JackMachThread.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adrian Knoth
  • Date: 2011-03-31 13:54:50 UTC
  • mfrom: (1.1.3 upstream) (2.1.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110331135450-zafc1di024kzeu31
Tags: 1.9.7~dfsg-1
* New upstream version 1.9.7 (ALSA resume, new latency API)
* Build with --mixed on i386 to be compatible with amd64.
* Don't patch jack_connect for fast consecutive calls anymore, it's now
  using the same code as in jackd1 and waits for the port connection to
  appear.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
GNU Lesser General Public License for more details.
14
14
 
15
15
You should have received a copy of the GNU Lesser General Public License
16
 
along with this program; if not, write to the Free Software 
 
16
along with this program; if not, write to the Free Software
17
17
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
18
 
19
19
*/
24
24
namespace Jack
25
25
{
26
26
 
27
 
int JackMachThread::SetThreadToPriority(pthread_t thread, UInt32 inPriority, Boolean inIsFixed, UInt64 period, UInt64 computation, UInt64 constraint)
 
27
int JackMachThread::SetThreadToPriority(jack_native_thread_t thread, UInt32 inPriority, Boolean inIsFixed, UInt64 period, UInt64 computation, UInt64 constraint)
28
28
{
29
29
    if (inPriority == 96) {
30
30
        // REAL-TIME / TIME-CONSTRAINT THREAD
64
64
}
65
65
 
66
66
// returns the thread's priority as it was last set by the API
67
 
UInt32 JackMachThread::GetThreadSetPriority(pthread_t thread)
 
67
UInt32 JackMachThread::GetThreadSetPriority(jack_native_thread_t thread)
68
68
{
69
69
    return GetThreadPriority(thread, THREAD_SET_PRIORITY);
70
70
}
71
71
 
72
72
// returns the thread's priority as it was last scheduled by the Kernel
73
 
UInt32 JackMachThread::GetThreadScheduledPriority(pthread_t thread)
 
73
UInt32 JackMachThread::GetThreadScheduledPriority(jack_native_thread_t thread)
74
74
{
75
75
    return GetThreadPriority(thread, THREAD_SCHEDULED_PRIORITY);
76
76
}
77
77
 
78
 
UInt32 JackMachThread::GetThreadPriority(pthread_t thread, int inWhichPriority)
 
78
UInt32 JackMachThread::GetThreadPriority(jack_native_thread_t thread, int inWhichPriority)
79
79
{
80
80
    thread_basic_info_data_t threadInfo;
81
81
    policy_info_data_t thePolicyInfo;
118
118
    return 0;
119
119
}
120
120
 
121
 
int JackMachThread::GetParams(pthread_t thread, UInt64* period, UInt64* computation, UInt64* constraint)
 
121
int JackMachThread::GetParams(jack_native_thread_t thread, UInt64* period, UInt64* computation, UInt64* constraint)
122
122
{
123
123
    thread_time_constraint_policy_data_t theTCPolicy;
124
124
    mach_msg_type_number_t count = THREAD_TIME_CONSTRAINT_POLICY_COUNT;
144
144
{
145
145
    // pthread_cancel still not yet implemented in Darwin (TO CHECK ON TIGER)
146
146
    jack_log("JackMachThread::Kill");
147
 
    
148
 
    if (fThread != (pthread_t)NULL)  { // If thread has been started
 
147
 
 
148
    if (fThread != (jack_native_thread_t)NULL)  { // If thread has been started
149
149
        mach_port_t machThread = pthread_mach_thread_np(fThread);
150
150
        int res = (thread_terminate(machThread) == KERN_SUCCESS) ? 0 : -1;
151
 
        fThread = (pthread_t)NULL;
 
151
        fThread = (jack_native_thread_t)NULL;
152
152
        return res;
153
153
    } else {
154
154
        return -1;
159
159
{
160
160
    jack_log("JackMachThread::AcquireRealTime fPeriod = %ld fComputation = %ld fConstraint = %ld",
161
161
             long(fPeriod / 1000), long(fComputation / 1000), long(fConstraint / 1000));
162
 
    return (fThread != (pthread_t)NULL) ? AcquireRealTimeImp(fThread, fPeriod, fComputation, fConstraint) : -1; 
 
162
    return (fThread != (jack_native_thread_t)NULL) ? AcquireRealTimeImp(fThread, fPeriod, fComputation, fConstraint) : -1;
163
163
}
164
164
 
165
165
int JackMachThread::AcquireSelfRealTime()
181
181
    return AcquireSelfRealTime();
182
182
}
183
183
 
184
 
int JackMachThread::AcquireRealTimeImp(pthread_t thread, UInt64 period, UInt64 computation, UInt64 constraint)
 
184
int JackMachThread::AcquireRealTimeImp(jack_native_thread_t thread, UInt64 period, UInt64 computation, UInt64 constraint)
185
185
{
186
186
    SetThreadToPriority(thread, 96, true, period, computation, constraint);
187
187
    return 0;
189
189
 
190
190
int JackMachThread::DropRealTime()
191
191
{
192
 
    return (fThread != (pthread_t)NULL) ? DropRealTimeImp(fThread) : -1;
 
192
    return (fThread != (jack_native_thread_t)NULL) ? DropRealTimeImp(fThread) : -1;
193
193
}
194
194
 
195
195
int JackMachThread::DropSelfRealTime()
197
197
    return DropRealTimeImp(pthread_self());
198
198
}
199
199
 
200
 
int JackMachThread::DropRealTimeImp(pthread_t thread)
 
200
int JackMachThread::DropRealTimeImp(jack_native_thread_t thread)
201
201
{
202
202
    SetThreadToPriority(thread, 63, false, 0, 0, 0);
203
203
    return 0;