本文整理汇总了C++中SDL_WaitThread函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_WaitThread函数的具体用法?C++ SDL_WaitThread怎么用?C++ SDL_WaitThread使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_WaitThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SDL_mutexP
void FrameExporter::stop() {
if(!thread) return;
if(dumper_thread_state == FRAME_EXPORTER_STOPPED || dumper_thread_state == FRAME_EXPORTER_EXIT) return;
SDL_mutexP(mutex);
dumper_thread_state = FRAME_EXPORTER_EXIT;
SDL_CondSignal(cond);
SDL_mutexV(mutex);
SDL_WaitThread(thread, 0);
thread = 0;
}
示例2: ijkmp_destroy
inline static void ijkmp_destroy(IjkMediaPlayer *mp)
{
if (!mp)
return;
ffp_destroy_p(&mp->ffplayer);
if (mp->msg_thread) {
SDL_WaitThread(mp->msg_thread, NULL);
mp->msg_thread = NULL;
}
pthread_mutex_destroy(&mp->mutex);
freep((void**)&mp->data_source);
memset(mp, 0, sizeof(IjkMediaPlayer));
freep((void**)&mp);
}
示例3: l_thread_newThread
static int l_thread_newThread(lua_State* state) {
thread_Data* data = (thread_Data*) lua_newuserdata(state, sizeof(thread_Data));
moduleData.state = state;
const char* name = luaL_optstring(state, 2, NULL);
data->thread = SDL_CreateThread((SDL_ThreadFunction)callback, name, (void *)NULL);
if (NULL == data->thread)
luaL_error(state, "\n Create thread failed: %s\n", SDL_GetError());
else
SDL_WaitThread(data->thread, &data->res);
lua_rawgeti(state, LUA_REGISTRYINDEX, moduleData.threadDataMT);
lua_setmetatable(state, -2);
return 1;
}
示例4: SDL_WaitThread
AutoPilotWindow::~AutoPilotWindow() {
//destroy parser thread
parser_wait=0;
if(parser_thread)
SDL_WaitThread(parser_thread,NULL);
parser_thread=NULL;
if(tasker)
delete tasker;
if(parser)
delete parser;
if(port)
delete port;
if(logs)
delete logs;
if(input)
delete input;
}
示例5: main
int main(int argc, char **argv) {
if (argc < 2 || argc > 2) {
printf("Usage: %s image.flif\n",argv[0]);
return 0;
}
d = flif_create_decoder();
if (!d) return 1;
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("FLIF Viewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 200, 200, 0);
flif_decoder_set_quality(d, 100); // this is the default
flif_decoder_set_scale(d, 1); // this is the default
#ifdef PROGRESSIVE_DECODING
flif_decoder_set_callback(d, &(progressive_render));
flif_decoder_set_first_callback_quality(d, 500); // do the first callback when at least 5.00% quality has been decoded
printf("Decoding progressively...\n");
SDL_Thread *decode_thread = SDL_CreateThread(decodeThread,"Decode_FLIF",argv);
if (!decode_thread) {
printf("Error: failed to create decode thread\n");
return 1;
}
#else
printf("Decoding entire image...\n");
decodeThread(argv);
progressive_render(10000,-1);
#endif
SDL_Event e;
int result = 0;
while (!quit) {
draw_image();
if (animation) {
SDL_Delay(frame_delay[frame]);
frame++;
frame %= flif_decoder_num_images(d);
} else { SDL_WaitEvent(&e); if (!do_event(e)) break; SDL_Delay(100); }
while (SDL_PollEvent(&e)) if (!do_event(e)) break;
}
#ifdef PROGRESSIVE_DECODING
while(flif_abort_decoder(d)) SDL_Delay(100);
SDL_WaitThread(decode_thread, &result);
#endif
flif_destroy_decoder(d);
SDL_DestroyWindow(window);
SDL_Quit();
return result;
}
示例6: Thread_Shutdown_
/**
* Thread_Shutdown_
*/
static void Thread_Shutdown_(void) {
if (thread_pool.num_threads) {
thread_t *t = thread_pool.threads;
uint16_t i = 0;
for (i = 0; i < thread_pool.num_threads; i++, t++) {
Thread_Wait(t);
SDL_CondSignal(t->cond);
SDL_WaitThread(t->thread, NULL);
SDL_DestroyCond(t->cond);
SDL_DestroyMutex(t->mutex);
}
Mem_Free(thread_pool.threads);
}
}
示例7: SDL_CreateThread
int AVIWrapper::play(bool click_flag)
{
int ret = 0;
time_start = 0;
status = AVI_PLAYING;
if (v_stream)
thread_id = SDL_CreateThread(::playVideo, this);
if (a_stream)
Mix_HookMusic(::audioCallback, this);
bool done_flag = false;
while (!(done_flag & click_flag) && status == AVI_PLAYING) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_KEYDOWN:
if (((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_RETURN
|| ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_KP_ENTER
|| ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_SPACE
|| ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_ESCAPE)
done_flag = true;
break;
case SDL_QUIT:
ret = 1;
case SDL_MOUSEBUTTONDOWN:
done_flag = true;
break;
default:
break;
}
}
SDL_Delay(10);
}
status = AVI_STOP;
if (v_stream)
SDL_WaitThread(thread_id, NULL);
if (a_stream)
Mix_HookMusic(NULL, NULL);
return ret;
}
示例8: main
int main(int argc, char **argv)
{
SDL_Thread *threads[NUM_THREADS];
uintptr_t i;
int init_sem;
if(argc < 2) {
fprintf(stderr,"Usage: %s init_value\n", argv[0]);
return(1);
}
/* Load the SDL library */
if ( SDL_Init(0) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
return(1);
}
signal(SIGTERM, killed);
signal(SIGINT, killed);
init_sem = atoi(argv[1]);
sem = SDL_CreateSemaphore(init_sem);
printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem);
#if 0
/* Create all the threads */
for( i = 0; i < NUM_THREADS; ++i ) {
threads[i] = SDL_CreateThread(ThreadFunc, (void*)i);
}
/* Wait 10 seconds */
SDL_Delay(10 * 1000);
/* Wait for all threads to finish */
printf("Waiting for threads to finish\n");
alive = 0;
for( i = 0; i < NUM_THREADS; ++i ) {
SDL_WaitThread(threads[i], NULL);
}
printf("Finished waiting for threads\n");
#endif
SDL_DestroySemaphore(sem);
SDL_Quit();
return(0);
}
示例9: main
int main(){
mainData = malloc(sizeof(struct main_ProgramData));
//initialze the webcam
mainData->LocalWebcamData = VIDEO_webcamload("/dev/video0");
//So we can know to print debug shit
mainData->verbose = 1;
//Right now we don't want the render thread to do anything until we SemPost this
mainData->UI_renderhold = SDL_CreateSemaphore(0);
//This is the thread that sets up the video surface and handles events
mainData->UI_initandeventthread = SDL_CreateThread(UI_Initialize, NULL);
//Thread where the rendering happens
mainData->UI_renderthread = SDL_CreateThread( UI_thread, NULL);
SDL_WaitThread(mainData->UI_initandeventthread, NULL);
return 0;
}
示例10: tilt_free
void tilt_free(void)
{
if (mutex)
{
/* Get/set the status of the tilt sensor thread. */
SDL_mutexP(mutex);
state.status = 0;
SDL_mutexV(mutex);
/* Wait for the thread to terminate and destroy the mutex. */
SDL_WaitThread(thread, NULL);
SDL_DestroyMutex(mutex);
mutex = NULL;
thread = NULL;
}
}
示例11: locker
Thread::~Thread() {
SDL_Thread *th = NULL;
{
AutoLocker locker(&lock);
th = (SDL_Thread *)threadInfo;
if(!th)
return;
}
// we have to ensure thread handle is destroyed.
if(SDL_ThreadID() == threadId) {
// thread is deleting itself.
// SDL_WaitThread would cause deadlock.
cleanuper->Add(th);
}else{
SDL_WaitThread(th, NULL);
}
}
示例12: SDL_WaitThread
void Graphics::DeinitGraphics()
{
if (Graphics::Handle)
Graphics::ThreadData.flag = 0;
SDL_WaitThread(Graphics::ThreadData.thread, NULL);
for (int i = 0; Graphics::dlObjectList[i]; i++ )
{
free(Graphics::dlObjectList[i]);
Graphics::dlObjectList[i] = NULL;
}
for (int i = 0; Graphics::dlSpriteList[i]; i++ )
{
free(Graphics::dlSpriteList[i]);
Graphics::dlSpriteList[i] = NULL;
}
delete Graphics::Handle;
SDL_Quit();
}
示例13: SDL_WaitThread
WhoIsOnline::~WhoIsOnline()
{
config.removeListeners(this);
if (mThread && SDL_GetThreadID(mThread))
SDL_WaitThread(mThread, nullptr);
free(mMemoryBuffer);
mMemoryBuffer = nullptr;
// Remove possibly leftover temporary download
delete []mCurlError;
FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
delete *itd;
mOnlinePlayers.clear();
mOnlineNicks.clear();
}
示例14: n2s_destruct
static EEL_xno n2s_destruct(EEL_object *eo)
{
EB_socket *ebs = o2EB_socket(eo);
if(!ebs->rs)
return 0; /* Detached! We're done here. */
if(ebs->rs->sender)
{
ebs->rs->closed = 1;
SDL_WaitThread(ebs->rs->sender, NULL);
sfifo_close(&ebs->rs->fifo);
}
NET2_TCPClose(ebs->rs->n2socket);
if(ebs->rs->n2socket >= 0)
if(eb_sockets)
eb_sockets[ebs->rs->n2socket] = NULL;
free(ebs->rs);
return 0;
}
示例15: SDL_SemPost
void NetworkManager::cleanUp()
{
network_running = false;
SDL_SemPost(semaphore);
int st;
SDL_WaitThread(resolverThread, &st);
SDL_DestroySemaphore(semaphore);
semaphore = 0;
resolverThread = 0;
rqueue.clear();
#ifdef _WIN32
WSACleanup();
#endif
}