本文整理汇总了C++中pause函数的典型用法代码示例。如果您正苦于以下问题:C++ pause函数的具体用法?C++ pause怎么用?C++ pause使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pause函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QGraphicsScene
//.........这里部分代码省略.........
Score->setFrameStyle( QFrame::StyledPanel | QFrame::Plain );
Score->setAlignment( Qt::AlignCenter );
ToolBar->addWidget(Score);
ToolBar->addSeparator();
Health = new QLabel("Health");
ToolBar->addWidget(Health);
HealthBar = new QProgressBar();
HealthBar->setValue(100);
HealthBar->setTextVisible(false);
ToolBar->addWidget(HealthBar);
ToolBar->addSeparator();
Start = new QPushButton("START");
ToolBar->addWidget(Start);
ToolBar->addSeparator();
Pause = new QPushButton("PAUSE");
Quit = new QPushButton("QUIT");
ToolBar->addWidget(Quit);
ToolBar->addSeparator();
Layout->addWidget(GameView);
Layout->addWidget(ToolBar);
timeInterval = 5;
timeCounter = 0;
timer = new QTimer(this);
timer->setInterval(timeInterval);
setLayout(Layout);
StartView = new QGraphicsPixmapItem();
StartPic = new QPixmap("Images/Game_StartScreen.png");
StartPicScaled = StartPic->scaled( 1000, 550, Qt::IgnoreAspectRatio, Qt::FastTransformation );
StartView->setPixmap(StartPicScaled);
GameScene->addItem(StartView);
StartView->setPos(-13, -19);
NameBox = new QTextEdit();
NameBox->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
NameBox->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
NameBox->setFixedHeight(20);
NameBox->setFixedWidth(200);
GameScene->addWidget(NameBox);
NameBox->move(705,422);
////////////////////////// Allocate Main Player Object /////////////////////////
tommy = new Tommy();
HorsePic = new QPixmap("Images/HORSE_1.png");
HorsePic2 = new QPixmap("Images/HORSE_2.png");
HorseScaled = HorsePic->scaled( 150, 150, Qt::IgnoreAspectRatio, Qt::FastTransformation );
HorseScaled2 = HorsePic2->scaled( 150, 150, Qt::IgnoreAspectRatio, Qt::FastTransformation );
leftPosition = false;
////////////////////////// Object Logistics /////////////////////////
bearExists = false;
BearCounter = 0;
numBears = 0;
MAX_BEARS = 3;
bearVelocty = .75;
srand( time(NULL));
bearStartX = rand()%800 + 800;
DPSexists = false;
DPSlimit = 40;
DPScounter = 0;
treeExists = false;
treeCounter = 0;
treeVelocity = 1.5;
devilExists = false;
devilCounter = 0;
fireballExists = false;
duckExists = false;
duckCounter = 0;
bookExists = false;
scoreFactor = .00001;
tStart = clock();
////////////////////////// Connections /////////////////////////
connect(Start, SIGNAL(clicked()), this, SLOT( start() ));
connect(Quit, SIGNAL(clicked()), this, SLOT( exit() ));
connect(Pause, SIGNAL(clicked()), this, SLOT( pause() ));
connect(timer, SIGNAL(timeout()), this, SLOT( scoreCounter() ));
connect(timer, SIGNAL(timeout()), this, SLOT( imageRotate() ));
connect(timer, SIGNAL(timeout()), this, SLOT( objectAnimate() ));
connect(timer, SIGNAL(timeout()), this, SLOT( jumpRegulator() ));
connect(timer, SIGNAL(timeout()), this, SLOT( tommyJump() ));
connect(timer, SIGNAL(timeout()), this, SLOT( fireballShoot() ));
connect(timer, SIGNAL(timeout()), this, SLOT( bookDrop() ));
connect(timer, SIGNAL(timeout()), this, SLOT( tommyCollision() ));
connect(timer, SIGNAL(timeout()), this, SLOT( addItems() ));
connect(timer, SIGNAL(timeout()), this, SLOT( speedUpdater() ));
setFocus();
}
示例2: do_test
static int
do_test (void)
{
pthread_t th;
int old, rc;
int ret = 0;
int fd[2];
rc = pipe (fd);
if (rc < 0)
error (EXIT_FAILURE, errno, "couldn't create pipe");
rc = pthread_create (&th, NULL, tf, NULL);
if (rc)
error (EXIT_FAILURE, rc, "couldn't create thread");
rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
if (rc)
{
error (0, rc, "1st pthread_setcanceltype failed");
ret = 1;
}
if (old != PTHREAD_CANCEL_DEFERRED && old != PTHREAD_CANCEL_ASYNCHRONOUS)
{
error (0, 0, "1st pthread_setcanceltype returned invalid value %d",
old);
ret = 1;
}
clobber_lots_of_regs ();
close (fd[0]);
rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
if (rc)
{
error (0, rc, "pthread_setcanceltype after close failed");
ret = 1;
}
if (old != PTHREAD_CANCEL_DEFERRED)
{
error (0, 0, "pthread_setcanceltype after close returned invalid value %d",
old);
ret = 1;
}
clobber_lots_of_regs ();
close (fd[1]);
rc = pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, &old);
if (rc)
{
error (0, rc, "pthread_setcanceltype after 2nd close failed");
ret = 1;
}
if (old != PTHREAD_CANCEL_ASYNCHRONOUS)
{
error (0, 0, "pthread_setcanceltype after 2nd close returned invalid value %d",
old);
ret = 1;
}
struct sigaction sa = { .sa_handler = handler, .sa_flags = 0 };
sigemptyset (&sa.sa_mask);
sigaction (SIGALRM, &sa, NULL);
struct itimerval it;
it.it_value.tv_sec = 1;
it.it_value.tv_usec = 0;
it.it_interval = it.it_value;
setitimer (ITIMER_REAL, &it, NULL);
clobber_lots_of_regs ();
pause ();
memset (&it, 0, sizeof (it));
setitimer (ITIMER_REAL, &it, NULL);
rc = pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &old);
if (rc)
{
error (0, rc, "pthread_setcanceltype after pause failed");
ret = 1;
}
if (old != PTHREAD_CANCEL_DEFERRED)
{
error (0, 0, "pthread_setcanceltype after pause returned invalid value %d",
old);
ret = 1;
}
it.it_value.tv_sec = 1;
it.it_value.tv_usec = 0;
it.it_interval = it.it_value;
setitimer (ITIMER_REAL, &it, NULL);
clobber_lots_of_regs ();
pause ();
memset (&it, 0, sizeof (it));
setitimer (ITIMER_REAL, &it, NULL);
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
switch(fork()) {
case -1:
msg_out(crit, "fork: %m");
exit(1);
case 0:
/* child */
pid = setsid();
if (pid == -1) {
msg_out(crit, "setsid: %m");
exit(1);
}
break;
default:
/* parent */
exit(0);
}
}
master_pid = getpid();
umask(S_IWGRP|S_IWOTH);
if ((fp = fopen(pidfile, "w")) != NULL) {
fprintf(fp, "%u\n", (unsigned)master_pid);
fchown(fileno(fp), PROCUID, PROCGID);
fclose(fp);
} else {
msg_out(warn, "cannot open pidfile %s", pidfile);
}
setsignal(SIGHUP, reload);
if (fg)
setsignal(SIGINT, cleanup);
else
setsignal(SIGINT, SIG_IGN);
setsignal(SIGQUIT, SIG_IGN);
setsignal(SIGILL, SIG_IGN);
setsignal(SIGTRAP, SIG_IGN);
setsignal(SIGABRT, SIG_IGN);
#ifdef SIGEMT
setsignal(SIGEMT, SIG_IGN);
#endif
setsignal(SIGSYS, SIG_IGN);
setsignal(SIGPIPE, SIG_IGN);
setsignal(SIGALRM, SIG_IGN);
setsignal(SIGTERM, cleanup);
setsignal(SIGUSR1, SIG_IGN);
setsignal(SIGUSR2, SIG_IGN);
#ifdef SIGPOLL
setsignal(SIGPOLL, SIG_IGN);
#endif
setsignal(SIGVTALRM, SIG_IGN);
setsignal(SIGPROF, SIG_IGN);
setsignal(SIGXCPU, SIG_IGN);
setsignal(SIGXFSZ, SIG_IGN);
#ifdef USE_THREAD
if ( threading ) {
if (max_thread <= 0 || max_thread > THREAD_LIMIT) {
max_thread = THREAD_LIMIT;
}
/* resource limit is problem in threadig (e.g. Solaris:=64)*/
memset((caddr_t)&rl, 0, sizeof rl);
if (getrlimit(RLIMIT_NOFILE, &rl) != 0)
msg_out(warn, "getrlimit: %m");
else
save_fd = rl.rlim_cur;
if (rl.rlim_cur < (rlim_t)max_fd)
rl.rlim_cur = max_fd; /* willing to fix to max_fd */
if ( rl.rlim_cur != save_fd ) /* if rlim_cur is changed */
if (setrlimit(RLIMIT_NOFILE, &rl) != 0)
msg_out(warn, "cannot set rlimit(max_fd)");
setregid(0, PROCGID);
setreuid(0, PROCUID);
pthread_mutex_init(&mutex_select, NULL);
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
msg_out(norm, "Starting: MAX_TH(%d)", max_thread);
for (i=0; i<max_thread; i++) {
if (pthread_create(&tid, &attr,
(void *)&serv_loop, (void *)NULL) != 0)
exit(1);
}
main_thread = pthread_self(); /* store main thread ID */
for (;;) {
pause();
}
} else {
#endif
setsignal(SIGCHLD, reapchild);
setregid(0, PROCGID);
setreuid(0, PROCUID);
msg_out(norm, "Starting: MAX_CH(%d)", max_child);
serv_loop();
#ifdef USE_THREAD
}
#endif
return(0);
}
示例4: sfSound_pause
void sfSound_pause(sfSound* sound)
{
CSFML_CALL(sound, pause());
}
示例5: pause
void AVDemuxThread::run()
{
m_buffering = false;
end = false;
if (audio_thread && !audio_thread->isRunning())
audio_thread->start(QThread::HighPriority);
if (video_thread && !video_thread->isRunning())
video_thread->start();
int index = 0;
Packet pkt;
pause(false);
qDebug("get av queue a/v thread = %p %p", audio_thread, video_thread);
PacketBuffer *aqueue = audio_thread ? audio_thread->packetQueue() : 0;
PacketBuffer *vqueue = video_thread ? video_thread->packetQueue() : 0;
// aqueue as a primary buffer: music with/without cover
AVThread* thread = !video_thread || (audio_thread && demuxer->hasAttacedPicture()) ? audio_thread : video_thread;
m_buffer = thread->packetQueue();
const qint64 buf2 = aqueue ? aqueue->bufferValue() : 1; // TODO: may be changed by user. Deal with audio track change
if (aqueue) {
aqueue->clear();
aqueue->setBlocking(true);
}
if (vqueue) {
vqueue->clear();
vqueue->setBlocking(true);
}
connect(thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished(qint64)), Qt::DirectConnection);
seek_tasks.clear();
bool was_end = false;
if (ademuxer) {
ademuxer->seek(0LL);
}
while (!end) {
processNextSeekTask();
if (demuxer->atEnd()) {
if (!was_end) {
if (aqueue) {
aqueue->put(Packet::createEOF());
aqueue->blockEmpty(false); // do not block if buffer is not enough. block again on seek
}
if (vqueue) {
vqueue->put(Packet::createEOF());
vqueue->blockEmpty(false);
}
}
m_buffering = false;
Q_EMIT mediaStatusChanged(QtAV::BufferedMedia);
was_end = true;
// wait for a/v thread finished
msleep(100);
continue;
}
was_end = false;
if (tryPause()) {
continue; //the queue is empty and will block
}
updateBufferState();
if (!demuxer->readFrame()) {
continue;
}
index = demuxer->stream();
pkt = demuxer->packet();
Packet apkt;
bool audio_has_pic = demuxer->hasAttacedPicture();
int a_ext = 0;
if (ademuxer) {
QMutexLocker locker(&buffer_mutex);
Q_UNUSED(locker);
if (ademuxer) {
a_ext = -1;
audio_has_pic = ademuxer->hasAttacedPicture();
// FIXME: buffer full but buffering!!!
// avoid read external track everytime. aqueue may not block full
// vqueue will not block if aqueue is not enough
if (!aqueue->isFull() || aqueue->isBuffering()) {
if (ademuxer->readFrame()) {
if (ademuxer->stream() == ademuxer->audioStream()) {
a_ext = 1;
apkt = ademuxer->packet();
}
}
// no continue otherwise. ademuxer finished earlier than demuxer
}
}
}
//qDebug("vqueue: %d, aqueue: %d/isbuffering %d isfull: %d, buffer: %d/%d", vqueue->size(), aqueue->size(), aqueue->isBuffering(), aqueue->isFull(), aqueue->buffered(), aqueue->bufferValue());
//QMutexLocker locker(&buffer_mutex); //TODO: seems we do not need to lock
//Q_UNUSED(locker);
/*1 is empty but another is enough, then do not block to
ensure the empty one can put packets immediatly.
But usually it will not happen, why?
*/
/* demux thread will be blocked only when 1 queue is full and still put
* if vqueue is full and aqueue becomes empty, then demux thread
* will be blocked. so we should wake up another queue when empty(or threshold?).
* TODO: the video stream and audio stream may be group by group. provide it
* stream data: aaaaaaavvvvvvvaaaaaaaavvvvvvvvvaaaaaa, it happens
* stream data: aavavvavvavavavavavavavavvvaavavavava, it's ok
//.........这里部分代码省略.........
示例6: main
//.........这里部分代码省略.........
printf(_("Solar elevation: %f\n"), elevation);
}
/* Use elevation of sun to set color temperature */
color_setting_t interp;
interpolate_color_settings(&scheme, elevation, &interp);
if (verbose || mode == PROGRAM_MODE_PRINT) {
period_t period = get_period(&scheme,
elevation);
double transition =
get_transition_progress(&scheme,
elevation);
print_period(period, transition);
printf(_("Color temperature: %uK\n"),
interp.temperature);
printf(_("Brightness: %.2f\n"),
interp.brightness);
}
if (mode == PROGRAM_MODE_PRINT) {
exit(EXIT_SUCCESS);
}
/* Adjust temperature */
r = method->set_temperature(&state, &interp);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"), stderr);
method->free(&state);
exit(EXIT_FAILURE);
}
/* In Quartz (OSX) the gamma adjustments will automatically
revert when the process exits. Therefore, we have to loop
until CTRL-C is received. */
if (strcmp(method->name, "quartz") == 0) {
fputs(_("Press ctrl-c to stop...\n"), stderr);
pause();
}
}
break;
case PROGRAM_MODE_MANUAL:
{
if (verbose) printf(_("Color temperature: %uK\n"), temp_set);
/* Adjust temperature */
color_setting_t manual;
memcpy(&manual, &scheme.day, sizeof(color_setting_t));
manual.temperature = temp_set;
r = method->set_temperature(&state, &manual);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"), stderr);
method->free(&state);
exit(EXIT_FAILURE);
}
/* In Quartz (OSX) the gamma adjustments will automatically
revert when the process exits. Therefore, we have to loop
until CTRL-C is received. */
if (strcmp(method->name, "quartz") == 0) {
fputs(_("Press ctrl-c to stop...\n"), stderr);
pause();
}
}
break;
case PROGRAM_MODE_RESET:
{
/* Reset screen */
color_setting_t reset = { NEUTRAL_TEMP, { 1.0, 1.0, 1.0 }, 1.0 };
r = method->set_temperature(&state, &reset);
if (r < 0) {
fputs(_("Temperature adjustment failed.\n"), stderr);
method->free(&state);
exit(EXIT_FAILURE);
}
/* In Quartz (OSX) the gamma adjustments will automatically
revert when the process exits. Therefore, we have to loop
until CTRL-C is received. */
if (strcmp(method->name, "quartz") == 0) {
fputs(_("Press ctrl-c to stop...\n"), stderr);
pause();
}
}
break;
case PROGRAM_MODE_CONTINUAL:
{
r = run_continual_mode(&loc, &scheme,
method, &state,
transition, verbose);
if (r < 0) exit(EXIT_FAILURE);
}
break;
}
/* Clean up gamma adjustment state */
method->free(&state);
return EXIT_SUCCESS;
}
示例7: main
//.........这里部分代码省略.........
/* EXEC SQL WHENEVER SQLERROR GOTO sqlerr; */
for( i=0; i < num_conn; i++ ){
ctx[i] = mysql_init(NULL);
if(!ctx[i]) goto sqlerr;
}
for( t_num=0; t_num < num_conn; t_num++ ){
thd_arg[t_num].port= port;
thd_arg[t_num].number= t_num;
pthread_create( &t[t_num], NULL, (void *)thread_main, (void *)&(thd_arg[t_num]) );
}
printf("\nRAMP-UP TIME.(%d sec.)\n",lampup_time);
fflush(stdout);
sleep(lampup_time);
printf("\nMEASURING START.\n\n");
fflush(stdout);
/* sleep(measure_time); */
/* start timer */
#ifndef _SLEEP_ONLY_
if( setitimer(ITIMER_REAL, &itval, NULL) == -1 ) {
fprintf(stderr, "error in setitimer()\n");
}
#endif
counting_on = 1;
/* wait signal */
for(i = 0; i < (measure_time / PRINT_INTERVAL); i++ ) {
#ifndef _SLEEP_ONLY_
pause();
#else
sleep(PRINT_INTERVAL);
alarm_dummy();
#endif
}
counting_on = 0;
#ifndef _SLEEP_ONLY_
/* stop timer */
itval.it_interval.tv_sec = 0;
itval.it_interval.tv_usec = 0;
itval.it_value.tv_sec = 0;
itval.it_value.tv_usec = 0;
if( setitimer(ITIMER_REAL, &itval, NULL) == -1 ) {
fprintf(stderr, "error in setitimer()\n");
}
#endif
printf("\nSTOPPING THREADS");
activate_transaction = 0;
/* wait threads' ending and close connections*/
for( i=0; i < num_conn; i++ ){
pthread_join( t[i], NULL );
}
printf("\n");
free(ctx);
for( i=0; i < num_conn; i++ ){
free(stmt[i]);
}
示例8: login
void login(LinkedList<Item> *listOfItems, LinkedList<Club> *listOfClubs, LinkedList<User> *listOfUsers)
{
string password, username;
Node<User> *tmp;
cout << "Input username: ";
getline(cin, username);
cout << "Input password: ";
getline(cin, password);
/*Password Masking
#ifdef _WIN32 //For Windows (conio.h is only included if on a window OS)
temp = _getch();
while(temp != '\r')
{
cout << "Input password" << endl;
temp = _getch();
if (temp == '\r')
break;
std::cout << "*";
password += temp;
}
#elif __APPLE__
//password = getpass("Input password");
#elif __linux__
//password = getpass("Input password");
#elif __unix__
//password = getpass("Input password");
#endif
*/
tmp = listOfUsers->mHead;
while (tmp != NULL)
{
if ((tmp->mData.getUserName() == username) && (tmp->mData.getPassword() == password))
{
clearScreen();
cout << "You logged in!" << endl;
pause();
bool logout = false;
do {
logout = displayAdminMenu(listOfItems, listOfClubs, listOfUsers);
} while (!logout);
return;
}
tmp = tmp->mNext;
}
cout << "This is not a valid login." << endl;
login(listOfItems, listOfClubs, listOfUsers);
//if (checkWords(username, password, listOfItems, listOfClubs, listOfUsers) == true)
//{
// clearScreen();
// cout << "You logged in!" << endl;
// displayAdminMenu(listOfItems, listOfClubs, listOfUsers);
// system("pause");
//}
//else
//{
// cout << "This is not a valid login." << endl;
// login(listOfItems, listOfClubs, listOfUsers);
// return;
//}
}
示例9: eic_pause
val_t eic_pause(void)
{
val_t v;
v.ival = pause();
return v;
}
示例10: Pause
void Pause()
{
(void)pause();
return;
}
示例11: while
void game::handelevents()
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
running=false;
return;
case SDL_KEYDOWN:
switch(event.key.keysym.sym)
{
case SDLK_LEFT :
direction[0]=1;
player1->setMoving(1);
//player1->setJump(0);
break;
case SDLK_RIGHT:
direction[1]=1;
player1->setMoving(1);
// player1->setJump(0);
break;
case SDLK_SPACE:
player1->setJump();
player1->setMoving(0);
break;
case SDLK_c:
if(player1->getDirection()=='r' && player1->getpower()==1)
{
bullets.push_back(new bullet(bull,player1->getRect()->x+player1->getRect()->w-8,player1->getRect()->y-5,5,0,10));
break;
}
if(player1->getDirection()=='l' && player1->getpower()==1)
{
bullets.push_back(new bullet(bull,player1->getRect()->x-player1->getRect()->w+10,player1->getRect()->y-5,-5,0,10));
break;
case SDLK_ESCAPE :
int h=pause(screen);
if (h==1)
running=false;
break;
}
}
break;
case SDL_KEYUP:
switch(event.key.keysym.sym)
{
case SDLK_LEFT :
direction[0]=0;
player1->setMoving(0);
break;
case SDLK_RIGHT:
direction[1]=0;
player1->setMoving(0);
break;
}
break;
}
}
}
示例12: main
//.........这里部分代码省略.........
if (thr_create(NULL, NULL, (void *(*)(void*))getldap_refresh,
0, 0, NULL) != 0) {
logit("thr_create() call failed\n");
syslog(LOG_ERR,
gettext("ldap_cachemgr: thr_create() call failed"));
perror("thr_create");
exit(1);
}
/*
* kick off the thread which refreshes the server info
*/
if (thr_create(NULL, NULL, (void *(*)(void*))getldap_serverInfo_refresh,
0, 0, NULL) != 0) {
logit("thr_create() call failed\n");
syslog(LOG_ERR,
gettext("ldap_cachemgr: thr_create() call failed"));
perror("thr_create");
exit(1);
}
#ifdef SLP
if (use_slp) {
/* kick off SLP discovery thread */
if (thr_create(NULL, NULL, (void *(*)(void *))discover,
(void *)&refresh, 0, NULL) != 0) {
logit("thr_create() call failed\n");
syslog(LOG_ERR, gettext("ldap_cachemgr: thr_create() "
"call failed"));
perror("thr_create");
exit(1);
}
}
#endif /* SLP */
if (thr_sigsetmask(SIG_UNBLOCK, &myset, NULL) < 0) {
logit("thr_sigsetmask() call failed\n");
syslog(LOG_ERR,
gettext("ldap_cachemgr: the_sigsetmask() call failed"));
perror("thr_sigsetmask");
exit(1);
}
/*CONSTCOND*/
while (1) {
(void) pause();
}
/* NOTREACHED */
/*LINTED E_FUNC_HAS_NO_RETURN_STMT*/
}
/*
* Before calling the alloca() function we have to be sure that we won't get
* beyond the stack. Since we don't know the precise layout of the stack,
* the address of an automatic of the function gives us a rough idea, plus/minus
* a bit. We also need a bit more of stackspace after the call to be able
* to call further functions. Even something as simple as making a system call
* from within this function can take ~100 Bytes of stackspace.
*/
#define SAFETY_BUFFER 32 * 1024 /* 32KB */
static
size_t
get_data_size(LineBuf *config_info, int *err_code)
{
size_t configSize = sizeof (ldap_return_t);
dataunion *buf = NULL; /* For the 'sizeof' purpose */
if (config_info->str != NULL &&
config_info->len >= sizeof (buf->data.ldap_ret.ldap_u.config)) {
configSize = sizeof (buf->space) +
config_info->len -
sizeof (buf->data.ldap_ret.ldap_u.config);
if (!stack_inbounds((char *)&buf -
(configSize + SAFETY_BUFFER))) {
/*
* We do not have enough space on the stack
* to accomodate the whole DUAProfile
*/
logit("The DUAProfile is too big. There is not enough "
"space to process it. Ignoring it.\n");
syslog(LOG_ERR, gettext("ldap_cachemgr: The DUAProfile "
"is too big. There is not enough space "
"to process it. Ignoring it."));
*err_code = SERVERERROR;
free(config_info->str);
config_info->str = NULL;
config_info->len = 0;
configSize = sizeof (ldap_return_t);
}
}
return (configSize);
}
示例13: QWidget
Player::Player(QWidget *parent)
: QWidget(parent)
, videoWidget(0)
, coverLabel(0)
, slider(0)
#ifndef PLAYER_NO_COLOROPTIONS
, colorDialog(0)
#endif
{
//! [create-objs]
player = new QMediaPlayer(this);
// owned by PlaylistModel
playlist = new QMediaPlaylist();
player->setPlaylist(playlist);
//! [create-objs]
connect(player, SIGNAL(durationChanged(qint64)), SLOT(durationChanged(qint64)));
connect(player, SIGNAL(positionChanged(qint64)), SLOT(positionChanged(qint64)));
connect(player, SIGNAL(metaDataChanged()), SLOT(metaDataChanged()));
connect(playlist, SIGNAL(currentIndexChanged(int)), SLOT(playlistPositionChanged(int)));
connect(player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
this, SLOT(statusChanged(QMediaPlayer::MediaStatus)));
connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(bufferingProgress(int)));
connect(player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(videoAvailableChanged(bool)));
connect(player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(displayErrorMessage()));
//! [2]
videoWidget = new VideoWidget(this);
player->setVideoOutput(videoWidget);
playlistModel = new PlaylistModel(this);
playlistModel->setPlaylist(playlist);
//! [2]
playlistView = new QListView(this);
playlistView->setModel(playlistModel);
playlistView->setCurrentIndex(playlistModel->index(playlist->currentIndex(), 0));
connect(playlistView, SIGNAL(activated(QModelIndex)), this, SLOT(jump(QModelIndex)));
slider = new QSlider(Qt::Horizontal, this);
slider->setRange(0, player->duration() / 1000);
labelDuration = new QLabel(this);
connect(slider, SIGNAL(sliderMoved(int)), this, SLOT(seek(int)));
QPushButton *openButton = new QPushButton(tr("Open"), this);
connect(openButton, SIGNAL(clicked()), this, SLOT(open()));
PlayerControls *controls = new PlayerControls(this, player);
controls->setState(player->state());
controls->setVolume(player->volume());
controls->setMuted(controls->isMuted());
connect(controls, SIGNAL(play()), player, SLOT(play()));
connect(controls, SIGNAL(pause()), player, SLOT(pause()));
connect(controls, SIGNAL(stop()), player, SLOT(stop()));
connect(controls, SIGNAL(next()), playlist, SLOT(next()));
connect(controls, SIGNAL(previous()), this, SLOT(previousClicked()));
connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int)));
connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool)));
connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal)));
connect(controls, SIGNAL(stop()), videoWidget, SLOT(update()));
connect(player, SIGNAL(stateChanged(QMediaPlayer::State)),
controls, SLOT(setState(QMediaPlayer::State)));
connect(player, SIGNAL(volumeChanged(int)), controls, SLOT(setVolume(int)));
connect(player, SIGNAL(mutedChanged(bool)), controls, SLOT(setMuted(bool)));
fullScreenButton = new QPushButton(tr("FullScreen"), this);
fullScreenButton->setCheckable(true);
#ifndef PLAYER_NO_COLOROPTIONS
colorButton = new QPushButton(tr("Color Options..."), this);
colorButton->setEnabled(false);
connect(colorButton, SIGNAL(clicked()), this, SLOT(showColorDialog()));
#endif
QBoxLayout *displayLayout = new QHBoxLayout;
displayLayout->addWidget(videoWidget, 2);
displayLayout->addWidget(playlistView);
QBoxLayout *controlLayout = new QHBoxLayout;
controlLayout->setMargin(0);
controlLayout->addWidget(openButton);
controlLayout->addStretch(1);
controlLayout->addWidget(controls);
controlLayout->addStretch(1);
controlLayout->addWidget(fullScreenButton);
#ifndef PLAYER_NO_COLOROPTIONS
controlLayout->addWidget(colorButton);
#endif
QBoxLayout *layout = new QVBoxLayout;
layout->addLayout(displayLayout);
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addWidget(slider);
//.........这里部分代码省略.........
示例14: main
int
main(int ac, char **av)
{
int lc; /* loop counter */
const char *msg; /* message returned from parse_opts */
pid_t pid, fake_pid;
int exno, status, fake_status, nsig;
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
}
setup(); /* global setup */
TEST_EXP_ENOS(exp_enos);
/* The following loop checks looping state if -i option given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
/* reset Tst_count in case we are looping */
Tst_count = 0;
status = 1;
exno = 1;
pid = fork();
if (pid < 0) {
tst_brkm(TBROK, cleanup, "Fork failed");
} else if (pid == 0) {
pause();
/*NOTREACHED*/
exit(exno);
} else {
fake_pid = fork();
if (fake_pid < 0) {
tst_brkm(TBROK, cleanup, "Second fork failed");
} else if (fake_pid == 0) {
pause();
/*NOTREACHED*/
exit(exno);
}
kill(fake_pid, TEST_SIG);
waitpid(fake_pid, &fake_status, 0);
TEST(kill(fake_pid, TEST_SIG));
kill(pid, TEST_SIG);
waitpid(pid, &status, 0);
}
if (TEST_RETURN != -1) {
tst_brkm(TFAIL, cleanup, "%s failed - errno = %d : %s "
"Expected a return value of -1 got %d",
TCID, TEST_ERRNO, strerror(TEST_ERRNO)),
TEST_RETURN;
/*NOTREACHED*/
}
if (STD_FUNCTIONAL_TEST) {
/*
* Check to see if the errno was set to the expected
* value of 3 : ESRCH
*/
nsig = WTERMSIG(status);
TEST_ERROR_LOG(TEST_ERRNO);
if (TEST_ERRNO == ESRCH) {
tst_resm(TPASS, "errno set to %d : %s, as "
"expected", TEST_ERRNO,
strerror(TEST_ERRNO));
} else {
tst_resm(TFAIL, "errno set to %d : %s expected "
"%d : %s", TEST_ERRNO,
strerror(TEST_ERRNO), 3, strerror(3));
}
}
}
cleanup();
/*NOTREACHED*/
}
示例15: pause
void Controller::addFilter(std::string fltName, std::vector<std::string> args) {
Filter *flt;
std::string name;
bool resume = false;
if((flt = pipeline->addFilter2(fltName.c_str()))) {
if((resume = player.isRunning())) {
pause();
}
try {
if (fltName == "grayscale")
{
name = "Grayscale";
}
else if (fltName == "sepia")
{
name = "Sepia";
}
else if (fltName == "colorinvert")
{
name = "Color inversion";
}
else if (fltName == "transform")
{
name = "Transformation";
//set arguments
std::string::size_type sz;
TransformFilter *filter = dynamic_cast<TransformFilter*>(flt);
float m[args.size()];
for(int i = 0; i < args.size(); i++) {
if(!args[i].empty())
m[i] = stof(args[i], &sz);
else m[i] = 0;
}
filter->setMatrix(m);
#ifdef DEBUG
for(int i = 0; i < args.size(); i++) {
std::cout << m[i] << std::endl;
}
#endif
}
else if (fltName == "conv2d")
{
name = "Convolution 2D";
//set arguments
//stored row by row
std::string::size_type sz;
Conv2DFilter *filter = dynamic_cast<Conv2DFilter*>(flt);
float kernel[args.size()];
//try {
for(int i = 0; i < args.size(); i++) {
if(!args[i].empty())
kernel[i] = stof(args[i], &sz);
else kernel[i] = 0;
}
// } catch (const std::invalid_argument& ia) {
// Controller::ctrlInst()->writeMsg(ia.w);
// }
for(int i = 0; i < args.size(); i++) {
std::cout << kernel[i] << std::endl;
}
filter->setFilterKernel(kernel, sqrt(args.size()));
}
else if (fltName == "separableconv2d")
{
name = "Separable Convolution 2D";
//set arguments
std::string::size_type sz;
SeparableConv2DFilter *filter = dynamic_cast<SeparableConv2DFilter*>(flt);
int size = args.size() / 2;
float horizKernel[size];
float verticKernel[size];
for(int i = 0; i < size; i++) {
if(!args[i].empty()) {
horizKernel[i] = stof(args[i], &sz);
verticKernel[i] = stof(args[i + size], &sz);
} else {
horizKernel[i] = 0;
verticKernel[i] = 0;
}
}
#ifdef DEBUG
for(int i = 0; i < size; i++) {
std::cout << horizKernel[i] << ":vert=" << verticKernel[i] << std::endl;
}
#endif
filter->setHorizontalFilterKernel(horizKernel, size);
filter->setVerticalFilterKernel(verticKernel, size);
}
else if (fltName == "sobel")
{
name = "Sobel Operator";
}
else if (fltName == "emboss")
//.........这里部分代码省略.........