当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_mutexV函数代码示例

本文整理汇总了C++中SDL_mutexV函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_mutexV函数的具体用法?C++ SDL_mutexV怎么用?C++ SDL_mutexV使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_mutexV函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: texasync_clear

/*
 * Clear all tasks. There may still remain one currently executing task.
 */
void
texasync_clear(void)
{
        SDL_mutexP(storage_mutex);
        {
                while (finished_tasks != NULL) {
                        Task *task = finished_tasks;
                        DL_DELETE(finished_tasks, task);
                        free_task(task);
                        
                        /* Update finished task counter. */
                        assert(num_finished > 0);
                        num_finished--;
                }
                
                while (active_tasks != NULL) {
                        Task *task = active_tasks;
                        DL_DELETE(active_tasks, task);
                        free_task(task);
                }
        }
        SDL_mutexV(storage_mutex);
}
开发者ID:gamebytes,项目名称:shmupacabra,代码行数:26,代码来源:texture_async.c

示例2: seek_marker

bool
MPEGstream:: seek_marker(MPEGstream_marker const * marker)
{
    SDL_mutexP(mutex);

    if ( marker ) {
        /* Release current buffer */
        if(br->IsLocked())
        {
            br->Unlock();
            marker->marked_buffer->Lock();
        }

        /* Reset the data positions */
        br = marker->marked_buffer;
        data = marker->marked_data;
        stop = marker->marked_stop;
    }

    SDL_mutexV(mutex);

    return(marker != 0);
}
开发者ID:luislasonbra,项目名称:bennugd-wii,代码行数:23,代码来源:MPEGstream.cpp

示例3: glEnable

void FrameExporter::dump() {

    display.mode2D();

    glEnable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    char* next_pixel_ptr = (pixels_shared_ptr == pixels1) ? pixels2 : pixels1;

    // copy pixels - now the right way up
    glReadPixels(0, 0, display.width, display.height,
                 GL_RGB, GL_UNSIGNED_BYTE, next_pixel_ptr);

    // wait for lock before changing the pointer to point to our new buffer
    SDL_mutexP(mutex);

    //flip buffer we are pointing at
    pixels_shared_ptr = next_pixel_ptr;
    dumper_thread_state = FRAME_EXPORTER_DUMP;

    SDL_CondSignal(cond);
    SDL_mutexV(mutex);
}
开发者ID:atondwal,项目名称:Core,代码行数:23,代码来源:ppm.cpp

示例4: AA_DirectUpdate

static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
{
	int i;
	SDL_Rect *rect;

	fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context));
#if 1
	aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context));
#else
	/* Render only the rectangles in the list */
	printf("Update rects : ");
	for ( i=0; i < numrects; ++i ) {
		rect = &rects[i];
		printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h);
		aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio);
	}
	printf("\n");
#endif
	SDL_mutexP(AA_mutex);
	aa_flush(AA_context);
	SDL_mutexV(AA_mutex);
	return;
}
开发者ID:0-14N,项目名称:NDroid,代码行数:23,代码来源:SDL_aavideo.c

示例5: mutex_unlock

int mutex_unlock(Mutex* m)
{
    int ret = 0;
    

    if(!m) return -1;
    if(!m->mutex) return -2;
    if(SDL_mutexV(m->mutex)==-1)
        printf("Fehler bei unlock!\n");
    else return 0;
    /*

#ifdef _WIN32   
    ret = !ReleaseMutex(m->mutex);
#else
    ret = pthread_mutex_unlock((pthread_mutex_t*)m->mutex);
#endif
    
    //if(ret)
        //printf("capture.unlock_mutex fehler bei unlock mutex\n");
     * */
    return ret;
}
开发者ID:alex1818,项目名称:OpenLive4Cam,代码行数:23,代码来源:mutex.c

示例6: SDL_mutexP

bool Network::messageReady()
{
    int len = -1, msgId;

    SDL_mutexP(mMutex);
    if (mInSize >= 2)
    {
        msgId = readWord(0);
        if (msgId == SMSG_SERVER_VERSION_RESPONSE)
            len = 10;
        else
            len = packet_lengths[msgId];

        if (len == -1 && mInSize > 4)
            len = readWord(2);

    }

    bool ret = (mInSize >= static_cast<unsigned int>(len));
    SDL_mutexV(mMutex);

    return ret;
}
开发者ID:Ablu,项目名称:invertika,代码行数:23,代码来源:network.cpp

示例7: while

