2 * OpenAL cross platform audio library
3 * Copyright (C) 1999-2007 by authors.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
34 ALuint (*func
)(ALvoid
*);
39 static DWORD CALLBACK
StarterFunc(void *ptr
)
41 ThreadInfo
*inf
= (ThreadInfo
*)ptr
;
44 ret
= inf
->func(inf
->ptr
);
45 ExitThread((DWORD
)ret
);
50 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
)
52 ThreadInfo
*inf
= malloc(sizeof(ThreadInfo
));
58 inf
->thread
= CreateThread(NULL
, 0, StarterFunc
, inf
, 0, NULL
);
68 ALuint
StopThread(ALvoid
*thread
)
70 ThreadInfo
*inf
= thread
;
73 WaitForSingleObject(inf
->thread
, INFINITE
);
74 GetExitCodeThread(inf
->thread
, &ret
);
86 ALuint (*func
)(ALvoid
*);
91 static void *StarterFunc(void *ptr
)
93 ThreadInfo
*inf
= (ThreadInfo
*)ptr
;
96 ret
= inf
->func(inf
->ptr
);
100 ALvoid
*StartThread(ALuint (*func
)(ALvoid
*), ALvoid
*ptr
)
102 ThreadInfo
*inf
= malloc(sizeof(ThreadInfo
));
107 if(pthread_create(&inf
->thread
, NULL
, StarterFunc
, inf
) != 0)
116 ALuint
StopThread(ALvoid
*thread
)
118 ThreadInfo
*inf
= thread
;
121 pthread_join(inf
->thread
, &ret
);