这篇教程C++ snooze函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中snooze函数的典型用法代码示例。如果您正苦于以下问题:C++ snooze函数的具体用法?C++ snooze怎么用?C++ snooze使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了snooze函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: thread_usleepinline void thread_usleep(unsigned int usec) { snooze(usec); }
开发者ID:Kazunekit,项目名称:OcherBook,代码行数:1,
示例2: RTDECLRTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies){ RT_ASSERT_PREEMPTIBLE(); snooze((bigtime_t)cMillies * 1000); return VINF_SUCCESS;}
开发者ID:LastRitter,项目名称:vbox-haiku,代码行数:6,
示例3: DeviceHub::Hub(Object *parent, int8 hubAddress, uint8 hubPort, usb_device_descriptor &desc, int8 deviceAddress, usb_speed speed, bool isRootHub) : Device(parent, hubAddress, hubPort, desc, deviceAddress, speed, isRootHub), fInterruptPipe(NULL){ TRACE("creating hub/n"); memset(&fHubDescriptor, 0, sizeof(fHubDescriptor)); for (int32 i = 0; i < USB_MAX_PORT_COUNT; i++) fChildren[i] = NULL; if (!fInitOK) { TRACE_ERROR("device failed to initialize/n"); return; } // Set to false again for the hub init. fInitOK = false; if (fDeviceDescriptor.device_class != 9) { TRACE_ERROR("wrong class! bailing out/n"); return; } TRACE("getting hub descriptor.../n"); size_t actualLength; status_t status = GetDescriptor(USB_DESCRIPTOR_HUB, 0, 0, (void *)&fHubDescriptor, sizeof(usb_hub_descriptor), &actualLength); // we need at least 8 bytes if (status < B_OK || actualLength < 8) { TRACE_ERROR("error getting hub descriptor/n"); return; } TRACE("hub descriptor (%ld bytes):/n", actualLength); TRACE("/tlength:..............%d/n", fHubDescriptor.length); TRACE("/tdescriptor_type:.....0x%02x/n", fHubDescriptor.descriptor_type); TRACE("/tnum_ports:...........%d/n", fHubDescriptor.num_ports); TRACE("/tcharacteristics:.....0x%04x/n", fHubDescriptor.characteristics); TRACE("/tpower_on_to_power_g:.%d/n", fHubDescriptor.power_on_to_power_good); TRACE("/tdevice_removeable:...0x%02x/n", fHubDescriptor.device_removeable); TRACE("/tpower_control_mask:..0x%02x/n", fHubDescriptor.power_control_mask); if (fHubDescriptor.num_ports > USB_MAX_PORT_COUNT) { TRACE_ALWAYS("hub supports more ports than we do (%d vs. %d)/n", fHubDescriptor.num_ports, USB_MAX_PORT_COUNT); fHubDescriptor.num_ports = USB_MAX_PORT_COUNT; } usb_interface_list *list = Configuration()->interface; Object *object = GetStack()->GetObject(list->active->endpoint[0].handle); if (object && (object->Type() & USB_OBJECT_INTERRUPT_PIPE) != 0) { fInterruptPipe = (InterruptPipe *)object; fInterruptPipe->QueueInterrupt(fInterruptStatus, sizeof(fInterruptStatus), InterruptCallback, this); } else { TRACE_ALWAYS("no interrupt pipe found/n"); } // Wait some time before powering up the ports if (!isRootHub) snooze(USB_DELAY_HUB_POWER_UP); // Enable port power on all ports for (int32 i = 0; i < fHubDescriptor.num_ports; i++) { status = DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT, USB_REQUEST_SET_FEATURE, PORT_POWER, i + 1, 0, NULL, 0, NULL); if (status < B_OK) TRACE_ERROR("power up failed on port %" B_PRId32 "/n", i); } // Wait for power to stabilize snooze(fHubDescriptor.power_on_to_power_good * 2000); fInitOK = true; TRACE("initialised ok/n");}
开发者ID:ErfanBagheri,项目名称:haiku,代码行数:81,
示例4: MTAKEstatic void *sendKeepalives(void *parm){ KeepaliveThreadParms *parms = (KeepaliveThreadParms *) parm; int keepaliveTimer = 0; int bytesSent; int backoffTimer = BACKOFF_TIMER_START; int backoffTimerCount = 0; unsigned char *buffer; buffer = MTAKE(TCPCLA_BUFSZ); //To send keepalive bundle if (buffer == NULL) { putErrmsg("No memory for TCP buffer in tcpclo.", NULL); return NULL; } iblock(SIGTERM); while (*(parms->cloRunning)) { snooze(1); keepaliveTimer++; if (keepaliveTimer < *(parms->keepalivePeriod)) { continue; } // If the negotiated keep alive interval is 0, then // keep alives will not be sent. if(*(parms->keepalivePeriod) == 0) { continue; } /* Time to send a keepalive. Note that the * interval between keepalive attempts will be * KEEPALIVE_PERIOD plus (if the remote induct * is not reachable) the length of time taken * by TCP to determine that the connection * attempt will not succeed (e.g., 3 seconds). */ keepaliveTimer = 0; pthread_mutex_lock(parms->mutex); bytesSent = sendBundleByTCPCL(parms->socketName, parms->ductSocket, 0, 0, buffer, parms->keepalivePeriod); pthread_mutex_unlock(parms->mutex); /* if the node is unable to establish a TCP connection, * the connection should be tried only after some delay. * */ if(bytesSent == 0) { while((backoffTimerCount < backoffTimer) && (*(parms->ductSocket) < 0)) { snooze(1); backoffTimerCount++; if(!(*(parms->cloRunning))) { break; } } backoffTimerCount = 0; /* keepaliveTimer keeps track of when the keepalive needs * to be sent. This value is set to keepalive period. * That way at the end of backoff period a * keepalive is sent * */ keepaliveTimer = *(parms->keepalivePeriod); if(backoffTimer < BACKOFF_TIMER_LIMIT) { backoffTimer *= 2; } continue; } backoffTimer = BACKOFF_TIMER_START; if (bytesSent < 0) { shutDownClo(); break; } } MRELEASE(buffer); return NULL;}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:83,
示例5: Virge_GEResetstatic voidVirge_GEReset(const DisplayModeEx& mode){ SharedInfo& si = *gInfo.sharedInfo; if (si.chipType == S3_TRIO_3D) Virge_NopAllCmdSets(); gInfo.WaitIdleEmpty(); if (si.chipType == S3_TRIO_3D) { bool ge_was_on = false; snooze(10000); for (int r = 1; r < 10; r++) { uint8 resetidx = 0x66; VerticalRetraceWait(); uint8 tmp = ReadCrtcReg(resetidx); VerticalRetraceWait(); IN_SUBSYS_STAT(); // turn off the GE if (tmp & 0x01) { WriteCrtcReg(resetidx, tmp); ge_was_on = true; snooze(10000); } IN_SUBSYS_STAT(); WriteCrtcReg(resetidx, tmp | 0x02); snooze(10000); VerticalRetraceWait(); WriteCrtcReg(resetidx, tmp & ~0x02); snooze(10000); if (ge_was_on) { tmp |= 0x01; WriteCrtcReg(resetidx, tmp); snooze(10000); } VerticalRetraceWait(); Virge_NopAllCmdSets(); gInfo.WaitIdleEmpty(); WriteReg32(DEST_SRC_STR, mode.bytesPerRow << 16 | mode.bytesPerRow); snooze(10000); if ((IN_SUBSYS_STAT() & 0x3f802000 & 0x20002000) != 0x20002000) { TRACE("Restarting S3 graphics engine reset %2d ...%lx/n", r, IN_SUBSYS_STAT() ); } else break; } } else { uint8 regIndex = (si.chipType == S3_VIRGE_VX ? 0x63 : 0x66); uint8 tmp = ReadCrtcReg(regIndex); snooze(10000); // try multiple times to avoid lockup of VIRGE/MX for (int r = 1; r < 10; r++) { WriteCrtcReg(regIndex, tmp | 0x02); snooze(10000); WriteCrtcReg(regIndex, tmp & ~0x02); snooze(10000); gInfo.WaitIdleEmpty(); WriteReg32(DEST_SRC_STR, mode.bytesPerRow << 16 | mode.bytesPerRow); snooze(10000); if (((IN_SUBSYS_STAT() & 0x3f00) != 0x3000)) { TRACE("Restarting S3 graphics engine reset %2d .../n", r); } else break; } } gInfo.WaitQueue(2); WriteReg32(SRC_BASE, 0); WriteReg32(DEST_BASE, 0); gInfo.WaitQueue(4); WriteReg32(CLIP_L_R, ((0) << 16) | mode.timing.h_display); WriteReg32(CLIP_T_B, ((0) << 16) | mode.timing.v_display); WriteReg32(MONO_PAT_0, ~0); WriteReg32(MONO_PAT_1, ~0); if (si.chipType == S3_TRIO_3D) Virge_NopAllCmdSets();}
开发者ID:DonCN,项目名称:haiku,代码行数:96,
示例6: floatsleep//.........这里部分代码省略......... delay((int)(secs * 1000 + 0.5)); /* delay() uses milliseconds */ Py_END_ALLOW_THREADS#elif defined(MS_WINDOWS) { double millisecs = secs * 1000.0; unsigned long ul_millis; if (millisecs > (double)ULONG_MAX) { PyErr_SetString(PyExc_OverflowError, "sleep length is too large"); return -1; } Py_BEGIN_ALLOW_THREADS /* Allow sleep(0) to maintain win32 semantics, and as decreed * by Guido, only the main thread can be interrupted. */ ul_millis = (unsigned long)millisecs; if (ul_millis == 0 || main_thread != PyThread_get_thread_ident()) Sleep(ul_millis); else { DWORD rc; ResetEvent(hInterruptEvent); rc = WaitForSingleObject(hInterruptEvent, ul_millis); if (rc == WAIT_OBJECT_0) { /* Yield to make sure real Python signal * handler called. */ Sleep(1); Py_BLOCK_THREADS errno = EINTR; PyErr_SetFromErrno(PyExc_IOError); return -1; } } Py_END_ALLOW_THREADS }#elif defined(PYOS_OS2) /* This Sleep *IS* Interruptable by Exceptions */ Py_BEGIN_ALLOW_THREADS if (DosSleep(secs * 1000) != NO_ERROR) { Py_BLOCK_THREADS PyErr_SetFromErrno(PyExc_IOError); return -1; } Py_END_ALLOW_THREADS#elif defined(__BEOS__) /* This sleep *CAN BE* interrupted. */ { if( secs <= 0.0 ) { return; } Py_BEGIN_ALLOW_THREADS /* BeOS snooze() is in microseconds... */ if( snooze( (bigtime_t)( secs * 1000.0 * 1000.0 ) ) == B_INTERRUPTED ) { Py_BLOCK_THREADS PyErr_SetFromErrno( PyExc_IOError ); return -1; } Py_END_ALLOW_THREADS }#elif defined(RISCOS) if (secs <= 0.0) return 0; Py_BEGIN_ALLOW_THREADS /* This sleep *CAN BE* interrupted. */ if ( riscos_sleep(secs) ) return -1; Py_END_ALLOW_THREADS#elif defined(PLAN9) { double millisecs = secs * 1000.0; if (millisecs > (double)LONG_MAX) { PyErr_SetString(PyExc_OverflowError, "sleep length is too large"); return -1; } /* This sleep *CAN BE* interrupted. */ Py_BEGIN_ALLOW_THREADS if(sleep((long)millisecs) < 0){ Py_BLOCK_THREADS PyErr_SetFromErrno(PyExc_IOError); return -1; } Py_END_ALLOW_THREADS }#elif _AMIGA /* XXX Can't interrupt this sleep */ Py_BEGIN_ALLOW_THREADS Delay((long)(secs*50)); Py_END_ALLOW_THREADS#else /* !_AMIGA */ /* XXX Can't interrupt this sleep */ Py_BEGIN_ALLOW_THREADS sleep((int)secs); Py_END_ALLOW_THREADS#endif /* !_AMIGA */ /* XXX Can't interrupt this sleep */ return 0;}
开发者ID:Belxjander,项目名称:Kirito,代码行数:101,
示例7: sstatus_t TToolTipView::ToolTipThread(tool_tip *tip){ uint32 buttons; BPoint where; BScreen s(B_MAIN_SCREEN_ID); BRect screen = s.Frame(); screen.InsetBy(2, 2); while (!tip->quit) { if (tip->tool_tip_window->LockWithTimeout(0) == B_NO_ERROR) { if (tip->tool_tip_view->Window()) tip->tool_tip_view->GetMouse(&where, &buttons,false);/* if (tip->tool_tip_view->Window()) if (tip->tool_tip_view->Window()->CurrentMessage()) { tip->tool_tip_view->Window()->CurrentMessage()->FindPoint("where", &where); tip->tool_tip_view->Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); }*/ tip->tool_tip_view->ConvertToScreen(&where); tip->stopped = tip->stop; if (tip->reset) { if (tip->showing) tip->tool_tip_window->Hide(); tip->stop = false; tip->stopped = false; tip->reset = false; tip->shown = false; tip->showing = false; tip->start_time = system_time() + tip->settings.delay; } else if (tip->showing) { if ((tip->stop) || (!tip->settings.enabled) || (!tip->app_active) || (!tip->bounds.Contains(where)) || (tip->expire_time < system_time()) || (abs((int)tip->start.x - (int)where.x) > kSLOP) || (abs((int)tip->start.y - (int)where.y) > kSLOP) || (buttons)) { tip->tool_tip_window->Hide(); tip->shown = tip->settings.one_time_only; tip->showing = false; tip->tip_timed_out = (tip->expire_time < system_time()); tip->start_time = system_time() + tip->settings.delay; } } else if ((tip->settings.enabled) && (!tip->stopped) && (tip->app_active) && (!tip->shown) && (!tip->tip_timed_out) && (!buttons) && (tip->bounds.Contains(where)) && (tip->start_time < system_time())) { tip->start = where; tip->tool_tip_view->AdjustWindow(); tip->tool_tip_window->Show(); tip->tool_tip_window->Activate(false); tip->showing = true; tip->expire_time = system_time() + tip->settings.hold; tip->start = where; } else if ((abs((int)tip->start.x - (int)where.x) > kSLOP) || (abs((int)tip->start.y - (int)where.y) > kSLOP)) { tip->start = where; tip->start_time = system_time() + tip->settings.delay; tip->tip_timed_out = false; } if (buttons) tip->start_time = system_time() + tip->settings.delay; tip->tool_tip_window->Unlock(); } snooze(50000); } return B_NO_ERROR;}
开发者ID:HaikuArchives,项目名称:Globe,代码行数:80,
示例8: mainint main (int argc, char* argv[]) { // int oldtime, newtime; // bk001204 - unused int len, i; char *cmdline; //jens void Sys_SetDefaultCDPath(const char *path); thread_id cThread; cThread = spawn_thread(appthread, "q3appthread", B_LOW_PRIORITY, 0); resume_thread(cThread); snooze(100000); //Todo app_info cInfo; be_app->GetAppInfo(&cInfo); BEntry cFile(&cInfo.ref); BEntry cDir; cFile.GetParent(&cDir); BPath cPath; cDir.GetPath(&cPath); chdir(cPath.Path()); be_app->HideCursor(); // go back to real user for config loads //jens saved_euid = geteuid(); //jens seteuid(getuid()); Sys_ParseArgs(argc, argv); // bk010104 - added this for support Sys_SetDefaultCDPath(argv[0]); // merge the command line, this is kinda silly for (len = 1, i = 1; i < argc; i++) len += strlen(argv[i]) + 1; cmdline = (char*)malloc(len); *cmdline = 0; for (i = 1; i < argc; i++) { if (i > 1) strcat(cmdline, " "); strcat(cmdline, argv[i]); } // bk000306 - clear queues memset(&eventQue[0], 0, MAX_QUED_EVENTS*sizeof(sysEvent_t) ); memset(&sys_packetReceived[0], 0, MAX_MSGLEN*sizeof(byte) ); Com_Init(cmdline); NET_Init(); Sys_ConsoleInputInit();// int fd = 0;// fd = fileno(stdin);// int on = 1;// setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));// setsockopt(STDIN_FILENO, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int)); //jensfcntl(0, F_SETFL, fcntl (0, F_GETFL, 0) | FNDELAY);#ifdef DEDICATED // init here for dedicated, as we don't have GLimp_Init //jens InitSig();#endif while (1) {#ifdef __linux__ Sys_ConfigureFPU();#endif Com_Frame (); }}
开发者ID:kallisti5,项目名称:quake3,代码行数:69,
示例9: yahoo_io_threadint32yahoo_io_thread( void * _data ){ YahooConnection * conn = (YahooConnection*)_data; register_callbacks(); conn->fID = yahoo_init_with_attributes(conn->fYahooID, conn->fPassword, "local_host", "95.252.70.62", "pager_port", 5050, NULL); LOG("yahoo_io_thread: id: %s, pass: %s/n", conn->fYahooID, conn->fPassword ); gYahooConnections[conn->fID] = conn; yahoo_login(conn->fID, YAHOO_STATUS_AVAILABLE); int lfd = 0; fd_set inp, outp; struct timeval tv; while (conn->IsAlive()) { snooze(10000); FD_ZERO(&inp); FD_ZERO(&outp); tv.tv_sec=3; tv.tv_usec=1E4; lfd=0; int i; for(i = 0; i < conn->CountConnections(); i++) { struct conn_handler *c = conn->ConnectionAt(i); if(c->remove) { conn->RemoveConnection(c); c->remove = 0; free(c); } else { if(c->cond & YAHOO_INPUT_READ) FD_SET(c->con->fd, &inp); if(c->cond & YAHOO_INPUT_WRITE) FD_SET(c->con->fd, &outp); if(lfd < c->con->fd) lfd = c->con->fd; } } select(lfd + 1, &inp, &outp, NULL, &tv); time(&curTime); for(i = 0; i < conn->CountConnections(); i++) { struct conn_handler *c = conn->ConnectionAt(i); if(c->con->remove) { free(c->con); c->con = NULL; break; } if(c->remove) continue; if(FD_ISSET(c->con->fd, &inp)) yahoo_callback(c, YAHOO_INPUT_READ); if(FD_ISSET(c->con->fd, &outp)) yahoo_callback(c, YAHOO_INPUT_WRITE); } if(expired(pingTimer)) yahoo_ping_timeout_callback(conn->fID); // if(expired(webcamTimer)) yahoo_webcam_timeout_callback(webcam_id); } LOG("Exited loop"); for(int i = 0; i < conn->CountConnections(); i++) { struct conn_handler *c = conn->ConnectionAt(i); free(c); conn->RemoveConnection(c); } return 0;}
开发者ID:Barrett17,项目名称:Caya,代码行数:78,
示例10: ltpclockint ltpclock(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9, int a10){#elseint main(int argc, char *argv[]){#endif Sdr sdr; LtpDB *ltpConstants; int state = 1; time_t currentTime; if (ltpInit(0, 0) < 0) { putErrmsg("ltpclock can't initialize LTP.", NULL); return 1; } sdr = getIonsdr(); ltpConstants = getLtpConstants(); isignal(SIGTERM, shutDown); /* Main loop: wait for event occurrence time, then * execute applicable events. */ oK(_running(&state)); writeMemo("[i] ltpclock is running."); while (_running(NULL)) { /* Sleep for 1 second, then dispatch all events * whose executions times have now been reached. */ snooze(1); currentTime = getUTCTime(); /* Infer link state changes from rate changes * noted in the shared ION database. */ if (manageLinks(sdr, currentTime) < 0) { putErrmsg("Can't manage links.", NULL); state = 0; /* Terminate loop. */ oK(_running(&state)); continue; } /* Then dispatch retransmission events, as * constrained by the new link state. */ if (dispatchEvents(sdr, ltpConstants->timeline, currentTime) < 0) { putErrmsg("Can't dispatch events.", NULL); state = 0; /* Terminate loop. */ oK(_running(&state)); continue; } } writeErrmsgMemos(); writeMemo("[i] ltpclock has ended."); ionDetach(); return 0;}
开发者ID:b,项目名称:ION,代码行数:64,
示例11: usb_disk_device_added//.........这里部分代码省略......... mutex_init(&device->lock, "usb_disk device lock"); status_t result = device->notify = create_sem(0, "usb_disk callback notify"); if (result < B_OK) { mutex_destroy(&device->lock); free(device); return result; } result = device->interruptLock = create_sem(0, "usb_disk interrupt lock"); if (result < B_OK) { mutex_destroy(&device->lock); free(device); return result; } // TODO: handle more than 1 unit device->lun_count = 1; device->luns = (device_lun **)malloc(device->lun_count * sizeof(device_lun *)); for (uint8 i = 0; i < device->lun_count; i++) device->luns[i] = NULL; result = B_OK; TRACE_ALWAYS("device reports a lun count of %d/n", device->lun_count); for (uint8 i = 0; i < device->lun_count; i++) { // create the individual luns present on this device device_lun *lun = (device_lun *)malloc(sizeof(device_lun)); if (lun == NULL) { result = B_NO_MEMORY; break; } device->luns[i] = lun; lun->device = device; lun->logical_unit_number = i; lun->should_sync = false; lun->media_present = true; lun->media_changed = true; usb_disk_reset_capacity(lun); // initialize this lun result = usb_disk_inquiry(lun); // Reset the device // If we don't do it all the other commands except inquiry and send // diagnostics will be stalled. result = usb_disk_send_diagnostic(lun); for (uint32 tries = 0; tries < 3; tries++) { status_t ready = usb_disk_test_unit_ready(lun); if (ready == B_OK || ready == B_DEV_NO_MEDIA) { if (ready == B_OK) { if (lun->device_type == B_CD) lun->write_protected = true; // TODO: check for write protection; disabled since // some devices lock up when getting the mode sense else if (/*usb_disk_mode_sense(lun) != B_OK*/true) lun->write_protected = false; } break; } snooze(10000); } if (result != B_OK) break; } if (result != B_OK) { TRACE_ALWAYS("failed to initialize logical units/n"); usb_disk_free_device_and_luns(device); return result; } mutex_lock(&gDeviceListLock); device->device_number = 0; disk_device *other = gDeviceList; while (other != NULL) { if (other->device_number >= device->device_number) device->device_number = other->device_number + 1; other = (disk_device *)other->link; } device->link = (void *)gDeviceList; gDeviceList = device; gLunCount += device->lun_count; for (uint8 i = 0; i < device->lun_count; i++) sprintf(device->luns[i]->name, DEVICE_NAME, device->device_number, i); mutex_unlock(&gDeviceListLock); TRACE("new device: 0x%08lx/n", (uint32)device); *cookie = (void *)device; return B_OK;}
开发者ID:Karvjorm,项目名称:haiku,代码行数:101,
示例12: mainint main(int argc, char *argv[]){ ALuint freq; ALenum format; ALvoid *data; ALsizei i, size; thread_id thread1, thread2; status_t status; /* listener parameters */ ALfloat listenerOrientation[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f }; ALfloat listenerPosition[] = { 0.0f, 0.0f, 0.0f }; ALfloat listenerVelocity[] = { 0.0f, 0.0f, 0.0f }; /* source parameters */ ALfloat sourcePosition[] = { 0.0f, 0.0f, 1.0f }; ALfloat sourceVelocity[] = { 0.0f, 0.0f, 0.0f }; ALfloat sourcePitch = 1.0f; ALfloat sourceGain = 1.0f; /* initialize */ print("Main: initialize"); alInit((ALint *) &argc, (ALubyte **) argv); /* create context */ print("Main: create context"); context = alcCreateContext(22050, AL_FORMAT_STEREO16, 2048); /* lock the context */ print("Main: make current"); alcMakeCurrent(context); /* create buffers and sources */ if (alGenBuffers(kNumBuffers, buffer) != kNumBuffers) quit("Can't create buffers"); if (alGenSources(kNumSources, source) != kNumSources) quit("Can't create sources"); /* load buffers with data */ alutLoadWAV(kWaveFileName, &format, &data, &size, &freq); for (i = 0; i < kNumBuffers; i++) { alBufferData(buffer[i], format, data, size, freq); } free(data); /* initialize listener */ alListenerfv(AL_POSITION, listenerPosition); alListenerfv(AL_VELOCITY, listenerVelocity); alListenerfv(AL_ORIENTATION, listenerOrientation); /* initialize sources */ for (i = 0; i < kNumSources; i++) { alSourcefv(source[i], AL_POSITION, sourcePosition); alSourcefv(source[i], AL_VELOCITY, sourceVelocity); alSourcef(source[i], AL_PITCH, sourcePitch); alSourcef(source[i], AL_GAIN, sourceGain); alSourcei(source[i], AL_BUFFER, buffer[i % kNumBuffers]); alSourcei(source[i], AL_LOOPING, AL_TRUE); } /* start the sources */ print("Main: play"); for (i = 0; i < kNumSources; i++) alSourcePlay(source[i]); /* release the context */ print("Main: release current"); alcMakeCurrent(NULL); /* spawn two threads */ print("Main: spawn thread 1"); thread1 = spawn_thread(threadFunc1, "thread 1", B_NORMAL_PRIORITY, NULL); print("Main: spawn thread 2"); thread2 = spawn_thread(threadFunc2, "thread 2", B_NORMAL_PRIORITY, NULL); /* resume the threads */ print("Main: resume thread 1"); resume_thread(thread1); print("Main: resume thread 2"); resume_thread(thread2); /* acquire context, snooze and release context */ print("Main: make current"); alcMakeCurrent(context); print("Main: snooze..."); snooze(500000); print("Main: release current"); alcMakeCurrent(NULL); //.........这里部分代码省略.........
开发者ID:Aye1,项目名称:RVProject,代码行数:101,
示例13: Windowvoid PatternMenuButton::MouseDown (BPoint point){// BMenuItem *selected;// point = BPoint (0, 0);// ConvertToScreen (&point);// BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD,// point.x + OPEN_RAD, point.y + OPEN_RAD);// menu->Show();// if ((selected = menu->Track (true, &openRect)) != NULL)// {// index = menu->IndexOf (selected);// menu->Mark (index);// menu->InvalidateWindow();// }// menu->Hide();// Invalidate(); Window()->Lock(); uint32 buttons = Window()->CurrentMessage()->FindInt32 ("buttons");// uint32 clicks = Window()->CurrentMessage()->FindInt32 ("clicks"); BMenuItem *mselected; point = BPoint (0, 0); ConvertToScreen (&point); if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; GetMouse (&pbp, &bt, true); bigtime_t start = system_time(); while (system_time() - start < dcspeed) { snooze (20000); GetMouse (&bp, &bt, true); if (!bt && click != 2) { click = 0; } if (bt && !click) { click = 2; } if (bp != pbp) break; } if (click != 2) { BRect openRect = BRect (point.x - OPEN_RAD, point.y - OPEN_RAD, point.x + OPEN_RAD, point.y + OPEN_RAD); menu->Show(); if ((mselected = menu->Track (true, &openRect)) != NULL) { index = menu->IndexOf (mselected); menu->Mark (index); if (MenuWinOnScreen) menu->InvalidateWindow(); } menu->Hide(); if (editorshowing) {// rgb_color c = color();// BMessage *msg = new BMessage ('SetC');// msg->AddInt32 ("color", c.red);// msg->AddInt32 ("color", c.green);// msg->AddInt32 ("color", c.blue);// editor->PostMessage (msg);// delete msg; } click = 1; } } if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY) { click = 1; if (editorshowing) {// rgb_color c = color();// BMessage *msg = new BMessage ('SetC');// msg->AddInt32 ("color", c.red);// msg->AddInt32 ("color", c.green);// msg->AddInt32 ("color", c.blue);// editor->PostMessage (msg);// delete msg; } else { ShowEditor(); } } Invalidate(); Window()->Unlock();}
开发者ID:gedrin,项目名称:Becasso,代码行数:90,
示例14: Windowvoid CMassView::MouseDown(BPoint where) // reacts to mouse clicks { long whichButtons = 1; // used for tracking which buttons are down Window()->CurrentMessage()->FindInt32("buttons", &whichButtons); // find out which buttons are down if (inGLMode && (whichButtons & B_SECONDARY_MOUSE_BUTTON)) // if we are in GL mode, and button 2 is down { float frameWidth = Frame().Width(), frameHeight = Frame().Height(); // find the width & height dragMode = dragBall; // drag the arcball to rotate HVect vNow; // vector type for passing to ball functions vNow.x = (2.0 * where.x - frameWidth)/frameWidth; // set the vector vNow.y = -(2.0 * where.y - frameHeight)/frameHeight; // in both dimensions Ball_Mouse(&ball, vNow); // and pass it to the Ball functions Ball_BeginDrag(&ball); // start dragging while (whichButtons) // loop until drop the mouse { snooze(20 * 1000); // snooze for 20 C++ snprintf函数代码示例 C++ snmp_synch_response函数代码示例
|