void draw_char_sel::get_login_chars()
{
	while (SDL_mutexP(draw_mtx) == -1) {};
	lin_char_info **data = owner->get_login_chars();
	sdl_animate_button **chars;
	chars = (sdl_animate_button**)&widgets[0];
	for (int i = 0; i < 4; i++)
	{
		chars[i]->set_info(data[i + (page_num*4)]);
	}
	ready = true;
	
	sdl_char_info *stuff;
	stuff = (sdl_char_info*)widgets[11];
	stuff->hand_info(chars[0]->get_info());
	cur_char_slot = 0;
	chars[0]->animate(true);
	chars[1]->animate(false);
	chars[2]->animate(false);
	chars[3]->animate(false);

	SDL_mutexV(draw_mtx);
}
开发者ID:tea91,项目名称:l1j-client,代码行数:23,代码来源:draw_char_sel.cpp

示例8: pop_save_return

static int pop_save_return(lua_State *L)
{
	save_queue *q = NULL;
	SDL_mutexP(main_save->lock_oqueue);
	if (main_save->oqueue_head)
	{
		q = main_save->oqueue_head;
		if (q) main_save->oqueue_head = q->next;
		if (!main_save->oqueue_head) main_save->oqueue_tail = NULL;
	}
	SDL_mutexV(main_save->lock_oqueue);

	if (q)
	{
		lua_pushstring(L, q->zfname);
		free(q->zfname);
		free(q);
	}
	else
		lua_pushnil(L);

	return 1;
}
开发者ID:naclander,项目名称:tome,代码行数:23,代码来源:serial.c

示例9: Thread_Run

/*
 * @brief Wrap the user's function in our own for introspection.
 */
