status_t BnMediaPlayer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case DISCONNECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); disconnect(); return NO_ERROR; } break; case SET_VIDEO_SURFACE: { CHECK_INTERFACE(IMediaPlayer, data, reply); sp<ISurface> surface = interface_cast<ISurface>(data.readStrongBinder()); reply->writeInt32(setVideoSurface(surface)); return NO_ERROR; } break; case PREPARE_ASYNC: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(prepareAsync()); return NO_ERROR; } break; case START: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(start()); return NO_ERROR; } break; case STOP: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(stop()); return NO_ERROR; } break; case IS_PLAYING: { CHECK_INTERFACE(IMediaPlayer, data, reply); bool state; status_t ret = isPlaying(&state); reply->writeInt32(state); reply->writeInt32(ret); return NO_ERROR; } break; case PAUSE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(pause()); return NO_ERROR; } break; case SEEK_TO: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(seekTo(data.readInt32())); return NO_ERROR; } break; case GET_CURRENT_POSITION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getCurrentPosition(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case GET_DURATION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getDuration(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case RESET: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(reset()); return NO_ERROR; } break; case SET_AUDIO_STREAM_TYPE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAudioStreamType(data.readInt32())); return NO_ERROR; } break; case SET_LOOPING: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setLooping(data.readInt32())); return NO_ERROR; } break; case SET_VOLUME: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setVolume(data.readFloat(), data.readFloat())); return NO_ERROR; } break; case INVOKE: { CHECK_INTERFACE(IMediaPlayer, data, reply); invoke(data, reply); return NO_ERROR; } break; case SET_METADATA_FILTER: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setMetadataFilter(data)); return NO_ERROR; } break; case SUSPEND: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(suspend()); return NO_ERROR; } break; case RESUME: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(resume()); return NO_ERROR; } break; case GET_METADATA: { CHECK_INTERFACE(IMediaPlayer, data, reply); const status_t retcode = getMetadata(data.readInt32(), data.readInt32(), reply); reply->setDataPosition(0); reply->writeInt32(retcode); reply->setDataPosition(0); return NO_ERROR; } break; case SET_AUX_EFFECT_SEND_LEVEL: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAuxEffectSendLevel(data.readFloat())); return NO_ERROR; } break; case ATTACH_AUX_EFFECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(attachAuxEffect(data.readInt32())); return NO_ERROR; } break; #ifdef OMAP_ENHANCEMENT case REQUEST_CLONE_MODE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(requestVideoCloneMode(data.readInt32())); return NO_ERROR; } break; #endif default: return BBinder::onTransact(code, data, reply, flags); } }
void PauseLayer::keyBackClicked() { resume(); }
void Node::resumeSchedulerAndActions() { resume(); }
void MenuWidget::unpause() { this->hide(); this->glView->setFocus(); emit resume(); }
static int recordAudio(char *pkgName, char *cursor, BOOL relatedToLastPlayed) { unsigned long getAvailRand(); int handle, ret = -1; char temp[PATH_LENGTH]; char filepath[PATH_LENGTH]; char unique_id[PATH_LENGTH], digits[16]; long start, end, prev; CtnrFile *file; int key; int low_voltage, v; unsigned long wrk1; char *cp, *cp1, category[9]; long metadata_start; long metadata_numfields; unsigned long rand1; long previousBitRate; previousBitRate = BIT_RATE; // set to return BIT_RATE to orig value at end of fct, in case BIT_RATE is changed below rand1 = getAvailRand(); // pick random value to identify this recording unsignedlongToHexString((long)rand1,digits); if (strcmp(cursor,TRANSLATE_TEMP_DIR) == 0) { strcpy(filepath,LANGUAGES_PATH); strcat(filepath,TRANSLATE_TEMP_DIR); strcat(filepath,"/"); strcat(filepath,pkgName); strcat(filepath,AUDIO_FILE_EXT); BIT_RATE = MAX_BIT_RATE; } else if (*cursor == SYS_MSG_CHAR) { strcpy(filepath,LANGUAGES_PATH); catLangDir(filepath); // strcat(filepath,pkgName); cp1 = filepath + strlen(filepath); // save this position strcat(filepath, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); strcat(filepath, "_"); strcat(filepath, digits); strcpy(pkgName, cp1); // change pkgName to show file name we used strcat(filepath,AUDIO_FILE_EXT); } else { strcpy(filepath,USER_PATH); // strcat(filepath,pkgName); cp1 = filepath + strlen(filepath); // save this position strcat(filepath, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); strcat(filepath, "_"); strcat(filepath, digits); strcpy(pkgName, cp1); // change pkgName to show file name we used strcat(filepath,AUDIO_FILE_EXT); } file = getTempFileFromName(cursor,0); if (strcmp(cursor,TRANSLATE_TEMP_DIR) != 0) insertSound(file,NULL,FALSE); if (context.keystroke == KEY_HOME) { //let context.keystroke propogate through ret = 1; // signals no audio recorded but not necessary to throw exception } else { start = getRTCinSeconds(); strcpy(temp,"\x0d\x0a"); longToDecimalString(start,temp+2,8); strcat(temp,(const char *)": RECORD "); LBstrncat(temp,pkgName,60); LBstrncat(temp," -> ",60); LBstrncat(temp,cursor,60); logString(temp,BUFFER); // play record prompt message unless running translation app or if a button was just pressed if (!context.keystroke && strcmp(cursor,TRANSLATE_TEMP_DIR) != 0) { insertSound(&pkgSystem.files[SPEAK_SOUND_FILE_IDX],NULL,FALSE); if (context.keystroke == KEY_HOME) ret = 1; // signals no audio recorded but not necessary to throw exception else context.keystroke = 0; } else context.keystroke = 0; // reset context.keystroke so a second action doesn't take place stop(); start = getRTCinSeconds(); prev = end = start; //asm("INT OFF"); // to prevent recordings with bad blocks } // only open file to record if HOME was not pressed and only proceed if file opens correctly if (ret != 1 && ((handle = tbOpen((LPSTR)filepath,O_CREAT|O_RDWR)) != -1)) { setLED(LED_RED,TRUE); playBip(); turnAmpOff(); Snd_SACM_RecFAT(handle, C_CODEC_AUDIO1800, BIT_RATE); low_voltage = 0; do { end = getRTCinSeconds(); if (0==(end%2) && (prev != end)) { // blink LED every three seconds prev = end; setLED(LED_RED,FALSE); wait (100); setLED(LED_RED,TRUE); while((v = getCurVoltageSample()) == 0xffff); if(vCur_1 < V_MIN_SDWRITE_VOLTAGE) { low_voltage = 1; } } key = keyCheck(0); if (key == KEY_PLAY) { // pause TODO: this key press to pause shouldn't be hard coded pause(); setLED(LED_RED,FALSE); // insertSound(&pkgSystem.files[REC_PAUSED_FILE_IDX],NULL,FALSE); ---need to play this from memory do key = keyCheck(0); // TODO: NEED CODE HERE TO SAFELY SAVE FILE WHEN PAUSED FOR EXTENDED PERIOD OF TIME (maybe 60 min?) // checkInactivity(key); --- this would cause recording to be lost in just 30-300 sec inactivity while (!key); if (key == KEY_PLAY) { setLED(LED_RED,TRUE); resume(); } } } while ((!key || (key == KEY_PLAY)) && (low_voltage == 0)); // TODO: this key press to stop shouldn't be hard coded // while ((end - start) < 3) { // must be at least 2.0 second recording // end = getRTCinSeconds(); // } SACM_Stop(); //Snd_Stop(); // no need to call stop() and flush the log setLED(LED_RED,FALSE); turnAmpOn(); playDing(); //lseek(handle, 6, SEEK_SET ); //Seek to the start of the file input //write(handle,(LPSTR)header<<1,6); // write meta data to end of file close(handle); // rhm: I think its already closed, I can't write to it here systemCounts.recordingNumber++; // bump global recording number saveSystemCounts(); handle = tbOpen((LPSTR)filepath,O_RDWR); metadata_start = lseek(handle, 0L, SEEK_END); // offset to start of metadata metadata_numfields = 0L; // init num fields wrk1 = METADATA_VERSION; writeLE32(handle, wrk1, CURRENT_POS); //meta data version = 1 writeLE32(handle, metadata_numfields, CURRENT_POS); // 4 byte for num fields strcpy(unique_id, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); // skip serial number prefix strcat(unique_id, "_"); strcat(unique_id, digits); addField(handle, DC_IDENTIFIER, unique_id, 1); metadata_numfields += 1; addField(handle, DTB_REVISION, (char *)"0", 1); metadata_numfields += 1; strcpy(unique_id, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); // skip serial number prefix strcat(unique_id, "_"); longToDecimalString(systemCounts.powerUpNumber,(char *)temp,4); strcat(unique_id, temp); strcat(unique_id, "_"); longToDecimalString(systemCounts.recordingNumber,(char *)temp,4); strcat(unique_id, temp); strcat(unique_id, "_"); strncat(unique_id, digits, 8); addField(handle, DC_TITLE, unique_id, 1); metadata_numfields += 1; // strcpy(unique_id, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); // skip serial number prefix // strcat(unique_id, "_"); // strcat(unique_id, digits); // addField(handle, DC_AUDIO_ITEM_ID, unique_id, 1); // metadata_numfields += 1; if (pkgSystem.idxLanguageCode != -1) { strcpy(unique_id,&pkgSystem.strHeapStack[pkgSystem.idxLanguageCode]); addField(handle, DC_LANGUAGE, unique_id, 1); metadata_numfields += 1; } cp = cursor; if(cp != NULL) { if(*cp >= '0' && *cp <= '9') { strcpy(category, cursor); } else if(!strncmp(cp, "AGR", 3)) strcpy(category, CAT_AGRICULTURE); else if(!strncmp(cp, "HEA", 3)) strcpy(category, CAT_HEALTH); else if(!strncmp(cp, "EDU", 3)) strcpy(category, CAT_EDUCATION); else if(!strncmp(cp, "STO", 3)) strcpy(category, CAT_STORIES); else if(!strncmp(cp, "BUS", 3)) strcpy(category, CAT_BUSINESS); else if(!strncmp(cp, "GOV", 3)) strcpy(category, CAT_GOVERNANCE); else if(!strncmp(cp, "MUS", 3)) strcpy(category, CAT_MUSIC); else if(!strncmp(cp, "DIA", 3)) strcpy(category, CAT_DIARY); else strcpy(category, CAT_OTHER); } addField(handle, DC_CATEGORY, category, 1); metadata_numfields += 1; if(relatedToLastPlayed) { strcpy(unique_id, STAT_FN); // DC_IDENTIFIER read at open if(strlen(unique_id)) { addField(handle,DC_RELATION,unique_id,1); metadata_numfields += 1; } } strcpy(unique_id, (char *)TB_SERIAL_NUMBER_ADDR + CONST_TB_SERIAL_PREFIX_LEN); // skip serial number prefix addField(handle,DC_SOURCE,unique_id,1); metadata_numfields += 1; longToDecimalString(systemCounts.powerUpNumber,(char *)temp,4); addField(handle,DC_DATE,temp,1); metadata_numfields += 1; // add other fields here writeLE32(handle, metadata_numfields, metadata_start + 4); // write correct num meta data fields close(handle); // done with meta data //asm("INT FIQ, IRQ"); -- see INT OFF above used once to prevent corrupted recordings (now possibly handled by SD_Initial() after USB Device mode // *P_WatchDog_Ctrl &= ~0x8000; // clear bit 15 to disable if (strcmp(cursor,TRANSLATE_TEMP_DIR) != 0) { insertSound(&pkgSystem.files[POST_REC_FILE_IDX],NULL,FALSE); if (!context.keystroke) insertSound(file,NULL,FALSE); // replay subject } // Leaving this out now, because I believe it gets created when it is first played if non-existent. // The delay of having it in recordAudio is too long. // createStatsFile(rand1); // Assumes no name collision from using a 32-bit semi-random number // Checking all past names was causing a long delay, but maybe (TODO:) we can // add in a check if the open() fails and then generate a new number in that unlikely case strcpy(temp,"TIME RECORDED (secs): "); longToDecimalString((long)end-start,temp+strlen(temp),4); strcat(temp,"\x0d\x0a"); logString(temp,BUFFER); //logString(temp,ASAP); ret = 0; // used to set this based on fileExists() check, but too slow } else if (ret == -1) { logException(16, filepath,RESET); //can't open file for new recording } BIT_RATE = previousBitRate; return ret; }
// Decodes the received IR message // Returns 0 if no data ready, 1 if data ready. // Results of decoding are stored in results int IRrecv::decode(decode_results *results) { results->rawbuf = irparams.rawbuf; results->rawlen = irparams.rawlen; if (irparams.rcvstate != STATE_STOP) { return ERR; } #if TINY_PROTO_NEC #ifdef DEBUG Serial.println("Attempting NEC decode"); #endif if (decodeNEC(results)) { return DECODED; } #endif #if TINY_PROTO_SONY #ifdef DEBUG Serial.println("Attempting Sony decode"); #endif if (decodeSony(results)) { return DECODED; } #endif #if TINY_PROTO_SANYO #ifdef DEBUG Serial.println("Attempting Sanyo decode"); #endif if (decodeSanyo(results)) { return DECODED; } #endif #if TINY_PROTO_MITSUBISHI #ifdef DEBUG Serial.println("Attempting Mitsubishi decode"); #endif if (decodeMitsubishi(results)) { return DECODED; } #endif #if TINY_PROTO_RC5 #ifdef DEBUG Serial.println("Attempting RC5 decode"); #endif if (decodeRC5(results)) { return DECODED; } #endif #if TINY_PROTO_RC6 #ifdef DEBUG Serial.println("Attempting RC6 decode"); #endif if (decodeRC6(results)) { return DECODED; } #endif #if TINY_PROTO_PANASONIC #ifdef DEBUG Serial.println("Attempting Panasonic decode"); #endif if (decodePanasonic(results)) { return DECODED; } #endif #if TINY_PROTO_LG #ifdef DEBUG Serial.println("Attempting LG decode"); #endif if (decodeLG(results)) { return DECODED; } #endif #if TINY_PROTO_JVC #ifdef DEBUG Serial.println("Attempting JVC decode"); #endif if (decodeJVC(results)) { return DECODED; } #endif #if TINY_PROTO_SAMSUNG #ifdef DEBUG Serial.println("Attempting SAMSUNG decode"); #endif if (decodeSAMSUNG(results)) { return DECODED; } #endif #if TINY_PROTO_HASH // decodeHash returns a hash on any input. // Thus, it needs to be last in the list. // If you add any decodes, add them before this. if (decodeHash(results)) { return DECODED; } #endif // Throw away and start over resume(); return ERR; }
void eFilePushThread::start(int fd_source, int fd_dest) { m_raw_source.setfd(fd_source); m_fd_dest = fd_dest; resume(); }
process shell ( did32 dev /* ID of tty device from which */ ) /* to accept commands */ { char buf[SHELL_BUFLEN]; /* Input line (large enough for */ /* one line from a tty device */ int32 len; /* Length of line read */ char tokbuf[SHELL_BUFLEN + /* Buffer to hold a set of */ SHELL_MAXTOK]; /* Contiguous null-terminated */ /* Strings of tokens */ int32 tlen; /* Current length of all data */ /* in array tokbuf */ int32 tok[SHELL_MAXTOK]; /* Index of each token in */ /* array tokbuf */ int32 toktyp[SHELL_MAXTOK]; /* Type of each token in tokbuf */ int32 ntok; /* Number of tokens on line */ pid32 child; /* Process ID of spawned child */ bool8 backgnd; /* Run command in background? */ char *outname, *inname; /* Pointers to strings for file */ /* names that follow > and < */ did32 stdinput, stdoutput; /* Descriptors for redirected */ /* input and output */ int32 i; /* Index into array of tokens */ int32 j; /* Index into array of commands */ int32 msg; /* Message from receive() for */ /* child termination */ int32 tmparg; /* Address of this var is used */ /* when first creating child */ /* process, but is replaced */ char *src, *cmp; /* Pointers used during name */ /* comparison */ bool8 diff; /* Was difference found during */ /* comparison */ char *args[SHELL_MAXTOK]; /* Argument vector passed to */ /* builtin commands */ /* Print shell banner and startup message */ fprintf(dev, "\n\n%s%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", SHELL_BAN0,SHELL_BAN1,SHELL_BAN2,SHELL_BAN3,SHELL_BAN4, SHELL_BAN5,SHELL_BAN6,SHELL_BAN7,SHELL_BAN8,SHELL_BAN9); fprintf(dev, "%s\n\n", SHELL_STRTMSG); /* Continually prompt the user, read input, and execute command */ while (TRUE) { /* Display prompt */ fprintf(dev, SHELL_PROMPT); /* Read a command */ len = read(dev, buf, sizeof(buf)); /* Exit gracefully on end-of-file */ if (len == EOF) { break; } /* If line contains only NEWLINE, go to next line */ if (len <= 1) { continue; } buf[len] = SH_NEWLINE; /* terminate line */ /* Parse input line and divide into tokens */ ntok = lexan(buf, len, tokbuf, &tlen, tok, toktyp); /* Handle parsing error */ if (ntok == SYSERR) { fprintf(dev,"%s\n", SHELL_SYNERRMSG); continue; } /* If line is empty, go to next input line */ if (ntok == 0) { fprintf(dev, "\n"); continue; } /* If last token is '&', set background */ if (toktyp[ntok-1] == SH_TOK_AMPER) { ntok-- ; tlen-= 2; backgnd = TRUE; } else { backgnd = FALSE; } /* Check for input/output redirection (default is none) */ outname = inname = NULL; if ( (ntok >=3) && ( (toktyp[ntok-2] == SH_TOK_LESS) ||(toktyp[ntok-2] == SH_TOK_GREATER))){ if (toktyp[ntok-1] != SH_TOK_OTHER) { fprintf(dev,"%s\n", SHELL_SYNERRMSG); continue; } if (toktyp[ntok-2] == SH_TOK_LESS) { inname = &tokbuf[tok[ntok-1]]; } else { outname = &tokbuf[tok[ntok-1]]; } ntok -= 2; tlen = tok[ntok]; } if ( (ntok >=3) && ( (toktyp[ntok-2] == SH_TOK_LESS) ||(toktyp[ntok-2] == SH_TOK_GREATER))){ if (toktyp[ntok-1] != SH_TOK_OTHER) { fprintf(dev,"%s\n", SHELL_SYNERRMSG); continue; } if (toktyp[ntok-2] == SH_TOK_LESS) { if (inname != NULL) { fprintf(dev,"%s\n", SHELL_SYNERRMSG); continue; } inname = &tokbuf[tok[ntok-1]]; } else { if (outname != NULL) { fprintf(dev,"%s\n", SHELL_SYNERRMSG); continue; } outname = &tokbuf[tok[ntok-1]]; } ntok -= 2; tlen = tok[ntok]; } /* Verify remaining tokens are type "other" */ for (i=0; i<ntok; i++) { if (toktyp[i] != SH_TOK_OTHER) { break; } } if ((ntok == 0) || (i < ntok)) { fprintf(dev, SHELL_SYNERRMSG); continue; } stdinput = stdoutput = dev; /* Lookup first token in the command table */ for (j = 0; j < ncmd; j++) { src = cmdtab[j].cname; cmp = tokbuf; diff = FALSE; while (*src != NULLCH) { if (*cmp != *src) { diff = TRUE; break; } src++; cmp++; } if (diff || (*cmp != NULLCH)) { continue; } else { break; } } /* Handle command not found */ if (j >= ncmd) { fprintf(dev, "command %s not found\n", tokbuf); continue; } /* Handle built-in command */ if (cmdtab[j].cbuiltin) { /* No background or redirect. */ if (inname != NULL || outname != NULL || backgnd){ fprintf(dev, SHELL_BGERRMSG); continue; } else { /* Set up arg vector for call */ for (i=0; i<ntok; i++) { args[i] = &tokbuf[tok[i]]; } /* Call builtin shell function */ if ((*cmdtab[j].cfunc)(ntok, args) == SHELL_EXIT) { break; } } continue; } /* Open files and redirect I/O if specified */ if (inname != NULL) { stdinput = open(NAMESPACE,inname,"ro"); if (stdinput == SYSERR) { fprintf(dev, SHELL_INERRMSG, inname); continue; } } if (outname != NULL) { stdoutput = open(NAMESPACE,outname,"w"); if (stdoutput == SYSERR) { fprintf(dev, SHELL_OUTERRMSG, outname); continue; } else { control(stdoutput, F_CTL_TRUNC, 0, 0); } } /* Spawn child thread for non-built-in commands */ child = create(cmdtab[j].cfunc, SHELL_CMDSTK, SHELL_CMDPRIO, cmdtab[j].cname, 2, ntok, &tmparg); /* If creation or argument copy fails, report error */ if ((child == SYSERR) || (addargs(child, ntok, tok, tlen, tokbuf, &tmparg) == SYSERR) ) { fprintf(dev, SHELL_CREATMSG); continue; } /* Set stdinput and stdoutput in child to redirect I/O */ proctab[child].prdesc[0] = stdinput; proctab[child].prdesc[1] = stdoutput; msg = recvclr(); resume(child); if (! backgnd) { msg = receive(); while (msg != child) { msg = receive(); } } } /* Terminate the shell process by returning from the top level */ fprintf(dev,SHELL_EXITMSG); return OK; }
bool CVideoInfoTag::Save(TiXmlNode *node, const std::string &tag, bool savePathInfo, const TiXmlElement *additionalNode) { if (!node) return false; // we start with a <tag> tag TiXmlElement movieElement(tag.c_str()); TiXmlNode *movie = node->InsertEndChild(movieElement); if (!movie) return false; XMLUtils::SetString(movie, "title", m_strTitle); if (!m_strOriginalTitle.empty()) XMLUtils::SetString(movie, "originaltitle", m_strOriginalTitle); if (!m_strShowTitle.empty()) XMLUtils::SetString(movie, "showtitle", m_strShowTitle); if (!m_strSortTitle.empty()) XMLUtils::SetString(movie, "sorttitle", m_strSortTitle); if (!m_ratings.empty()) { TiXmlElement ratings("ratings"); for (const auto& it : m_ratings) { TiXmlElement rating("rating"); rating.SetAttribute("name", it.first.c_str()); XMLUtils::SetFloat(&rating, "value", it.second.rating); XMLUtils::SetInt(&rating, "votes", it.second.votes); rating.SetAttribute("max", 10); if (it.first == m_strDefaultRating) rating.SetAttribute("default", "true"); ratings.InsertEndChild(rating); } movie->InsertEndChild(ratings); } XMLUtils::SetInt(movie, "userrating", m_iUserRating); if (m_EpBookmark.timeInSeconds > 0) { TiXmlElement epbookmark("episodebookmark"); XMLUtils::SetFloat(&epbookmark, "position", (float)m_EpBookmark.timeInSeconds); if (!m_EpBookmark.playerState.empty()) { TiXmlElement playerstate("playerstate"); CXBMCTinyXML doc; doc.Parse(m_EpBookmark.playerState); playerstate.InsertEndChild(*doc.RootElement()); epbookmark.InsertEndChild(playerstate); } movie->InsertEndChild(epbookmark); } XMLUtils::SetInt(movie, "top250", m_iTop250); if (tag == "episodedetails" || tag == "tvshow") { XMLUtils::SetInt(movie, "season", m_iSeason); XMLUtils::SetInt(movie, "episode", m_iEpisode); XMLUtils::SetInt(movie, "displayseason",m_iSpecialSortSeason); XMLUtils::SetInt(movie, "displayepisode",m_iSpecialSortEpisode); } if (tag == "musicvideo") { XMLUtils::SetInt(movie, "track", m_iTrack); XMLUtils::SetString(movie, "album", m_strAlbum); } XMLUtils::SetString(movie, "outline", m_strPlotOutline); XMLUtils::SetString(movie, "plot", m_strPlot); XMLUtils::SetString(movie, "tagline", m_strTagLine); XMLUtils::SetInt(movie, "runtime", GetDuration() / 60); if (!m_strPictureURL.m_xml.empty()) { CXBMCTinyXML doc; doc.Parse(m_strPictureURL.m_xml); const TiXmlNode* thumb = doc.FirstChild("thumb"); while (thumb) { movie->InsertEndChild(*thumb); thumb = thumb->NextSibling("thumb"); } } if (m_fanart.m_xml.size()) { CXBMCTinyXML doc; doc.Parse(m_fanart.m_xml); movie->InsertEndChild(*doc.RootElement()); } XMLUtils::SetString(movie, "mpaa", m_strMPAARating); XMLUtils::SetInt(movie, "playcount", GetPlayCount()); XMLUtils::SetDate(movie, "lastplayed", m_lastPlayed); if (savePathInfo) { XMLUtils::SetString(movie, "file", m_strFile); XMLUtils::SetString(movie, "path", m_strPath); XMLUtils::SetString(movie, "filenameandpath", m_strFileNameAndPath); XMLUtils::SetString(movie, "basepath", m_basePath); } if (!m_strEpisodeGuide.empty()) { CXBMCTinyXML doc; doc.Parse(m_strEpisodeGuide); if (doc.RootElement()) movie->InsertEndChild(*doc.RootElement()); else XMLUtils::SetString(movie, "episodeguide", m_strEpisodeGuide); } XMLUtils::SetString(movie, "id", GetUniqueID()); for (const auto& uniqueid : m_uniqueIDs) { TiXmlElement uniqueID("uniqueid"); uniqueID.SetAttribute("type", uniqueid.first); if (uniqueid.first == m_strDefaultUniqueID) uniqueID.SetAttribute("default", "true"); TiXmlText value(uniqueid.second); uniqueID.InsertEndChild(value); movie->InsertEndChild(uniqueID); } XMLUtils::SetStringArray(movie, "genre", m_genre); XMLUtils::SetStringArray(movie, "country", m_country); if (!m_strSet.empty()) { TiXmlElement set("set"); XMLUtils::SetString(&set, "name", m_strSet); if (!m_strSetOverview.empty()) XMLUtils::SetString(&set, "overview", m_strSetOverview); movie->InsertEndChild(set); } XMLUtils::SetStringArray(movie, "tag", m_tags); XMLUtils::SetStringArray(movie, "credits", m_writingCredits); XMLUtils::SetStringArray(movie, "director", m_director); if (HasPremiered()) XMLUtils::SetDate(movie, "premiered", m_premiered); if (HasYear()) XMLUtils::SetInt(movie, "year", GetYear()); XMLUtils::SetString(movie, "status", m_strStatus); XMLUtils::SetString(movie, "code", m_strProductionCode); XMLUtils::SetDate(movie, "aired", m_firstAired); XMLUtils::SetStringArray(movie, "studio", m_studio); XMLUtils::SetString(movie, "trailer", m_strTrailer); if (m_streamDetails.HasItems()) { // it goes fileinfo/streamdetails/[video|audio|subtitle] TiXmlElement fileinfo("fileinfo"); TiXmlElement streamdetails("streamdetails"); for (int iStream=1; iStream<=m_streamDetails.GetVideoStreamCount(); iStream++) { TiXmlElement stream("video"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetVideoCodec(iStream)); XMLUtils::SetFloat(&stream, "aspect", m_streamDetails.GetVideoAspect(iStream)); XMLUtils::SetInt(&stream, "width", m_streamDetails.GetVideoWidth(iStream)); XMLUtils::SetInt(&stream, "height", m_streamDetails.GetVideoHeight(iStream)); XMLUtils::SetInt(&stream, "durationinseconds", m_streamDetails.GetVideoDuration(iStream)); XMLUtils::SetString(&stream, "stereomode", m_streamDetails.GetStereoMode(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetAudioStreamCount(); iStream++) { TiXmlElement stream("audio"); XMLUtils::SetString(&stream, "codec", m_streamDetails.GetAudioCodec(iStream)); XMLUtils::SetString(&stream, "language", m_streamDetails.GetAudioLanguage(iStream)); XMLUtils::SetInt(&stream, "channels", m_streamDetails.GetAudioChannels(iStream)); streamdetails.InsertEndChild(stream); } for (int iStream=1; iStream<=m_streamDetails.GetSubtitleStreamCount(); iStream++) { TiXmlElement stream("subtitle"); XMLUtils::SetString(&stream, "language", m_streamDetails.GetSubtitleLanguage(iStream)); streamdetails.InsertEndChild(stream); } fileinfo.InsertEndChild(streamdetails); movie->InsertEndChild(fileinfo); } /* if has stream details */ // cast for (iCast it = m_cast.begin(); it != m_cast.end(); ++it) { // add a <actor> tag TiXmlElement cast("actor"); TiXmlNode *node = movie->InsertEndChild(cast); XMLUtils::SetString(node, "name", it->strName); XMLUtils::SetString(node, "role", it->strRole); XMLUtils::SetInt(node, "order", it->order); XMLUtils::SetString(node, "thumb", it->thumbUrl.GetFirstThumb().m_url); } XMLUtils::SetStringArray(movie, "artist", m_artist); XMLUtils::SetStringArray(movie, "showlink", m_showLink); for (const auto& namedSeason : m_namedSeasons) { TiXmlElement season("namedseason"); season.SetAttribute("number", namedSeason.first); season.SetValue(namedSeason.second); movie->InsertEndChild(season); } TiXmlElement resume("resume"); XMLUtils::SetFloat(&resume, "position", (float)m_resumePoint.timeInSeconds); XMLUtils::SetFloat(&resume, "total", (float)m_resumePoint.totalTimeInSeconds); if (!m_resumePoint.playerState.empty()) { TiXmlElement playerstate("playerstate"); CXBMCTinyXML doc; doc.Parse(m_resumePoint.playerState); playerstate.InsertEndChild(*doc.RootElement()); resume.InsertEndChild(playerstate); } movie->InsertEndChild(resume); XMLUtils::SetDateTime(movie, "dateadded", m_dateAdded); if (additionalNode) movie->InsertEndChild(*additionalNode); return true; }
static void activate_purger(rtems_task_priority prio) { set_task_prio(task_id_purger, prio); resume(task_id_purger); }
static void create_waiter(void) { resume(task_id_waiter); set_task_prio(task_id_waiter, PRIORITY_IDLE); }
/*------------------------------------------------------------------------ * nulluser -- initialize system and become the null process (id==0) *------------------------------------------------------------------------ */ nulluser() /* babysit CPU when no one home */ { int userpid; #ifdef X__COM32__ init_com32(); #endif initevec(); #ifdef X__COM32__ puts_com32("initevec() done\n"); #endif sysinit(); #ifdef X__COM32__ puts_com32("sysinit() done\n"); #endif /* associate CONSOLE with a tty */ open(CONSOLE, KBMON, 0); /* open(CONSOLE, SERIAL0); */ sprintf(vers, "Xinu Version %s", VERSION); kprintf("\n\n%s\n", vers); if (reboot++ < 1) kprintf("\n"); else kprintf(" (reboot %d)\n", reboot); kprintf("%d bytes real mem\n", (unsigned long) maxaddr+1); #ifdef DETAIL kprintf(" %d", (unsigned long) 0); kprintf(" to %d\n", (unsigned long) (maxaddr) ); #endif kprintf("%d bytes Xinu code\n", (unsigned long) ((unsigned long) &end - (unsigned long) start)); #ifdef DETAIL kprintf(" %d", (unsigned long) start); kprintf(" to %d\n", (unsigned long) &end ); #endif #ifdef DETAIL kprintf("%d bytes user stack/heap space\n", (unsigned long) ((unsigned long) maxaddr - (unsigned long) &end)); kprintf(" %d", (unsigned long) &end); kprintf(" to %d\n", (unsigned long) maxaddr); #endif kprintf("clock %sabled\n", clkruns == 1?"en":"dis"); /* !!! enable();*/ /* enable interrupts */ kprintf("interrupts enabled\n"); /* create a process to execute the user's main program */ userpid = create(main,INITSTK,INITPRIO,INITNAME,INITARGS); /* start the network */ resume(create(netstart,NETSTK,NETPRI,NETNAM,NETARGC,userpid)); while (TRUE) /* empty */; }
ThreadCollector::ThreadCollector() { resume(); }
void IRrecvBase::enableIRIn(void) { pinMode(irparams.recvpin, INPUT); resume(); }
int main(void) { int8_t idle_task_id; // set up the ports.... hw_init(); // allow input to settle while clock switch in progress TRISBbits.TRISB15 = 1; // input port CNPUBbits.CNPUB15 = 1; // with a pull-up // set up the PLL for 70Mips // FOSC = 10mHz // FPLLI = 5Mhz // FSYS = 280Mhz // FOSC = 140Mhz PLLFBD = I_PLLDIV; // PLL divider CLKDIVbits.PLLPRE = I_PLLPRE; // Prescaler divide by 2 CLKDIVbits.PLLPOST = I_PLLPOST; // Postscale divide by 2 // Initiate Clock Switch to Primary Oscillator with PLL (NOSC=0b011) if(OSCCONbits.COSC != 0b011) { __builtin_write_OSCCONH(0x03); __builtin_write_OSCCONL(OSCCON | 0x01); // Wait for Clock switch to occur while (OSCCONbits.COSC!= 0b011); } // Wait for PLL to lock while (OSCCONbits.LOCK!= 1); // unlock the PPS functions __builtin_write_OSCCONL(OSCCON & 0xbf); // map pins map_rpo(RP42R, rpo_c1tx); map_rpi(rpi_rpi44, rpi_c1rx); TRISAbits.TRISA0 = 1; TRISAbits.TRISA1 = 1; TRISAbits.TRISA7 = 1; TRISAbits.TRISA10 = 1; TRISBbits.TRISB0 = 1; TRISBbits.TRISB1 = 1; TRISBbits.TRISB15 = 1; TRISCbits.TRISC0 = 1; TRISCbits.TRISC1 = 1; TRISCbits.TRISC2 = 1; ee_params.init_mode = PORTBbits.RB15 == 0; // set up uart data early init_deque(&uart_config.rx_queue, RX_BUFFER_LENGTH, rx_queue, NUM_RX_BUFFERS); init_deque(&uart_config.tx_queue, TX_BUFFER_LENGTH, tx_queue, NUM_TX_BUFFERS); idle_task_id = scheduler_init(tasks, NUM_TASKS, idle_task, idle_stack, numelements(idle_stack)); resume(idle_task_id); // create the canbus task can_init(HARDWARE_REVISION, SOFTWARE_REVISION, can_tx_buffer, CAN_TX_LENGTH, can_rx_buffer, CAN_RX_LENGTH, can_tx_stack, numelements(can_tx_stack), 0, can_rx_stack, numelements(can_rx_stack), 0, publisher_stack, numelements(publisher_stack), 0); subscribe(&listener); // initialize the eeprom as we need our settings first eeprom_init(&ee_params); resume(create_task("KEYS", keys_stack, numelements(keys_stack), keys_worker, 0, NORMAL_PRIORITY)); // run with an idle task run(idle_task_id); return 0; }
syscall future_get(future *f, int* value) { // kprintf("Inside Future_get\n"); // kprintf("Flag%d",f->flag); if(f->flag == FUTURE_EXCLUSIVE) { f->pid = getpid(); if(f->state == FUTURE_EMPTY) { suspend(f->pid); //return SYSERR; } //kprintf("relesed"); *value = f->value; f->state = FUTURE_EMPTY; //change the state back.. } else if (f->flag == FUTURE_SHARED) { if(f->state == FUTURE_EMPTY) // the future is not set yet.. { //enqueue this process.. enqueueFuture(&(f->get_queue), getpid()); //TODO:wait the process.. suspend(getpid()); } *value = f->value; } else if (f->flag == FUTURE_QUEUE) { //TODO: Incomplete functionality.. if(f->set_queue.size == 0) { //no process waiting to set the future.. //allocate this process to the get queue and wait.. enqueueFuture(&(f->get_queue), getpid()); //wait the current process.. suspend(getpid()); } else { //dequeue a process from the set queue.. enqueueFuture(&(f->get_queue), getpid()); resume(dequeueFuture(&(f->set_queue))); while(f->state != FUTURE_VALID) { resched(); } } *value = f->value; f->state = FUTURE_EMPTY; } else { kprintf("Unsupported future state!!!"); return SYSERR; } return OK; }
TEventQueue::TEventQueue() { #ifdef __MSDOS__ resume(); #endif }
// Decodes the received IR message // Returns 0 if no data ready, 1 if data ready. // Results of decoding are stored in results int IRrecv::decode(decode_results *results) { results->rawbuf = irparams.rawbuf; results->rawlen = irparams.rawlen; if (irparams.rcvstate != STATE_STOP) { return ERR; } #ifdef DEBUG Serial.println("Attempting NEC decode"); #endif if (decodeNEC(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting Sony decode"); #endif if (decodeSony(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting Sanyo decode"); #endif if (decodeSanyo(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting Mitsubishi decode"); #endif if (decodeMitsubishi(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting RC5 decode"); #endif if (decodeRC5(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting RC6 decode"); #endif if (decodeRC6(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting Panasonic decode"); #endif if (decodePanasonic(results)) { return DECODED; } #ifdef DEBUG Serial.println("Attempting JVC decode"); #endif if (decodeJVC(results)) { return DECODED; } // decodeHash returns a hash on any input. // Thus, it needs to be last in the list. // If you add any decodes, add them before this. if (decodeHash(results)) { return DECODED; } // Throw away and start over resume(); return ERR; }
int main (int argc, char* argv[]) { int fd, rc, attach_pin = 0; char* libdir = NULL; pid_t pid; char ldpath[4096]; int base; int follow_splits = 0; int save_mmap = 0; struct option long_options[] = { {"pthread", required_argument, 0, 0}, {0, 0, 0, 0} }; /* do { int i; for (i = 0; i < argc; i++) { printf("Got input arg of %s\n", argv[i]); } } while (0); */ while (1) { char opt; int option_index = 0; opt = getopt_long(argc, argv, "fpmh", long_options, &option_index); //printf("getopt_long returns %c (%d)\n", opt, opt); if (opt == -1) { break; } switch(opt) { case 0: switch(option_index) { case 0: //printf("pthread libdir is %s\n", optarg); libdir = optarg; break; default: assert(0); } break; case 'm': //printf("save_mmap is on"); save_mmap = 1; break; case 'f': //printf("follow_splits is on"); follow_splits = 1; break; case 'p': //printf("attach_pin is on"); attach_pin = 1; break; case 'h': print_help(argv[0]); exit(EXIT_SUCCESS); break; default: fprintf(stderr, "Unrecognized option\n"); print_help(argv[0]); exit(EXIT_FAILURE); break; } } base = optind; /* David D. Replaced with proper getopts */ /* for (base = 2; base < argc; base++) { if (!strcmp(argv[base], "-p")) { attach_pin = 1; } else if (!strcmp(argv[base], "-f")) { follow_splits = 1; } else if (!strcmp(argv[base], "-m")) { save_mmap = 1; } else if (argc > base+1 && !strncmp(argv[base], "--pthread", 8)) { libdir = argv[base+1]; base++; } else { break; // unrecognized arg } } */ /* do { int i; for (i = base; i < argc; i++) { printf("Got non-opt arg: %s\n", argv[i]); } } while (0); */ if (argc-base != 1) { fprintf(stderr, "Invalid non-arg arguments!\n"); print_help(argv[0]); exit(EXIT_FAILURE); } if (attach_pin && save_mmap) { fprintf(stderr, "Attaching pin (-p) and saving mmaps (-m) shouldn't both be enabled!\n"); exit(EXIT_FAILURE); } if (libdir) { strcpy (ldpath, libdir); strcat (ldpath, "/ld-linux.so.2"); libdir = ldpath; } fd = open ("/dev/spec0", O_RDWR); if (fd < 0) { perror ("open /dev/spec0"); exit(EXIT_FAILURE); } pid = getpid(); printf("libdir: %s, ldpath: %s\n", libdir, ldpath); printf("resume pid %d follow %d\n", pid, follow_splits); rc = resume (fd, attach_pin, follow_splits, save_mmap, argv[base], libdir); if (rc < 0) { perror ("resume"); return -1; } fprintf (stderr, "resume should not return\n"); return -1; }
///---------------------------------------------------------------------------- void coroutine_stackful_actor::handle_recv(detail::pack& pk) { if (check(pk.recver_, ctxid_, timestamp_)) { bool is_response = false; if (aid_t* aid = boost::get<aid_t>(&pk.tag_)) { mb_.push(*aid, pk.msg_); } else if (detail::request_t* req = boost::get<detail::request_t>(&pk.tag_)) { mb_.push(*req, pk.msg_); } else if (detail::link_t* link = boost::get<detail::link_t>(&pk.tag_)) { add_link(link->get_aid(), pk.skt_); return; } else if (detail::exit_t* ex = boost::get<detail::exit_t>(&pk.tag_)) { mb_.push(*ex, pk.msg_); base_type::remove_link(ex->get_aid()); } else if (response_t* res = boost::get<response_t>(&pk.tag_)) { is_response = true; mb_.push(*res, pk.msg_); } if ( (recving_ && !is_response) || (responsing_ && is_response) ) { if (recving_ && !is_response) { bool ret = mb_.pop(recving_rcv_, recving_msg_, curr_match_.match_list_); if (!ret) { return; } curr_match_.clear(); } if (responsing_ && is_response) { BOOST_ASSERT(recving_res_.valid()); bool ret = mb_.pop(recving_res_, recving_msg_); if (!ret) { return; } } ++tmr_sid_; errcode_t ec; tmr_.cancel(ec); resume(actor_normal); } } else if (!pk.is_err_ret_) { if (detail::link_t* link = boost::get<detail::link_t>(&pk.tag_)) { /// send actor exit msg base_type::send_already_exited(link->get_aid(), pk.recver_); } else if (detail::request_t* req = boost::get<detail::request_t>(&pk.tag_)) { /// reply actor exit msg response_t res(req->get_id(), pk.recver_); base_type::send_already_exited(req->get_aid(), res); } } }
void TracingThread::stop() { if( ToSuspend ) resume(); stopped = true; }
LRESULT player_impl::win_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { PAINTSTRUCT ps; HDC hdc; switch (msg) { case WM_CREATE: { SetTimer(hwnd, ID_PLAYER_TIMER, 100, NULL); } break; case WM_TIMER: { if (wparam != ID_PLAYER_TIMER) break; // 计算显示客户区. int more_y = GetSystemMetrics(SM_CYCAPTION) + (GetSystemMetrics(SM_CYBORDER) * 2) + (GetSystemMetrics(SM_CYDLGFRAME) * 2); int more_x = (GetSystemMetrics(SM_CXDLGFRAME) * 2) + (GetSystemMetrics(SM_CXBORDER) * 2); if (!m_avplay || !m_avplay->m_video_ctx) break; if (m_avplay && m_avplay->m_video_ctx && (m_avplay->m_video_ctx->width != 0 || m_avplay->m_video_ctx->height != 0 || m_avplay->m_play_status == playing)) { RECT rc = { 0 }; GetWindowRect(hwnd, &rc); SetWindowPos(hwnd, HWND_NOTOPMOST, rc.left, rc.top, m_avplay->m_video_ctx->width + more_x, m_avplay->m_video_ctx->height + more_y, SWP_FRAMECHANGED); KillTimer(hwnd, ID_PLAYER_TIMER); } // 得到正确的宽高信息. m_video_width = m_avplay->m_video_ctx->width; m_video_height = m_avplay->m_video_ctx->height; } break; case WM_KEYDOWN: if (wparam == VK_F2) { full_screen(!m_full_screen); } break; case WM_RBUTTONDOWN: { if (m_avplay && m_avplay->m_play_status == playing) pause(); else if (m_avplay && m_avplay->m_play_status == paused) resume(); } break; case WM_LBUTTONDOWN: { RECT rc = { 0 }; GetWindowRect(hwnd, &rc); int width = rc.right - rc.left; int xpos = LOWORD(lparam); double fact = (double)xpos / width; if (m_avplay && (m_avplay->m_play_status == playing || m_avplay->m_play_status == completed) && (fact >= 0.0f && fact <= 1.0f)) ::av_seek(m_avplay, fact); } break; // case WM_PAINT: // hdc = BeginPaint(hwnd, &ps); // if (m_avplay) // win_paint(hwnd, hdc); // EndPaint(hwnd, &ps); // break; case WM_ERASEBKGND: { return 1; // if (m_video && m_avplay->m_play_status == playing) // return 1; // else // return DefWindowProc(hwnd, msg, wparam, lparam); } case WM_ACTIVATE: case WM_SYNCPAINT: break; case WM_MOVING: case WM_MOVE: case WM_SIZE: { RECT window; GetClientRect(hwnd, &window); if (m_avplay && m_avplay->m_vo_ctx && m_video->priv) { m_video->re_size(m_video, LOWORD(lparam), HIWORD(lparam)); } InvalidateRect(hwnd, NULL, TRUE); } break; case WM_DESTROY: PostQuitMessage(0); break; default: break; } if (m_old_win_proc) return CallWindowProc(m_old_win_proc, hwnd, msg, wparam, lparam);// m_old_win_proc(hwnd, msg, wparam, lparam); else return DefWindowProc(hwnd, msg, wparam, lparam); }
void insertSound(CtnrFile *file, CtnrBlock *block, BOOL wait) { unsigned long lastPlayedPoint; CtnrFile *lastFilePlayed; unsigned long lBlockEndPoint; int keystroke = 0; int isPlayerStopped = !SACM_Status(); BOOL wasPaused; wasPaused = context.isPaused; lastFilePlayed = context.file; context.file = file; if (block) lBlockEndPoint = extractTime(block->endTime,context.package->timePrecision); if (!isPlayerStopped) { lastPlayedPoint = Snd_A1800_GetCurrentTime(); if (lastPlayedPoint < INSERT_SOUND_REWIND_MS) lastPlayedPoint = 0; else lastPlayedPoint -= INSERT_SOUND_REWIND_MS; //context.file should not be changed until we need them again in a few lines play(context.file,block?block->startTime:0); context.isPaused = FALSE; while (SACM_Status() && !keystroke) { if (block && lBlockEndPoint < Snd_A1800_GetCurrentTime()) { stop(); break; } if (!wait && (keystroke = keyCheck(0))) { if (keystroke == KEY_PLAY && !context.isPaused) { pause(); context.isPaused = TRUE; } else if (keystroke == KEY_PLAY && context.isPaused) { resume(); context.isPaused = FALSE; } else context.keystroke = keystroke; } } context.file = lastFilePlayed; playLongInt(context.file,lastPlayedPoint); if (wasPaused) { pause(); context.isPaused = TRUE; } } else { play(file,block?block->startTime:0); context.isPaused = FALSE; while (SACM_Status() && !keystroke) { if (block && lBlockEndPoint < Snd_A1800_GetCurrentTime()) { stop(); break; } if (!wait && (keystroke = keyCheck(0))) { if (keystroke == KEY_PLAY && !context.isPaused) { pause(); context.isPaused = TRUE; } else if (keystroke == KEY_PLAY && context.isPaused) { resume(); context.isPaused = FALSE; } else context.keystroke = keystroke; } } context.file = lastFilePlayed; } if (!SACM_Status()) { context.isStopped = TRUE; context.isPaused = FALSE; turnAmpOff(); } }
int main() { srand(1); int i; int count = 0; char buf[8]; double total_cnt; double a_percent, b_percent, c_percent, d_percent; kprintf("\n\n########## Test Case1, linux-like scheduling basic(2 processes):\n"); setschedclass(LINUXSCHED); resume(prC = create(proc, 2000, 90, "proc C", 1, 'C')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prC); kprintf("\n\n########## Test Case2, linux-like scheduling basic(4 processes):\n"); count=0; resume(prA = create(proc, 2000, 5, "proc A", 1, 'A')); resume(prB = create(proc, 2000, 50, "proc B", 1, 'B')); resume(prC = create(proc, 2000, 100, "proc C", 1, 'C')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); kill(prC); kprintf("\n\n########## Test Case3, linux-like scheduling with priority 15 and 25 (3 processes):\n"); count = 0; setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 15, "proc A", 1, 'A')); resume(prB = create(proc, 2000, 25, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); kprintf("\n\n########## Test Case4, linux-like scheduling with quantum 8 (3 processes):\n"); count = 0; setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 8, "proc A", 1, 'A')); resume(prB = create(proc, 2000, 8, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); kprintf("\n\n########## Test Case5, linux-like scheduling with quantum 100 (3 processes):\n"); count = 0; setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 100, "proc A", 1, 'A')); resume(prB = create(proc, 2000, 100, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); kprintf("\n\n########## Test Case6, linux-like scheduling with quantum 1000 (3 processes):\n"); count = 0; setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 1000, "proc A", 1, 'A')); resume(prB = create(proc, 2000, 1000, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); count=0; kprintf("\n\n########## Test Case7, linux-like scheduling with big quantum(3 processes):\n"); setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 1000000000, "proc A", 1, 'A')); resume(prB = create(procsleep, 2000, 1000000000, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); count=0; kprintf("\n\n########## Test Case8, linux-like scheduling with chprio(3 processes):\n"); setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 100, "proc A", 1, 'A')); resume(prB = create(procchprio, 2000, 100, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } kill(prA); kill(prB); count=0; kprintf("\n\n########## Test Case9, linux-like scheduling with create(3 processes):\n"); setschedclass(LINUXSCHED); resume(prA = create(proc, 2000, 200, "proc A", 1, 'A')); resume(prB = create(proccreate, 2000, 200, "proc B", 1, 'B')); while (count++ < LOOP) { kprintf("M"); for (i = 0; i < 10000000; i++); } sleep(5); kill(prA); kill(prB); count=0; kprintf("\n\n########## Test Case10, linux-like scheduling with sleep across epoch(3 processes):\n"); setschedclass(LINUXSCHED); resume(prA = create(proclong, 2000, 200, "proc A", 1, 'A')); resume(prB = create(procsleepmore, 2000, 200, "proc B", 1, 'B')); while (count++ < LOOP*2) { kprintf("M"); for (i = 0; i < 10000000; i++); } sleep(5); kill(prA); kill(prB); kprintf("\n\n########## Test Case11, multi-q scheduling(3 processes):\n"); setschedclass(MULTIQSCHED); total_cnt=0; a_percent=0; b_percent=0; prA = create(proc_a, 2000, 100, "proc A", 1, 'A'); prB = createReal(proc_b, 2000, 10, "proc B", 1, 'B'); resume(prA); resume(prB); sleep(5); kill(prA); kill(prB); total_cnt = a_cnt + b_cnt ; a_percent = (double) a_cnt / total_cnt * 100; b_percent = (double) b_cnt / total_cnt * 100; kprintf("Test RESULT: A = %d, B = %d (%d : %d)\n", a_cnt, b_cnt, (int) a_percent, (int) b_percent); kprintf("\n\n########## Test Case12, multi-q scheduling(4 processes):\n"); setschedclass(MULTIQSCHED); total_cnt=0; a_percent=0; b_percent=0; c_percent=0; a_cnt=b_cnt=c_cnt=0; prA = create(proc_a, 2000, 100, "proc A", 1, 'A'); prB = createReal(proc_b, 2000, 10, "proc B", 1, 'B'); prC = createReal(proc_c, 2000, 10, "proc C", 1, 'C'); resume(prA); resume(prB); resume(prC); sleep(10); kill(prA); kill(prB); kill(prC); total_cnt = a_cnt + b_cnt + c_cnt; a_percent = (double) a_cnt / total_cnt * 100; b_percent = (double) b_cnt / total_cnt * 100; c_percent = (double) c_cnt / total_cnt * 100; kprintf("Test RESULT: A = %d, B = %d, C = %d (%d : %d : %d)\n", a_cnt, b_cnt, c_cnt, (int) a_percent, (int) b_percent, (int) c_percent); kprintf("\n\n########## Test Case13, multi-q scheduling without real proc(3 processes):\n"); setschedclass(MULTIQSCHED); total_cnt=0; a_percent=0; b_percent=0; a_cnt=0; b_cnt=0; prA = create(proc_a, 2000, 100, "proc A", 1, 'A'); prB = create(proc_b, 2000, 100, "proc B", 1, 'B'); resume(prA); resume(prB); sleep(5); kill(prA); kill(prB); total_cnt = a_cnt + b_cnt ; a_percent = (double) a_cnt / total_cnt * 100; b_percent = (double) b_cnt / total_cnt * 100; kprintf("Test RESULT: A = %d, B = %d (%d : %d)\n", a_cnt, b_cnt, (int) a_percent, (int) b_percent); }
void PauseLayer::menupResume(CCObject *pSender) { resume(); }
CtrlAltDelSimulator::CtrlAltDelSimulator() { resume(); }
void GameState::handle_events(Game* game, sf::Event event) { if(event.type == sf::Event::LostFocus) pause(); else if(event.type == sf::Event::GainedFocus) resume(); if(paused) return; if(!in_menu) player.handle_events(event); if(in_menu) { player.erase_movement(); bool held; if(event.type == sf::Event::KeyPressed) { /*if(event.key.code == sf::Keyboard::Space) { const int BUY = 0, GIFT = 1, LEAVE = 2; switch(option) { case BUY: if(player.get_inventory().get_magiberries() > 0) { player.set_power(player.get_power() + (float)player.get_inventory().get_magiberries()/10); player.get_inventory().add_magiberries(player.get_inventory().get_magiberries()*-1); } in_menu = false; option = 0; return; break; case GIFT: if(player.get_inventory().get_iron() > 0) { std::cout << "Donated " << player.get_inventory().get_iron() << "!\n"; cur_village->favour = (float)player.get_inventory().get_iron() / (float)10; player.get_inventory().add_iron(player.get_inventory().get_iron()*-1); } in_menu = false; option = 0; return; break; case LEAVE: in_menu = false; option = 0; return; break; default: break; } }else*/ if(event.key.code == sf::Keyboard::W){ if(option > 0) option--; }else if(event.key.code == sf::Keyboard::S){ if(option < 2) option++; }else if(event.key.code == sf::Keyboard::Num1){ if(player.get_inventory().get_magiberries() > 0) { player.set_power(player.get_power() + (float)player.get_inventory().get_magiberries()/10); player.get_inventory().add_magiberries(player.get_inventory().get_magiberries()*-1); } in_menu = false; option = 0; return; }else if(event.key.code == sf::Keyboard::Num2){ if(player.get_inventory().get_iron() > 0) { std::cout << "Donated " << player.get_inventory().get_iron() << "!\n"; cur_village->favour = cur_village->favour += (float)player.get_inventory().get_iron() / (float)5; player.get_inventory().add_iron(player.get_inventory().get_iron()*-1); } in_menu = false; option = 0; return; }else if(event.key.code == sf::Keyboard::Num3){ in_menu = false; option = 0; return; } std::cout << "Menu: " << in_menu << " | O: " << option << " | FAV: " << cur_village->favour << " | POW: " << player.get_power() << "\n"; } } if(!in_menu && player.action && event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Space) { //- Is the ore a resource? if(level.get_tile(player.get_pos().x, player.get_pos().y, 27).is_resource) { const int IR = 2, MB = 1; switch(level.get_tile(player.get_pos().x, player.get_pos().y, 27).resource_code) { case IR: { if(player.get_shape() == Shape::IRON) { player.get_inventory().add_iron(1); std::cout << "Iron: " << player.get_inventory().get_iron() << "\nMagiBerries: " << player.get_inventory().get_magiberries() << "\n"; action_sound.play(); } else { std::cout << "[GS]: Not shapeshifter!\n"; } } break; case MB: player.get_inventory().add_magiberries(1); std::cout << "Iron: " << player.get_inventory().get_iron() << "\nMagiBerries: " << player.get_inventory().get_magiberries() << "\n"; mine_sound.play(); break; default: break; } } //- Village check for(int i = 0; i < level.get_villages().size(); ++i) { if(level.get_villages()[i]->get_bbox().intersects(player.get_bbox())) { this->cur_village = level.get_villages()[i]; in_menu = true; break; } } } //- Handle player movement /*sf::FloatRect new_pos; #define press(key) sf::Keyboard::isKeyPressed(key) if(press(keys["up"])) { // if ((**i).canMove(0,-1,_world)) // (**i)._sprite.Move(0,-32); new_pos = sf::FloatRect(player.get_pos().x+player.vx, player.move().y, w, h); if(player) } #undef press*/ }
WsConfigRunner::WsConfigRunner(Logger *logger, bool serviceMode) : m_serviceMode(serviceMode), m_log(logger) { resume(); }
//+============================================================================= // Decodes the received IR message // Returns 0 if no data ready, 1 if data ready. // Results of decoding are stored in results // int IRrecv::decode (decode_results *results) { results->rawbuf = irparams.rawbuf; results->rawlen = irparams.rawlen; results->overflow = irparams.overflow; if (irparams.rcvstate != STATE_STOP) return false ; #if DECODE_NEC DBG_PRINTLN("Attempting NEC decode"); if (decodeNEC(results)) return true ; #endif #if DECODE_SONY DBG_PRINTLN("Attempting Sony decode"); if (decodeSony(results)) return true ; #endif #if DECODE_SANYO DBG_PRINTLN("Attempting Sanyo decode"); if (decodeSanyo(results)) return true ; #endif #if DECODE_MITSUBISHI DBG_PRINTLN("Attempting Mitsubishi decode"); if (decodeMitsubishi(results)) return true ; #endif #if DECODE_RC5 DBG_PRINTLN("Attempting RC5 decode"); if (decodeRC5(results)) return true ; #endif #if DECODE_RC6 DBG_PRINTLN("Attempting RC6 decode"); if (decodeRC6(results)) return true ; #endif #if DECODE_PANASONIC DBG_PRINTLN("Attempting Panasonic decode"); if (decodePanasonic(results)) return true ; #endif #if DECODE_LG DBG_PRINTLN("Attempting LG decode"); if (decodeLG(results)) return true ; #endif #if DECODE_JVC DBG_PRINTLN("Attempting JVC decode"); if (decodeJVC(results)) return true ; #endif #if DECODE_SAMSUNG DBG_PRINTLN("Attempting SAMSUNG decode"); if (decodeSAMSUNG(results)) return true ; #endif #if DECODE_WHYNTER DBG_PRINTLN("Attempting Whynter decode"); if (decodeWhynter(results)) return true ; #endif #if DECODE_AIWA_RC_T501 DBG_PRINTLN("Attempting Aiwa RC-T501 decode"); if (decodeAiwaRCT501(results)) return true ; #endif #if DECODE_DENON DBG_PRINTLN("Attempting Denon decode"); if (decodeDenon(results)) return true ; #endif // decodeHash returns a hash on any input. // Thus, it needs to be last in the list. // If you add any decodes, add them before this. if (decodeHash(results)) return true ; // Throw away and start over resume(); return false; }
int main() { int lck, lrdm, lwrl, lwrh, sem, srdm, swrl, swrh, lloop, sloop; kprintf("Start priority inversion test with lock\n"); lck = lcreate(); lloop = create(dowait, 2000, 25, "dowait", 1, 5); lwrh = create(lwr, 2000, 30, "writer", 4, "writer H", lck, 20, 2); lwrl = create(lwr, 2000, 10, "writer", 4, "writer L", lck, 20, 5); lrdm = create(lrd, 2000, 20, "reader", 4, "reader M", lck, 20, 1); kprintf("Start Writer L, then sleep 1s\n"); resume(lwrl); sleep(1); kprintf("Start Writer H, then sleep 1s\n"); resume(lwrh); sleep(1); kprintf("Start dowait, then sleep 1s\n"); resume(lloop); sleep(1); sleep(10); kprintf ("Lock test finished!\n"); kprintf("Start priority inversion test with semaphore\n"); sem = screate(1); sloop= create(dowait, 2000, 20, "dowait", 1, 5); swrh = create(srw, 2000, 30, "writer", 3, "writer H", sem, 5); swrl = create(srw, 2000, 10, "writer", 3, "writer L", sem, 3); srdm = create(srw, 2000, 40, "reader", 3, "reader M", sem, 1); kprintf("Start Writer L, then sleep 1s\n"); resume(swrl); sleep(1); kprintf("Start Writer H, then sleep 1s\n"); resume(swrh); sleep(1); kprintf("Start dowait, then sleep 1s\n"); resume(sloop); sleep(1); sleep(10); kprintf ("Semaphore test finished!\n"); return 0; }