WebPMuxError WebPFrameCacheFlush(WebPFrameCache* const cache, int verbose, WebPMux* const mux) { while (cache->flush_count > 0) { WebPMuxFrameInfo* info; WebPMuxError err; EncodedFrame* const curr = CacheGetFrame(cache, 0); // Pick frame or full canvas. if (cache->keyframe == 0) { info = &curr->key_frame; info->blend_method = WEBP_MUX_NO_BLEND; cache->keyframe = KEYFRAME_NONE; cache->best_delta = DELTA_INFINITY; } else { info = &curr->sub_frame; info->blend_method = WEBP_MUX_BLEND; } // Add to mux. err = WebPMuxPushFrame(mux, info, 1); if (err != WEBP_MUX_OK) return err; if (verbose) { printf("Added frame. offset:%d,%d duration:%d dispose:%d blend:%d\n", info->x_offset, info->y_offset, info->duration, info->dispose_method, info->blend_method); } FrameRelease(curr); ++cache->start; --cache->flush_count; --cache->count; if (cache->keyframe != KEYFRAME_NONE) --cache->keyframe; } if (cache->count == 0) CacheReset(cache); return WEBP_MUX_OK; }
void umountRAMDisk() { if (gRAMDiskMI != NULL) { // Release ramdisk BVRef and DiskBVMap. struct DiskBVMap *oldMap = diskResetBootVolumes(0x100); CacheReset(); diskFreeMap(oldMap); // Free multiboot info and module structures. if ((void *)gRAMDiskMI->mi_mods_addr != NULL) free((void *)gRAMDiskMI->mi_mods_addr); if (gRAMDiskMI != NULL) free(gRAMDiskMI); // Reset multiboot structures. gMI = gRAMDiskMI = NULL; *gRAMDiskFile = '\0'; // Release ramdisk driver hooks. p_get_ramdisk_info = NULL; p_ramdiskReadBytes = NULL; // Reset ramdisk bvr gRAMDiskVolume = NULL; printf("\nunmounting: done"); } }
WebPFrameCache* WebPFrameCacheNew(size_t kmin, size_t kmax) { WebPFrameCache* cache = (WebPFrameCache*)malloc(sizeof(*cache)); if (cache == NULL) return NULL; CacheReset(cache); cache->kmin = kmin; cache->kmax = kmax; cache->count_since_key_frame = 0; assert(kmax > kmin); cache->size = kmax - kmin; cache->encoded_frames = (EncodedFrame*)calloc(cache->size, sizeof(*cache->encoded_frames)); if (cache->encoded_frames == NULL) { free(cache); return NULL; } return cache; }
/*********************************************************************** * main function ***********************************************************************/ UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { UInt16 error = RomVersionCompatible (MINVERSION, launchFlags); if (error) return (error); /*** * NORMAL STARTUP ****/ if ( cmd == sysAppLaunchCmdNormalLaunch ) { error = StartApplication (); if (error) { // PalmOS before 3.5 will continuously relaunch this app unless we switch to // another safe one. if (error != dmErrCorruptDatabase) { FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", ""); } StopApplication(); AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); return error; } FrmGotoForm(FORM_main); AppEventLoop (); StopApplication (); /*** * FIND ****/ /* } else if (cmd == sysAppLaunchCmdSaveData) { FrmSaveAllForms(); } else if (cmd == sysAppLaunchCmdFind) { PalmGlobalFind((FindParamsPtr)cmdPBP); */ /*** * GoTo ****/ /* } else if (cmd == sysAppLaunchCmdGoTo) { Boolean launched = launchFlags & sysAppLaunchFlagNewGlobals; if (launched) { error = StartApplication(); if (! error) { GoToItem((GoToParamsPtr)cmdPBP, launched); AppEventLoop(); StopApplication(); } } else { GoToItem((GoToParamsPtr)cmdPBP, launched); } */ /*** * BEAMING ****/ } else if (cmd == sysAppLaunchCmdSyncNotify) { // Register with the Exchange Manager ExgRegisterData(APP_CREATOR, exgRegExtensionID, "umx"); } else if (cmd == sysAppLaunchCmdExgAskUser) { // Always assume "Yes" as answer to the accept dialog since we display our // own on which the user can cancel the data ExgAskParamType *exgAskParam = (ExgAskParamType *)cmdPBP; exgAskParam->result=exgAskOk; } else if (cmd == sysAppLaunchCmdExgReceiveData) { DmOpenRef cats=NULL, dogs=NULL; // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { // Quit Forms FrmSaveAllForms(); cats = DatabaseGetRefN(DB_MAIN); dogs = DatabaseGetRefN(DB_DATA); error = BeamReceive(cats, dogs, (ExgSocketPtr) cmdPBP); CacheReset(); FrmGotoForm(FORM_main); } else { // Another app was running when we were called cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); dogs = DmOpenDatabaseByTypeCreator(DATABASE_DATA_TYPE, APP_CREATOR, dmModeReadWrite); if (! (cats && dogs)) { FrmAlert(ALERT_beamdbfail); } else { error=BeamReceive(cats, dogs, (ExgSocketPtr)cmdPBP); } if (cats) DmCloseDatabase(cats); if (dogs) DmCloseDatabase(dogs); } /*** * ALARM ****/ } else if (cmd == sysAppLaunchCmdAlarmTriggered) { // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { AlarmTriggered(DatabaseGetRefN(DB_MAIN), (SysAlarmTriggeredParamType *)cmdPBP); } else { DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); AlarmTriggered(cats, (SysAlarmTriggeredParamType *)cmdPBP); DmCloseDatabase(cats); } /*** * ATTENTION ****/ } else if (cmd == sysAppLaunchCmdAttention) { // Is app active? if (launchFlags & sysAppLaunchFlagSubCall) { AttentionBottleNeckProc(DatabaseGetRefN(DB_MAIN), (AttnLaunchCodeArgsType *)cmdPBP); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); AttentionBottleNeckProc(cats, (AttnLaunchCodeArgsType *)cmdPBP); DmCloseDatabase(cats); } /*** * ATTENTION GOTO ****/ } else if (cmd == appLaunchCmdAlarmEventGoto) { error = StartApplication (); if (error) { // PalmOS before 3.5 will continuously relaunch this app unless we switch to // another safe one. if (error != dmErrCorruptDatabase) { FrmCustomAlert(ALERT_debug, "Please reports this bug! Give your Palm device and PalmOS version, this BadBug(TM) should not happen.", "", ""); } StopApplication(); AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL); return error; } ExamSetGoto(*(UInt32 *)cmdPBP); FrmGotoForm(FORM_exams); AppEventLoop (); StopApplication (); /*** * TIME CHANGE ****/ // Launch code sent when the system time is changed. } else if (cmd == sysAppLaunchCmdTimeChange) { // reset the trigger for the next alarm to fire if (launchFlags & sysAppLaunchFlagSubCall) { AlarmReset(DatabaseGetRefN(DB_MAIN)); // Remove any "future" alarms from the attention manager queue // (ie alarms that will trigger after the new time setting) //AlarmUpdatePosted(DeviceTimeChanged); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); if (cats != 0) { AlarmReset(cats); //AlarmUpdatePosted(DeviceTimeChanged); DmCloseDatabase(cats); } } /*** * RESET ****/ // This action code is sent after the system is reset. } else if (cmd == sysAppLaunchCmdSystemReset) { if (! ((SysAppLaunchCmdSystemResetType*)cmdPBP)->hardReset) { if (launchFlags & sysAppLaunchFlagSubCall) { AlarmReset(DatabaseGetRefN(DB_MAIN)); } else { // Another app was running when we were called DmOpenRef cats = DmOpenDatabaseByTypeCreator(DATABASE_TYPE, APP_CREATOR, dmModeReadWrite); if (cats != 0) { AlarmReset(cats); DmCloseDatabase(cats); } } } } return 0; }
Dispatch() { int nready, result; int *clientReady; ClientPtr client; int op; nextFreeClientID = MINCLIENT; nClients = 0; clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients); if (!clientReady) return; while (1) { /* wait for something */ nready = WaitForSomething(clientReady); while (!dispatchException && (--nready >= 0)) { client = currentClient = clients[clientReady[nready]]; /* Client can be NULL if CloseDownClient() is called during this dispatchException loop. */ if (client == (ClientPtr)NULL) continue; isItTimeToYield = FALSE; while (!isItTimeToYield) { result = ReadRequest(client); if (result <= 0) { if (result < 0) CloseDownClient(client); break; } client->sequence++; if (result > (MAX_REQUEST_SIZE << 2)) result = FSBadLength; else { op = MAJOROP; if (op >= NUM_PROC_VECTORS) result = ProcBadRequest (client); else result = (*client->requestVector[op]) (client); } if (result != FSSuccess) { if (client->noClientException != FSSuccess) CloseDownClient(client); break; } } FlushAllOutput (); } /* reset if server is a drone and has run out of clients */ if (drone_server && nClients == 0) { dispatchException |= DE_RESET; } if (dispatchException) { /* re-read the config file */ if (dispatchException & DE_RECONFIG) { NoticeF("Re-reading config file\n"); if (ReadConfigFile(configfilename) != FSSuccess) ErrorF("couldn't parse config file\n"); SetConfigValues(); dispatchException &= ~DE_RECONFIG; } /* flush all the caches */ if (dispatchException & DE_FLUSH) { NoticeF("flushing all caches\n"); CacheReset(); dispatchException &= ~DE_FLUSH; } /* reset */ if (dispatchException & DE_RESET) { NoticeF("resetting\n"); break; } /* die *now* */ if (dispatchException & DE_TERMINATE) { NoticeF("terminating\n"); kill_all_clients(); exit(0); break; } } } kill_all_clients(); dispatchException = 0; }
int main(int argc, char *argv[]) { int i, oldumask; argcGlobal = argc; argvGlobal = argv; configfilename = DEFAULT_CONFIG_FILE; /* init stuff */ ProcessCmdLine(argc, argv); InitErrors(); /* * Do this first thing, to get any options that only take effect at * startup time. It is read again each time the server resets. */ if (ReadConfigFile(configfilename) != FSSuccess) { FatalError("couldn't read config file\n"); } /* make sure at least world write access is disabled */ if (((oldumask = umask(022)) & 002) == 002) (void)umask(oldumask); SetDaemonState(); SetUserId(); while (1) { serverGeneration++; OsInit(); if (serverGeneration == 1) { /* do first time init */ serverCache = CacheInit(SERVER_CACHE_SIZE); CreateSockets(OldListenCount, OldListen); InitProcVectors(); clients = (ClientPtr *) fsalloc(MAXCLIENTS * sizeof(ClientPtr)); if (!clients) FatalError("couldn't create client array\n"); for (i = MINCLIENT; i < MAXCLIENTS; i++) clients[i] = NullClient; /* make serverClient */ serverClient = (ClientPtr) fsalloc(sizeof(ClientRec)); if (!serverClient) FatalError("couldn't create server client\n"); } ResetSockets(); /* init per-cycle stuff */ InitClient(serverClient, SERVER_CLIENT, (pointer) 0); clients[SERVER_CLIENT] = serverClient; currentMaxClients = MINCLIENT; currentClient = serverClient; if (!InitClientResources(serverClient)) FatalError("couldn't init server resources\n"); InitExtensions(); InitAtoms(); InitFonts(); SetConfigValues(); if (!create_connection_block()) FatalError("couldn't create connection block\n"); #ifdef DEBUG fprintf(stderr, "Entering Dispatch loop\n"); #endif Dispatch(); #ifdef DEBUG fprintf(stderr, "Leaving Dispatch loop\n"); #endif /* clean up per-cycle stuff */ CacheReset(); CloseDownExtensions(); if ((dispatchException & DE_TERMINATE) || drone_server) break; fsfree(ConnectionInfo); /* note that we're parsing it again, for each time the server resets */ if (ReadConfigFile(configfilename) != FSSuccess) FatalError("couldn't read config file\n"); } CloseSockets(); CloseErrors(); exit(0); }
/***************************************************************************** * Function: GadgetSetNeedsCompleteRedraw * * Description: On next GadgetRedraw we erase first *****************************************************************************/ void GadgetSetNeedsCompleteRedraw(Boolean need) { gGadgetCompleteRedraw=need; CacheReset(); }