static int32_t Thread_Run(void *data) {
	thread_t *t = (thread_t *) data;

	while (thread_pool.mutex) {

		SDL_mutexP(t->mutex);

		if (t->status == THREAD_RUNNING) {
			t->Run(t->data);

			t->Run = NULL;
			t->data = NULL;

			t->status = THREAD_WAIT;
		} else {
			SDL_CondWait(t->cond, t->mutex);
		}

		SDL_mutexV(t->mutex);
	}

	return 0;
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:26,代码来源:thread.c

示例10: SDL_DelThread

static void SDL_DelThread(SDL_Thread *thread)
{
	int i;

	if ( !thread_lock ) {
		return;
	}
	SDL_mutexP(thread_lock);
	for ( i=0; i<SDL_numthreads; ++i ) {
		if ( thread == SDL_Threads[i] ) {
			break;
		}
	}
	if ( i < SDL_numthreads ) {
		if ( --SDL_numthreads > 0 ) {
			while ( i < SDL_numthreads ) {
				SDL_Threads[i] = SDL_Threads[i+1];
				++i;
			}
		} else {
			SDL_maxthreads = 0;
			SDL_free(SDL_Threads);
			SDL_Threads = NULL;
		}
#ifdef DEBUG_THREADS
		printf("Deleting thread (%d left - %d max)\n",
				SDL_numthreads, SDL_maxthreads);
#endif
	}
	SDL_mutexV(thread_lock);

#if 0	/* There could be memory corruption if another thread is starting */
	if ( SDL_Threads == NULL ) {
		SDL_ThreadsQuit();
	}
#endif
}
开发者ID:3bu1,项目名称:crossbridge,代码行数:37,代码来源:SDL_thread.c

示例11: FillHWRect

static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
{
	int dstX, dstY;
	int dstW, dstH;
	RivaBitmap *Bitmap = (RivaBitmap *)(mapped_io + BITMAP_OFFSET);

	
	if ( switched_away ) {
		return -2; 
	}
	if ( dst == this->screen ) {
		SDL_mutexP(hw_lock);
	}

	
	dstW = rect->w;
	dstH = rect->h;
	FB_dst_to_xy(this, dst, &dstX, &dstY);

	
	dstX += rect->x;
	dstY += rect->y;

	RIVA_FIFO_FREE(Bitmap, 1);
	Bitmap->Color1A = color;

	RIVA_FIFO_FREE(Bitmap, 2);
	Bitmap->UnclippedRectangle[0].TopLeft     = (dstX << 16) | dstY; 
	Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH;

	FB_AddBusySurface(dst);

	if ( dst == this->screen ) {
		SDL_mutexV(hw_lock);
	}
	return(0);
}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:37,代码来源:SDL_fbriva.c

示例12: while

void draw_maint_png::draw(SDL_Surface *display)
{
	while (SDL_mutexP(draw_mtx) == -1) {};
	SDL_FillRect(display, NULL, 0);
	sdl_drawmode::draw(display);
	char temp[27];
	sprintf(temp, "Displaying %d.png", background);
	lineage_font.draw(display, 320, 240, temp, 0x7392);
	if (extracting && (background < 65535))
	{
		char name[500];
		sprintf(name, "png/%d.bmp", background);
		if (gfx[0]->valid())
			gfx[0]->make_bmp(name);
		
		background++;
		
		if (gfx[0] != 0)
		{
			delete gfx[0];
			gfx[0] = 0;
		}
		gfx[0] = new sdl_graphic(background, 0, 0, GRAPH_PNG, owner);
	}
	else if (extracting && (background == 65535))
	{
		extracting = false;
		background = 0;
		if (gfx[0] != 0)
		{
			delete gfx[0];
			gfx[0] = 0;
		}
		gfx[0] = new sdl_graphic(background, 0, 0, GRAPH_PNG, owner);
	}
	SDL_mutexV(draw_mtx);
}
开发者ID:tea91,项目名称:l1j-client,代码行数:37,代码来源:draw_maint_png.cpp

示例13: while

unsigned int sdl_user::add_request(client_request rqst)
{
	unsigned int temp_val;
	if (stop_thread == false)
	{
		while (SDL_mutexP(requests_mtx) == -1) {};
		client_request *temp = new client_request;
		temp->data.rload.name = 0;
		memcpy(temp, &rqst, sizeof(rqst));
		temp->id = ++request_id;
		temp_val = request_id;
		switch (rqst.request)
		{
			case CLIENT_REQUEST_LOAD_SPRITE:
				if (rqst.data.sload.name != 0)
				{
					temp->data.sload.name = new char[strlen(rqst.data.sload.name)+1];
					strcpy(temp->data.sload.name, rqst.data.sload.name);
				}
				break;
			case CLIENT_REQUEST_LOAD_SDL_GRAPHIC:
				if (rqst.data.rload.name != 0)
				{
					temp->data.rload.name = new char[strlen(rqst.data.rload.name)+1];
					strcpy(temp->data.rload.name, rqst.data.rload.name);
				}
				break;
			case CLIENT_REQUEST_CHECK_MAP:
			case CLIENT_REQUEST_LOAD_TILE:
			default:
				break;
		}
		request_list.push_back(temp);
		SDL_mutexV(requests_mtx);
	}
	return temp_val;
}
开发者ID:tea91,项目名称:l1j-client,代码行数:37,代码来源:sdl_user_common.cpp

示例14: mem_alloc

/* midi engines register a provider (one each!) */
struct midi_provider *midi_provider_register(const char *name,
                struct midi_driver *driver)
{
        struct midi_provider *n;

        if (!midi_mutex) return NULL;

        n = mem_alloc(sizeof(struct midi_provider));
        n->name = str_dup(name);
        n->poll = driver->poll;
        n->enable = driver->enable;
        n->disable = driver->disable;
        if (driver->flags & MIDI_PORT_CAN_SCHEDULE) {
                n->send_later = driver->send;
                n->send_now = NULL;
                n->drain = driver->drain;
        } else {
                n->send_later = NULL;
                n->send_now = driver->send;
                n->drain = NULL;
        }

        SDL_mutexP(midi_mutex);
        n->next = port_providers;
        port_providers = n;

        if (driver->thread) {
                // FIXME this cast is stupid
                n->thread = SDL_CreateThread((int (*)(void*))driver->thread, n);
        } else {
                n->thread = NULL;
        }

        SDL_mutexV(midi_mutex);

        return n;
}
开发者ID:CharlesLio,项目名称:schismtracker,代码行数:38,代码来源:midi-core.c

示例15: mix_buffer

static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
{
   if ( ! audio->paused ) {
#ifdef MACOSX
        SDL_mutexP(audio->mixer_lock);
#endif
        if ( audio->convert.needed ) {
            audio->spec.callback(audio->spec.userdata,
                    (Uint8 *)audio->convert.buf,audio->convert.len);
            SDL_ConvertAudio(&audio->convert);
            if ( audio->convert.len_cvt != audio->spec.size ) {
                /* Uh oh... probably crashes here */;
            }
            memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
        } else {
            audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
        }
#ifdef MACOSX
        SDL_mutexV(audio->mixer_lock);
#endif
    }

    DecrementAtomic((SInt32 *) &need_to_mix);
}
开发者ID:Goettsch,项目名称:game-editor,代码行数:24,代码来源:SDL_romaudio.c


注:本文中的SDL_mutexV函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。