本文整理汇总了C++中Pause函数的典型用法代码示例。如果您正苦于以下问题:C++ Pause函数的具体用法?C++ Pause怎么用?C++ Pause使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Pause函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ViewFile
/*
* View a file in the current area, menu 103.
* If a file name is given, display direct,
* else ask for filename to view.
*/
void ViewFile(char *name)
{
char *File, *temp, *arc;
int count, total, rc, found = FALSE;
FILE *fp;
struct _fdbarea *fdb_area = NULL;
Syslog('+', "ViewFile(%s)", printable(name, 0));
if (Access(exitinfo.Security, area.LTSec) == FALSE) {
Enter(1);
/* You don't have enough security to list this area */
pout(YELLOW, BLACK, (char *) Language(236));
Enter(2);
Pause();
return;
}
File = calloc(PATH_MAX, sizeof(char));
if ((name != NULL) && strlen(name)) {
strcpy(File, name);
} else {
Enter(2);
/* Please enter filename: */
pout(YELLOW, BLACK, (char *) Language(245));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(File, 80);
if ((strcmp(File, "")) == 0) {
free(File);
return;
}
if (*(File) == '.' || *(File) == '*' || *(File) == ' ' || *(File) == '/') {
Enter(1);
/* Illegal Filename! */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
free(File);
return;
}
Strlen = strlen(File);
Strlen--;
if (*(File + Strlen) == '.' || *(File + Strlen) == '/' || *(File + Strlen) == ' ') {
Enter(1);
/* Illegal Filename! */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
free(File);
return;
}
if ((!strcmp(File, "files.bbs")) || (!strcmp(File, "00index")) || (strstr(File, (char *)".html"))) {
Enter(1);
/* Illegal Filename! */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(247));
Enter(2);
Pause();
free(File);
return;
}
}
/*
* Now check if this file is present
*/
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL) {
free(File);
return;
}
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
if (((strcasecmp(File, fdb.Name) == 0) || (strcasecmp(File, fdb.LName) == 0)) && (!fdb.Deleted)) {
found = TRUE;
break;
}
}
mbsedb_CloseFDB(fdb_area);
if (!found) {
Enter(1);
/* File does not exist, please try again ... */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(296));
Enter(2);
free(File);
Pause();
return;
}
snprintf(File, PATH_MAX, "%s/%s", sAreaPath, fdb.LName);
//.........这里部分代码省略.........
示例2: GetWindowInfo
void CRenderDevice::End (void)
{
#ifndef DEDICATED_SERVER
// Moved to m_pRenderEnd()
//VERIFY (HW.pDevice);
//if (HW.Caps.SceneMode) overdrawEnd ();
//
#ifdef INGAME_EDITOR
bool load_finished = false;
#endif // #ifdef INGAME_EDITOR
if (dwPrecacheFrame)
{
::Sound->set_master_volume (0.f);
dwPrecacheFrame --;
pApp->load_draw_internal ();
if (0==dwPrecacheFrame)
{
#ifdef INGAME_EDITOR
load_finished = true;
#endif // #ifdef INGAME_EDITOR
//Gamma.Update ();
m_pRender->updateGamma();
if(precache_light) precache_light->set_active (false);
if(precache_light) precache_light.destroy ();
::Sound->set_master_volume (1.f);
pApp->destroy_loading_shaders ();
m_pRender->ResourcesDestroyNecessaryTextures ();
Memory.mem_compact ();
Msg ("* MEMORY USAGE: %d K",Memory.mem_usage()/1024);
Msg ("* End of synchronization A[%d] R[%d]",b_is_Active, b_is_Ready);
#ifdef FIND_CHUNK_BENCHMARK_ENABLE
g_find_chunk_counter.flush();
#endif // FIND_CHUNK_BENCHMARK_ENABLE
CheckPrivilegySlowdown ();
if(g_pGamePersistent->GameType()==1)//haCk
{
WINDOWINFO wi;
GetWindowInfo(m_hWnd,&wi);
if(wi.dwWindowStatus!=WS_ACTIVECAPTION)
Pause(TRUE,TRUE,TRUE,"application start");
}
}
}
g_bRendering = FALSE;
// end scene
// Present goes here, so call OA Frame end.
if (g_SASH.IsBenchmarkRunning())
g_SASH.DisplayFrame(Device.fTimeGlobal);
m_pRender->End();
//RCache.OnFrameEnd ();
//Memory.dbg_check ();
//CHK_DX (HW.pDevice->EndScene());
//HRESULT _hr = HW.pDevice->Present( NULL, NULL, NULL, NULL );
//if (D3DERR_DEVICELOST==_hr) return; // we will handle this later
//R_ASSERT2 (SUCCEEDED(_hr), "Presentation failed. Driver upgrade needed?");
# ifdef INGAME_EDITOR
if (load_finished && m_editor)
m_editor->on_load_finished ();
# endif // #ifdef INGAME_EDITOR
#endif
}
示例3: StreamPause
static HRESULT StreamPause( aout_stream_t *s, bool pause )
{
return Pause( s->sys, pause );
}
示例4: PlayLaserGame
//.........这里部分代码省略.........
/* Draw cities: */
if (frame%2 == 0) NEXT_FRAME(shield);
for (i = 0; i < NUM_CITIES; i++) {
/* Decide which image to display: */
if (cities[i].alive) {
if (cities[i].expl == 0)
img = IMG_CITY_BLUE;
else
img = (IMG_CITY_BLUE_EXPL5 - (cities[i].expl / (CITY_EXPL_START / 5)));
} else
img = IMG_CITY_BLUE_DEAD;
/* Change image to appropriate color: */
img += ((wave % MAX_CITY_COLORS) * (IMG_CITY_GREEN - IMG_CITY_BLUE));
/* Draw it! */
dest.x = cities[i].x - (images[img]->w / 2);
dest.y = (screen->h) - (images[img]->h);
dest.w = (images[img]->w);
dest.h = (images[img]->h);
SDL_BlitSurface(images[img], NULL, screen, &dest);
/* Draw sheilds: */
if (cities[i].shields) {
dest.x = cities[i].x - (shield->frame[shield->cur]->w / 2);
dest.h = (screen->h) - (shield->frame[shield->cur]->h);
dest.w = src.w;
dest.h = src.h;
SDL_BlitSurface( shield->frame[shield->cur], NULL, screen, &dest);
}
}
/* Draw laser: */
if (laser.alive)
laser_draw_line(laser.x1, laser.y1, laser.x2, laser.y2, 255 / (LASER_START - laser.alive),
192 / (LASER_START - laser.alive), 64);
laser_draw_console_image(IMG_CONSOLE);
if (gameover > 0)
tux_img = IMG_TUX_FIST1 + ((frame / 2) % 2);
laser_draw_console_image(tux_img);
/* Draw "Game Over" */
if (gameover > 0) {
dest.x = (screen->w - images[IMG_GAMEOVER]->w) / 2;
dest.y = (screen->h - images[IMG_GAMEOVER]->h) / 2;
dest.w = images[IMG_GAMEOVER]->w;
dest.h = images[IMG_GAMEOVER]->h;
SDL_BlitSurface(images[IMG_GAMEOVER], NULL, screen, &dest);
}
/* Swap buffers: */
SDL_Flip(screen);
/* If we're in "PAUSE" mode, pause! */
if (paused) {
quit = Pause();
paused = 0;
}
/* Keep playing music: */
if (settings.sys_sound && !Mix_PlayingMusic())
MusicPlay(musics[MUS_GAME + (rand() % NUM_MUSICS)], 0);
/* Pause (keep frame-rate event) */
DEBUGCODE
{
fprintf(stderr, "now_time = %d\tlast_time = %d, elapsed time = %d\n",
now_time, last_time, now_time - last_time);
}
now_time = SDL_GetTicks();
if (now_time < last_time + FPS)
SDL_Delay(last_time + FPS - now_time);
}
示例5: Pause
void
AnimationPlayer::PauseFromJS()
{
Pause(eUpdateStyle);
}
示例6: TEST_F
TEST_F(BoundedQueueTest, EnqueuePauseProducerWhenQueueIsFull){
EXPECT_CALL(producer, Pause());
q.enqueue(4);
q.enqueue(4);
q.enqueue(4);
}
示例7: File_List
/*
* Show filelist from current area, called from the menu.
*/
void File_List()
{
int FileCount = 0;
unsigned FileBytes = 0;
_Tag T;
struct _fdbarea *fdb_area = NULL;
char temp[81];
iLineCount = 0;
WhosDoingWhat(FILELIST, NULL);
Syslog('+', "Listing File Area # %d", iAreaNumber);
if (Access(exitinfo.Security, area.LTSec) == FALSE) {
Enter(1);
/* You don't have enough security to list this area */
pout(YELLOW, BLACK, (char *) Language(236));
Enter(2);
Pause();
return;
}
InitTag();
if ((fdb_area = mbsedb_OpenFDB(iAreaNumber, 30)) == NULL)
return;
if (utf8)
chartran_init((char *)"CP437", (char *)"UTF-8", 'b');
clear();
Header();
if (iLC(2) == 1) {
mbsedb_CloseFDB(fdb_area);
chartran_close();
return;
}
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
memset(&T, 0, sizeof(T));
T.Area = iAreaNumber;
T.Active = FALSE;
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, chartran(fdb.LName), 80);
SetTag(T);
if (ShowOneFile() == 1) {
mbsedb_CloseFDB(fdb_area);
chartran_close();
return;
}
if (fdb.Deleted) {
/* D E L E T E D */ /* Uploaded by: */
snprintf(temp, 81, " -- %-12s %s [%4d] %s%s\n", fdb.Name, (char *) Language(239),
fdb.TimesDL, (char *) Language(238), fdb.Uploader);
PUTSTR(temp);
}
FileCount++; /* Increase File Counter by 1 */
FileBytes += fdb.Size; /* Increase File Byte Count */
}
Mark();
Enter(1);
/* Total Files: */
snprintf(temp, 81, "%s%d / %d bytes", (char *) Language(242), FileCount, FileBytes);
pout(LIGHTCYAN, BLACK, temp);
Enter(2);
chartran_close();
iLineCount = 0;
mbsedb_CloseFDB(fdb_area);
Pause();
}
示例8: NewfileScan
//.........这里部分代码省略.........
Date[5] = temp[4]; /* because when you convert */
Date[6] = temp[0]; /* a string to an int you */
Date[7] = temp[1]; /* loose the front Zero */
Date[8] = '\0'; /* making the number smaller */
itDate = atol(Date);
InitTag();
if ((pAreas = OpenFareas(FALSE)) == NULL)
return 0;
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0) && (area.New)) {
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
Sheader();
Found = FALSE;
Nopper();
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
strcpy(temp, StrDateDMY(fdb.UploadDate)); /* Realloc Space for Date */
Date[0] = temp[6]; /* Swap the date around */
Date[1] = temp[7]; /* Instead of DD-MM-YYYY */
Date[2] = temp[8]; /* Let it equal YYYYMMDD */
Date[3] = temp[9]; /* Swap the date around */
Date[4] = temp[3]; /* Swap the date around */
Date[5] = temp[4]; /* because when you convert */
Date[6] = temp[0]; /* a string to an int you */
Date[7] = temp[1]; /* loose the front Zero */
Date[8] = '\0'; /* making the number smaller */
/* and invalid to this cause */
ifDate = atol(Date);
if (ifDate >= itDate) {
if (!Found) {
Enter(2);
if (iLC(2) == 1) {
free(Date);
free(temp);
mbsedb_CloseFDB(fdb_area);
fclose(pAreas);
return 1;
}
Found = TRUE;
}
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
free(Date);
free(temp);
mbsedb_CloseFDB(fdb_area);
fclose(pAreas);
return 1;
}
} /* End of if */
} /* End of while */
mbsedb_CloseFDB(fdb_area);
/*
* Add 2 blank lines after found files.
*/
if (Found) {
Enter(2);
if (iLC(2) == 1) {
free(Date);
free(temp);
fclose(pAreas);
return 1;
}
}
} /* End of open filebase */
} /* End of check new files scan */
arecno++; /* Go to next file area */
} /* End of Main */
if (Count)
Syslog('+', "Found %d new files", Count);
fclose(pAreas);
Enter(1);
if (Count)
Mark();
else
Pause();
free(temp);
free(Date);
return 1;
}
示例9: Upload
/*
* Upload a file.
*/
int Upload()
{
int Area, rc;
unsigned int OldArea;
char *arc, *temp;
up_list *up = NULL, *tmpf;
WhosDoingWhat(UPLOAD, NULL);
Enter(1);
Area = OldArea = iAreaNumber;
/*
* If there is a special upload area for the current area
* then select it.
*/
if (area.Upload)
Area = area.Upload;
SetFileArea(Area);
Syslog('+', "Upload area is %d %s", Area, area.Name);
/*
* Check upload access for the real upload directory.
*/
if (!Access(exitinfo.Security, area.UPSec)) {
Enter(1);
/* You do not have enough access to upload to this area */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(278));
Enter(2);
SetFileArea(OldArea);
Pause();
return 0;
}
clear();
Enter(2);
rc = upload(&up);
if (rc) {
Syslog('+', "Upload failed, rc=%d", rc);
SetFileArea(OldArea);
return 0;
}
Syslog('b', "upload done, start checks");
Enter(2);
pout(CFG.UnderlineColourF, CFG.UnderlineColourB, (char *)"Checking your upload(s)");
Enter(1);
temp = calloc(PATH_MAX, sizeof(char));
for (tmpf = up; tmpf; tmpf = tmpf->next) {
snprintf(temp, PATH_MAX, "%s/%s/upl", CFG.bbs_usersdir, exitinfo.Name);
chdir(temp);
Syslog('b', "Checking upload %s", tmpf->filename);
if ((arc = GetFileType(tmpf->filename)) == NULL) {
/*
* If the filetype is unknown, it is probably
* a textfile or so. Import it direct.
*/
Syslog('b', "Unknown file type");
if (!ScanDirect(basename(tmpf->filename)))
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
} else {
/*
* We figured out the type of the uploaded file.
*/
Syslog('b', "File type is %s", arc);
/*
* MS-DOS executables are handled direct.
*/
if ((strcmp("EXE", arc) == 0) || (strcmp("COM", arc) == 0)) {
if (!ScanDirect(basename(tmpf->filename)))
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
} else {
switch (ScanArchive(basename(tmpf->filename), arc)) {
case 0: ImportFile(tmpf->filename, Area, TRUE, tmpf->size);
break;
case 1: break;
case 2: break;
case 3: /*
* No valid unarchiver found, just import after scanning,
* may catch macro viri.
*/
if (!ScanDirect(basename(tmpf->filename)))
ImportFile(tmpf->filename, Area, FALSE, tmpf->size);
break;
}
}
}
}
tidy_upload(&up);
free(temp);
Home();
SetFileArea(OldArea);
//.........这里部分代码省略.........
示例10: FilenameScan
//.........这里部分代码省略.........
_Tag T;
unsigned int OldArea;
struct _fdbarea *fdb_area = NULL;
Name = calloc(81, sizeof(char));
OldArea = iAreaNumber;
iLineCount = 2; /* Reset Line Counter to Zero */
arecno = 1; /* Reset Area Number to One */
Enter(2);
/* Accepts wildcards such as : *.zip, *.gz, *.* */
pout(WHITE, BLACK, (char *) Language(269));
Enter(2);
/* Enter filename to search for : */
pout(LIGHTCYAN, BLACK, (char *) Language(271));
colour(CFG.InputColourF, CFG.InputColourB);
GetstrC(Name, 80);
if ((strcmp(Name, "")) == 0) {
free(Name);
return 0;
}
strcpy(mask, re_mask(Name, TRUE));
Syslog('+', "FilenameScan(): \"%s\" -> \"%s\"", Name, mask);
free(Name);
re_comp(mask);
clear();
/* File Search by Filename */
pout(WHITE, BLACK, (char *) Language(272));
Enter(1);
InitTag();
if ((pAreas = OpenFareas(FALSE)) == NULL)
return 0;
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
Found = FALSE;
Sheader();
Nopper();
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
if (re_exec(fdb.Name) || re_exec(fdb.LName)) {
if (!Found) {
Enter(2);
if (iLC(2) == 1) {
SetFileArea(OldArea);
return 1;
}
Found = TRUE;
}
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 81);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
SetFileArea(OldArea);
return 1;
}
}
} /* End of while */
mbsedb_CloseFDB(fdb_area);
if (Found) {
Enter(2);
if (iLC(2) == 1) {
SetFileArea(OldArea);
return 1;
}
}
} /* End Check for LTSec */
} /* if access */
arecno++; /* Go to next file area */
} /* End of Main */
Syslog('+', "Found %d files", Count);
fclose(pAreas);
Enter(1);
if (Count)
Mark();
else
Pause();
SetFileArea(OldArea);
return 1;
}
示例11: KeywordScan
//.........这里部分代码省略.........
if ((strcmp(Name, "")) == 0)
return 0;
strcpy(tmpname, tl(Name));
strcpy(Name, "");
y = strlen(tmpname);
for (z = 0; z < y; z++) {
if (tmpname[z] != '*') {
snprintf(temp, 81, "%c", tmpname[z]);
strcat(Name, temp);
}
}
Syslog('+', "KeywordScan(): \"%s\"", Name);
clear();
/* File search by keyword */
pout(WHITE, BLACK, (char *) Language(268));
Enter(1);
InitTag();
if ((pAreas = OpenFareas(FALSE)) == NULL)
return 0;
while (fread(&area, areahdr.recsize, 1, pAreas) == 1) {
if ((Access(exitinfo.Security, area.LTSec)) && (area.Available) && (strlen(area.Password) == 0)) {
if ((fdb_area = mbsedb_OpenFDB(arecno, 30))) {
Nopper();
Found = FALSE;
Sheader();
while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
for (i = 0; i < 25; i++)
snprintf(BigDesc, 1230, "%s%s", BigDesc, *(fdb.Desc + i));
if ((strstr(fdb.Name,Name) != NULL) || (strstr(tl(BigDesc), Name) != NULL)) {
if (!Found) {
Enter(2);
if (iLC(2) == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
Found = TRUE;
}
memset(&T, 0, sizeof(T));
T.Area = arecno;
T.Active = FALSE;
T.Size = fdb.Size;
strncpy(T.SFile, fdb.Name, 12);
strncpy(T.LFile, fdb.LName, 80);
SetTag(T);
Count++;
if (ShowOneFile() == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
strcpy(BigDesc, ""); /* Clear BigDesc */
} /* while */
mbsedb_CloseFDB(fdb_area);
if (Found) {
Enter(2);
if (iLC(2) == 1) {
free(BigDesc);
free(Name);
free(tmpname);
SetFileArea(OldArea);
return 1;
}
}
} /* End check for LTSec */
} /* if access */
arecno++; /* Go to next file area */
} /* End of Main */
Syslog('+', "Found %d files", Count);
free(BigDesc);
free(Name);
free(tmpname);
fclose(pAreas);
Enter(1);
if (Count)
Mark();
else
Pause();
SetFileArea(OldArea);
return 1;
}
示例12: File_RawDir
/*
* Show Raw directory
*/
void File_RawDir(char *OpData)
{
DIR *dirp;
char *FileName, *temp, temp2[81];
int iFileCount = 0, LineCount = 2, iBytes = 0;
struct dirent *dp;
struct stat statfile;
FileName = calloc(PATH_MAX, sizeof(char));
temp = calloc(PATH_MAX, sizeof(char));
if ((strcmp(OpData, "/F")) == 0)
strcpy(temp, sAreaPath);
else
strcpy(temp, OpData);
if ((dirp = opendir(temp)) == NULL) {
clear();
WriteError("$RawDir: Can't open dir: %s", temp);
Enter(1);
pout(LIGHTRED, BLACK, (char *)"Can't open directory for raw listing!");
Enter(2);
Pause();
} else {
if (utf8)
chartran_init((char *)"CP437", (char *)"UTF-8", 'b');
clear();
/* Filename Size Date */
pout(CFG.HiliteF, CFG.HiliteB, (char *) Language(261));
Enter(1);
PUTSTR(chartran(fLine_str(78)));
while ((dp = readdir( dirp )) != NULL ) {
snprintf(FileName, PATH_MAX, "%s/%s", temp, dp->d_name);
if (*(dp->d_name) != '.') {
iFileCount++;
if (stat(FileName, &statfile) != 0) {
pout(LIGHTRED, BLACK, (char *)"Can't stat file ");
PUTSTR(FileName);
} else {
iBytes += statfile.st_size;
snprintf(temp2, 81, "%-54s " , dp->d_name);
pout(YELLOW, BLACK, temp2);
snprintf(temp2, 81, "%-12d", (int)(statfile.st_size));
pout(LIGHTMAGENTA, BLACK, temp2);
snprintf(temp2, 81, "%-10s", StrDateDMY(statfile.st_mtime));
pout(LIGHTGREEN, BLACK, temp2);
}
Enter(1);
LineCount++;
if (LineCount == rows) {
Pause();
LineCount = 0;
}
}
}
colour(CFG.HiliteF, CFG.HiliteB);
PUTSTR(chartran(fLine_str(78)));
/* Total Files: */ /* Bytes */
snprintf(temp2, 81, "%s %d, %d %s", (char *) Language(242), iFileCount, iBytes, (char *) Language(354));
pout(LIGHTGREEN, BLACK, temp2);
Enter(2);
Pause();
closedir(dirp);
chartran_close();
}
free(temp);
free(FileName);
}
示例13: WndProc
/**
* The window procedure which handles the application events.
*/
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_SETFOCUS:
{
GetCursorPos(&gLastMousePos);
gFocused = true;
break;
}
case WM_KILLFOCUS:
{
gFocused = false;
break;
}
// An explicit paint message
case WM_PAINT:
{
if (!gReinitializeRequired)
{
// This is only really called when something is dragged over top of the window
RenderScene();
}
ValidateRect(hWnd, nullptr);
break;
}
// Handle window size changes and pause streaming when minimized since the back buffer might not be available
case WM_SIZE:
{
// Update the pause state
int wmEvent = LOWORD(wParam);
if (wmEvent == SIZE_MINIMIZED)
{
gPaused = true;
Pause();
}
else if (wmEvent == SIZE_RESTORED)
{
gPaused = false;
}
break;
}
case WM_CHAR:
{
if ( AcceptingChatInput() )
{
unsigned char ch = static_cast<unsigned char>(wParam);
// backspace or visible character
if ( ch == 8 || (ch >= 32 && ch < 127) )
{
AppendChatInput(ch);
}
}
break;
}
// Handle key presses
case WM_KEYDOWN:
{
if ( AcceptingChatInput() )
{
switch (wParam)
{
case VK_RETURN:
{
EndChatInput(true);
break;
}
case VK_ESCAPE:
{
EndChatInput(false);
break;
}
}
}
else
{
switch (wParam)
{
// begin chat input
case VK_RETURN:
{
BeginChatInput();
break;
}
// Toggle streaming
case VK_F5:
{
if (IsStreaming())
{
gStreamingDesired = false;
StopStreaming();
}
else
{
//.........这里部分代码省略.........
示例14: while
//.........这里部分代码省略.........
break;
}
case MSG_DAMAGE_STEP_START: {
DuelClient::ClientAnalyze(offset, pbuf - offset);
ReplayRefresh();
pauseable = false;
break;
}
case MSG_DAMAGE_STEP_END: {
DuelClient::ClientAnalyze(offset, pbuf - offset);
ReplayRefresh();
pauseable = false;
break;
}
case MSG_MISSED_EFFECT: {
pbuf += 8;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_TOSS_COIN: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_TOSS_DICE: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += count;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_ANNOUNCE_RACE: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 5;
return ReadReplayResponse();
}
case MSG_ANNOUNCE_ATTRIB: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 5;
return ReadReplayResponse();
}
case MSG_ANNOUNCE_CARD: {
player = BufferIO::ReadInt8(pbuf);
pbuf += 4;
return ReadReplayResponse();
}
case MSG_ANNOUNCE_NUMBER:
case MSG_ANNOUNCE_CARD_FILTER: {
player = BufferIO::ReadInt8(pbuf);
count = BufferIO::ReadInt8(pbuf);
pbuf += 4 * count;
return ReadReplayResponse();
}
case MSG_CARD_HINT: {
pbuf += 9;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_PLAYER_HINT: {
pbuf += 6;
DuelClient::ClientAnalyze(offset, pbuf - offset);
break;
}
case MSG_MATCH_KILL: {
pbuf += 4;
break;
}
case MSG_TAG_SWAP: {
player = pbuf[0];
pbuf += pbuf[2] * 4 + pbuf[4] * 4 + 9;
DuelClient::ClientAnalyze(offset, pbuf - offset);
ReplayRefreshDeck(player);
ReplayRefreshExtra(player);
break;
}
}
if(pauseable) {
if(skip_step) {
skip_step--;
if(skip_step == 0) {
Pause(true, false);
mainGame->dInfo.isStarted = true;
mainGame->dInfo.isReplaySkiping = false;
mainGame->dField.RefreshAllCards();
mainGame->gMutex.Unlock();
}
}
if(is_pausing) {
is_paused = true;
mainGame->actionSignal.Reset();
mainGame->actionSignal.Wait();
is_paused = false;
}
current_step++;
}
}
return true;
}
示例15: lock
//.........这里部分代码省略.........
pa_stream_set_latency_update_callback(m_Stream, StreamLatencyUpdateCallback, m_MainLoop);
// default buffer construction
// align with AE's max buffer
unsigned int latency = m_BytesPerSecond / 2.5; // 400 ms
unsigned int process_time = latency / 4; // 100 ms
if(sinkStruct.isHWDevice)
{
// on hw devices buffers can be further reduced
// 200ms max latency
// 50ms min packet size
latency = m_BytesPerSecond / 5;
process_time = latency / 4;
}
pa_buffer_attr buffer_attr;
buffer_attr.fragsize = latency;
buffer_attr.maxlength = (uint32_t) -1;
buffer_attr.minreq = process_time;
buffer_attr.prebuf = (uint32_t) -1;
buffer_attr.tlength = latency;
if (pa_stream_connect_playback(m_Stream, isDefaultDevice ? NULL : device.c_str(), &buffer_attr, ((pa_stream_flags)(PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_ADJUST_LATENCY)), NULL, NULL) < 0)
{
CLog::Log(LOGERROR, "PulseAudio: Failed to connect stream to output");
pa_threaded_mainloop_unlock(m_MainLoop);
Deinitialize();
return false;
}
/* Wait until the stream is ready */
do
{
pa_threaded_mainloop_wait(m_MainLoop);
CLog::Log(LOGDEBUG, "PulseAudio: Stream %s", StreamStateToString(pa_stream_get_state(m_Stream)));
}
while (pa_stream_get_state(m_Stream) != PA_STREAM_READY && pa_stream_get_state(m_Stream) != PA_STREAM_FAILED);
if (pa_stream_get_state(m_Stream) == PA_STREAM_FAILED)
{
CLog::Log(LOGERROR, "PulseAudio: Waited for the stream but it failed");
pa_threaded_mainloop_unlock(m_MainLoop);
Deinitialize();
return false;
}
const pa_buffer_attr *a;
if (!(a = pa_stream_get_buffer_attr(m_Stream)))
{
CLog::Log(LOGERROR, "PulseAudio: %s", pa_strerror(pa_context_errno(m_Context)));
pa_threaded_mainloop_unlock(m_MainLoop);
Deinitialize();
return false;
}
else
{
unsigned int packetSize = a->minreq;
m_BufferSize = a->tlength;
m_periodSize = a->minreq;
format.m_frames = packetSize / frameSize;
}
{
CSingleLock lock(m_sec);
// Register Callback for Sink changes
pa_context_set_subscribe_callback(m_Context, SinkChangedCallback, this);
const pa_subscription_mask_t mask = PA_SUBSCRIPTION_MASK_SINK;
pa_operation *op = pa_context_subscribe(m_Context, mask, NULL, this);
if (op != NULL)
pa_operation_unref(op);
// Register Callback for Sink Info changes - this handles volume
pa_context_set_subscribe_callback(m_Context, SinkInputInfoChangedCallback, this);
const pa_subscription_mask_t mask_input = PA_SUBSCRIPTION_MASK_SINK_INPUT;
pa_operation* op_sinfo = pa_context_subscribe(m_Context, mask_input, NULL, this);
if (op_sinfo != NULL)
pa_operation_unref(op_sinfo);
}
pa_threaded_mainloop_unlock(m_MainLoop);
format.m_frameSize = frameSize;
m_format = format;
format.m_dataFormat = m_passthrough ? AE_FMT_S16NE : format.m_dataFormat;
CLog::Log(LOGNOTICE, "PulseAudio: Opened device %s in %s mode with Buffersize %u ms",
device.c_str(), m_passthrough ? "passthrough" : "pcm",
(unsigned int) ((m_BufferSize / (float) m_BytesPerSecond) * 1000));
// Cork stream will resume when adding first package
Pause(true);
{
CSingleLock lock(m_sec);
m_IsAllocated = true;
}
return true;
}