本文整理汇总了C++中SDL_CondSignal函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_CondSignal函数的具体用法?C++ SDL_CondSignal怎么用?C++ SDL_CondSignal使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_CondSignal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: aout_flush_audio
static void aout_flush_audio(SDL_Aout *aout)
{
SDL_Aout_Opaque *opaque = aout->opaque;
SDL_LockMutex(opaque->wakeup_mutex);
SDLTRACE("aout_flush_audio()");
opaque->need_flush = 1;
SDL_CondSignal(opaque->wakeup_cond);
SDL_UnlockMutex(opaque->wakeup_mutex);
}
示例2: SDL_GetError
bool condition::notify_one()
{
if(SDL_CondSignal(cond_) < 0) {
std::cerr << "SDL_CondSignal: " << SDL_GetError() << "\n";
return false;
}
return true;
}
示例3: SDL_GetError
bool condition::notify_one()
{
if(SDL_CondSignal(cond_) < 0) {
ERR_G << "SDL_CondSignal: " << SDL_GetError() << std::endl;
return false;
}
return true;
}
示例4: FE_PushEvent
int FE_PushEvent(SDL_Event *ev) {
SDL_LockMutex(eventLock);
while (SDL_PushEvent(ev) == -1)
SDL_CondWait(eventWait, eventLock);
SDL_UnlockMutex(eventLock);
SDL_CondSignal(eventWait); /* ? wake thread Waiting for event */
return 1;
}
示例5: client_socket_close
/**
* Close a client socket.
* @param csock
* Socket to close.
*/
void client_socket_close(client_socket_t *csock)
{
HARD_ASSERT(csock != NULL);
SDL_LockMutex(socket_mutex);
if (csock->sc != NULL) {
socket_destroy(csock->sc);
csock->sc = NULL;
}
abort_thread = 1;
/* Poke anyone waiting at a cond */
SDL_CondSignal(input_buffer_cond);
SDL_CondSignal(output_buffer_cond);
SDL_UnlockMutex(socket_mutex);
}
示例6: SDL_mutexP
int ThreadPool::threadWrapper(void* param) {
ThreadPoolItem* data = (ThreadPoolItem*)param;
SDL_mutexP(data->pool->mutex);
while(true) {
while(data->pool->nextAction == NULL && !data->pool->quitting)
SDL_CondWait(data->pool->awakeThread, data->pool->mutex);
if(data->pool->quitting) break;
data->pool->usedThreads.insert(data);
data->pool->availableThreads.erase(data);
Action* act = data->pool->nextAction; data->pool->nextAction = NULL;
data->headless = data->pool->nextIsHeadless;
data->name = data->pool->nextName;
data->finished = false;
data->working = true;
data->pool->nextData = data;
SDL_mutexV(data->pool->mutex);
SDL_CondSignal(data->pool->threadStartedWork);
g_pLogFile->textOut("Running Thread: " + data->name);
data->ret = act->handle();
delete act;
g_pLogFile->textOut( data->name + " [finished]" );
SDL_mutexP(data->pool->mutex);
data->finished = true;
SDL_CondSignal(data->pool->threadStatusChanged);
if(!data->headless) { // headless means that we just can clean it up right now without waiting
SDL_CondSignal(data->finishedSignal);
while(data->working) SDL_CondWait(data->readyForNewWork, data->pool->mutex);
} else
data->working = false;
data->pool->usedThreads.erase(data);
data->pool->availableThreads.insert(data);
SDL_CondSignal(data->pool->threadStatusChanged);
//setCurThreadName("");
}
SDL_mutexV(data->pool->mutex);
return 0;
}
示例7: SDL_LockMutex
void JobQueue::Queue(Job *job)
{
// push the job onto the queue
SDL_LockMutex(m_queueLock);
m_queue.push_back(job);
SDL_UnlockMutex(m_queueLock);
// and tell a waiting runner that there's one available
SDL_CondSignal(m_queueWaitCond);
}
示例8: packet_queue_abort
static void packet_queue_abort(PacketQueue *q)
{
SDL_LockMutex(q->mutex);
q->abort_request = 1;
SDL_CondSignal(q->cond);
SDL_UnlockMutex(q->mutex);
}
示例9: frame_queue_next
static void frame_queue_next(FrameQueue *f)
{
av_frame_unref(f->queue[f->rindex].frame);
if (++f->rindex == f->max_size)
f->rindex = 0;
SDL_LockMutex(f->mutex);
f->size--;
SDL_CondSignal(f->cond);
SDL_UnlockMutex(f->mutex);
}
示例10: video_refresh_timer
/*
每次timer到时间会进来(timer到时间发 FF_REFRESH_EVENT,收到 FF_REFRESH_EVENT 会进来)
一个timer只进一次timer就失效了。不过本函数里面会再起一个timer。
从is->pictq拿出一个 VideoPicture 进行显示,然后pictq的读指针向前移动一步
*/
void video_refresh_timer(void *userdata) {
VideoState *is = (VideoState *)userdata;
VideoPicture *vp;
double actual_delay, delay, sync_threshold, ref_clock, diff;
if (is->video_st) {
if (is->pictq_size == 0) {
schedule_refresh(is, 1);
}
else {
vp = &is->pictq[is->pictq_rindex];
delay = vp->pts - is->frame_last_pts; /* the pts from last time */
is->frame_last_pts = vp->pts;
/* ----------- */
/*音视频同步*/
ref_clock = get_audio_clock(is);
diff = vp->pts - ref_clock;
if (diff <= -0.015) {
delay = 0;
}
else if (diff >= 0.015) {
delay = 2 * delay;
}
/* ----------- */
if (delay == 0) {
count_delay_is_zero++;
delay = 0.010;
}
count_pict++;
printf("delay==0 percentage is %lf",(double)count_delay_is_zero/count_pict);
schedule_refresh(is, (int)(delay * 1000 + 0.5));
/* show the picture! */
video_display(is);
/* update queue for next picture! */
if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) {
is->pictq_rindex = 0;
}
SDL_LockMutex(is->pictq_mutex);
is->pictq_size--;
SDL_CondSignal(is->pictq_cond);
SDL_UnlockMutex(is->pictq_mutex);
}
}
else {
schedule_refresh(is, 100);
}
}
示例11: SDL_mutexP
void SoundSDL::read(u16 * stream, int length)
{
if (!_initialized || length <= 0 || !emulating)
return;
SDL_mutexP(_mutex);
_rbuf.read(stream, std::min(static_cast<std::size_t>(length) / 2, _rbuf.used()));
SDL_CondSignal(_cond);
SDL_mutexV(_mutex);
}
示例12: fifo_signal
int fifo_signal(struct fifo *fifo) {
ASSERT_FIFO_LOCKED(fifo);
#if defined(HAVE_LIBPTHREAD) && !defined(SDL_FIFOS)
/* linux multi-process locking */
return pthread_cond_signal(&fifo->cond);
#else
/* cross platform locking */
return SDL_CondSignal(fifo->cond);
#endif
}
示例13: DelayCallback
static void DelayCallback(void *_delay_data)
{
delay_data_t *delay_data = _delay_data;
SDL_LockMutex(delay_data->mutex);
delay_data->finished = 1;
SDL_CondSignal(delay_data->cond);
SDL_UnlockMutex(delay_data->mutex);
}
示例14: aout_set_volume
static void aout_set_volume(SDL_Aout *aout, float left_volume, float right_volume)
{
SDL_Aout_Opaque *opaque = aout->opaque;
SDL_LockMutex(opaque->wakeup_mutex);
SDLTRACE("aout_flush_audio()");
opaque->left_volume = left_volume;
opaque->right_volume = right_volume;
opaque->need_set_volume = 1;
SDL_CondSignal(opaque->wakeup_cond);
SDL_UnlockMutex(opaque->wakeup_mutex);
}
示例15: aout_set_volume
static void aout_set_volume(SDL_Aout *aout, float left_volume, float right_volume)
{
SDL_Aout_Opaque *opaque = aout->opaque;
SDL_LockMutex(opaque->wakeup_mutex);
ALOGI("aout_set_volume(%f, %f)", left_volume, right_volume);
opaque->left_volume = left_volume;
opaque->right_volume = right_volume;
opaque->need_set_volume = 1;
SDL_CondSignal(opaque->wakeup_cond);
SDL_UnlockMutex(opaque->wakeup_mutex);
}