这篇教程C++ system_time函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中system_time函数的典型用法代码示例。如果您正苦于以下问题:C++ system_time函数的具体用法?C++ system_time怎么用?C++ system_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了system_time函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: rtl8139_initint rtl8139_init(rtl8139 *rtl){ bigtime_t time; int err = -1; addr_t temp; dprintf("rtl8139_init: rtl %p/n", rtl); rtl->region = vm_map_physical_memory(vm_get_kernel_aspace_id(), "rtl8139_region", (void **)&rtl->virt_base, REGION_ADDR_ANY_ADDRESS, rtl->phys_size, LOCK_KERNEL|LOCK_RW, rtl->phys_base); if(rtl->region < 0) { dprintf("rtl8139_init: error creating memory mapped region/n"); err = -1; goto err; } dprintf("rtl8139 mapped at address 0x%lx/n", rtl->virt_base); // try to reset the device time = system_time(); RTL_WRITE_8(rtl, RT_CHIPCMD, RT_CMD_RESET); do { thread_snooze(10000); // 10ms if(system_time() - time > 1000000) { err = -1; goto err1; } } while((RTL_READ_8(rtl, RT_CHIPCMD) & RT_CMD_RESET)); // create a rx and tx buf rtl->rxbuf_region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "rtl8139_rxbuf", (void **)&rtl->rxbuf, REGION_ADDR_ANY_ADDRESS, 64*1024 + 16, REGION_WIRING_WIRED_CONTIG, LOCK_KERNEL|LOCK_RW); rtl->txbuf_region = vm_create_anonymous_region(vm_get_kernel_aspace_id(), "rtl8139_txbuf", (void **)&rtl->txbuf, REGION_ADDR_ANY_ADDRESS, 8*1024, REGION_WIRING_WIRED, LOCK_KERNEL|LOCK_RW); // set up the transmission buf and sem rtl->tx_sem = sem_create(4, "rtl8139_txsem"); mutex_init(&rtl->lock, "rtl8139"); rtl->txbn = 0; rtl->last_txbn = 0; rtl->rx_sem = sem_create(0, "rtl8139_rxsem"); rtl->reg_spinlock = 0; // set up the interrupt handler int_set_io_interrupt_handler(rtl->irq, &rtl8139_int, rtl, "rtl8139"); // read the mac address rtl->mac_addr[0] = RTL_READ_8(rtl, RT_IDR0); rtl->mac_addr[1] = RTL_READ_8(rtl, RT_IDR0 + 1); rtl->mac_addr[2] = RTL_READ_8(rtl, RT_IDR0 + 2); rtl->mac_addr[3] = RTL_READ_8(rtl, RT_IDR0 + 3); rtl->mac_addr[4] = RTL_READ_8(rtl, RT_IDR0 + 4); rtl->mac_addr[5] = RTL_READ_8(rtl, RT_IDR0 + 5); dprintf("rtl8139: mac addr %x:%x:%x:%x:%x:%x/n", rtl->mac_addr[0], rtl->mac_addr[1], rtl->mac_addr[2], rtl->mac_addr[3], rtl->mac_addr[4], rtl->mac_addr[5]); // enable writing to the config registers RTL_WRITE_8(rtl, RT_CFG9346, 0xc0); // reset config 1 RTL_WRITE_8(rtl, RT_CONFIG1, 0); // Enable receive and transmit functions RTL_WRITE_8(rtl, RT_CHIPCMD, RT_CMD_RX_ENABLE | RT_CMD_TX_ENABLE); // Set Rx FIFO threashold to 256, Rx size to 64k+16, 256 byte DMA burst RTL_WRITE_32(rtl, RT_RXCONFIG, 0x00009c00); // Set Tx 256 byte DMA burst RTL_WRITE_32(rtl, RT_TXCONFIG, 0x03000400); // Turn off lan-wake and set the driver-loaded bit RTL_WRITE_8(rtl, RT_CONFIG1, (RTL_READ_8(rtl, RT_CONFIG1) & ~0x30) | 0x20); // Enable FIFO auto-clear RTL_WRITE_8(rtl, RT_CONFIG4, RTL_READ_8(rtl, RT_CONFIG4) | 0x80); // go back to normal mode RTL_WRITE_8(rtl, RT_CFG9346, 0); // Setup RX buffers *(int *)rtl->rxbuf = 0; vm_get_page_mapping(vm_get_kernel_aspace_id(), rtl->rxbuf, &temp); dprintf("rx buffer will be at 0x%lx/n", temp); RTL_WRITE_32(rtl, RT_RXBUF, temp); // Setup TX buffers dprintf("tx buffer (virtual) is at 0x%lx/n", rtl->txbuf); *(int *)rtl->txbuf = 0; vm_get_page_mapping(vm_get_kernel_aspace_id(), rtl->txbuf, &temp); RTL_WRITE_32(rtl, RT_TXADDR0, temp); RTL_WRITE_32(rtl, RT_TXADDR1, temp + 2*1024); dprintf("first half of txbuf at 0x%lx/n", temp); *(int *)(rtl->txbuf + 4*1024) = 0; vm_get_page_mapping(vm_get_kernel_aspace_id(), rtl->txbuf + 4*1024, &temp); RTL_WRITE_32(rtl, RT_TXADDR2, temp); RTL_WRITE_32(rtl, RT_TXADDR3, temp + 2*1024); dprintf("second half of txbuf at 0x%lx/n", temp);//.........这里部分代码省略.........
开发者ID:HTshandou,项目名称:newos,代码行数:101,
示例2: timed_wait bool timed_wait(lock_type& m,xtime const& wait_until,predicate_type pred) { return timed_wait(m,system_time(wait_until),pred); }
开发者ID:3DJ,项目名称:ofxOgre,代码行数:4,
示例3: MakeFocusvoidBListView::MouseDown(BPoint point){ if (!IsFocus()) { MakeFocus(); Sync(); Window()->UpdateIfNeeded(); } BMessage* message = Looper()->CurrentMessage(); int32 index = IndexOf(point); // If the user double (or more) clicked within the current selection, // we don't change the selection but invoke the selection. // TODO: move this code someplace where it can be shared everywhere // instead of every class having to reimplement it, once some sane // API for it is decided. BPoint delta = point - fTrack->drag_start; bigtime_t sysTime; Window()->CurrentMessage()->FindInt64("when", &sysTime); bigtime_t timeDelta = sysTime - fTrack->last_click_time; bigtime_t doubleClickSpeed; get_click_speed(&doubleClickSpeed); bool doubleClick = false; if (timeDelta < doubleClickSpeed && fabs(delta.x) < kDoubleClickTresh && fabs(delta.y) < kDoubleClickTresh && fTrack->item_index == index) { doubleClick = true; } if (doubleClick && index >= fFirstSelected && index <= fLastSelected) { fTrack->drag_start.Set(INT32_MAX, INT32_MAX); Invoke(); return; } int32 modifiers; message->FindInt32("modifiers", &modifiers); if (!doubleClick) { fTrack->drag_start = point; fTrack->last_click_time = system_time(); fTrack->item_index = index; fTrack->was_selected = index >= 0 ? ItemAt(index)->IsSelected() : false; fTrack->try_drag = true; } if (index > -1) { if (fListType == B_MULTIPLE_SELECTION_LIST) { if (modifiers & B_SHIFT_KEY) { // select entire block // TODO: maybe review if we want it like in Tracker // (anchor item) Select(min_c(index, fFirstSelected), max_c(index, fLastSelected)); } else { if (modifiers & B_COMMAND_KEY) { // toggle selection state of clicked item (like in Tracker) // toggle selection state of clicked item if (ItemAt(index)->IsSelected()) Deselect(index); else Select(index, true); } else Select(index); } } else { // toggle selection state of clicked item if ((modifiers & B_COMMAND_KEY) && ItemAt(index)->IsSelected()) Deselect(index); else Select(index); } } else if ((modifiers & B_COMMAND_KEY) == 0) DeselectAll();}
开发者ID:RAZVOR,项目名称:haiku,代码行数:78,
示例4: out_writestatic ssize_t out_write(struct audio_stream_out *stream, const void* buffer, size_t bytes){ struct astream_out *out = (struct astream_out *)stream; int ret; size_t frames_total = bytes / sizeof(uint32_t); // always stereo 16 bit uint32_t *buf = (uint32_t *)buffer; size_t frames_written = 0; pthread_mutex_lock(&out->buf_lock); pthread_mutex_lock(&out->lock); if (!out->bt_enabled || out->suspended) { LOGV("a2dp write: bluetooth disabled bt_en %d, suspended %d", out->bt_enabled, out->suspended); ret = -1; goto err_bt_disabled; } if (out->standby) { acquire_wake_lock(PARTIAL_WAKE_LOCK, A2DP_WAKE_LOCK_NAME); out->standby = false; out->last_write_time = system_time(); out->buf_rd_idx = 0; out->buf_wr_idx = 0; out->buf_frames_ready = 0; } ret = _out_init_locked(out, NULL); if (ret < 0) { goto err_init; } pthread_mutex_unlock(&out->lock); if(isToMono){ int16_t mono; int16_t *stereoData = (int16_t *)buffer; uint16_t i; for(i = 0; i<bytes/4; i++) { // to Mono mono = (int16_t)(((int32_t)*(stereoData+2*i) + (int32_t)*(stereoData+2*i+1)) >> 1); // to Stereo again *(stereoData+2*i) = *(stereoData+2*i+1) = mono; } } while (frames_written < frames_total) { size_t frames = _out_frames_available_locked(out); if (frames == 0) { int ret = pthread_cond_timeout_np(&out->buf_cond, &out->buf_lock, BUF_WRITE_AVAILABILITY_TIMEOUT_MS); if (ret != 0) { pthread_mutex_lock(&out->lock); goto err_write; } frames = _out_frames_available_locked(out); } if (frames > frames_total - frames_written) { frames = frames_total - frames_written; } memcpy(out->buf + out->buf_wr_idx, buf + frames_written, frames * sizeof(uint32_t)); frames_written += frames; _out_inc_wr_idx_locked(out, frames); pthread_mutex_lock(&out->lock); if (out->standby) { goto err_write; } pthread_mutex_unlock(&out->lock); } pthread_mutex_unlock(&out->buf_lock); return bytes;/* out->lock must be locked and out->buf_lock unlocked when jumping here */err_write:err_init:err_bt_disabled: pthread_mutex_unlock(&out->buf_lock); LOGV("!!!! write error"); out_standby_stream_locked(out); pthread_mutex_unlock(&out->lock); /* XXX: simulate audio output timing in case of error?!?! */ usleep(out->buffer_duration_us); return ret;}
开发者ID:cmotc,项目名称:schs738c-external_bluetooth,代码行数:87,
示例5: timed_lock bool timed_lock(boost::xtime const & absolute_time) { return timed_lock(system_time(absolute_time)); }
开发者ID:Axitonium,项目名称:sourcesdkpython,代码行数:4,
示例6: system_time void Timer::reset () { this->_last = system_time(); this->_total = 0.0; }
开发者ID:DerDolch,项目名称:dream,代码行数:4,
示例7: MakeFocusvoidBListView::MouseDown(BPoint where){ if (!IsFocus()) { MakeFocus(); Sync(); Window()->UpdateIfNeeded(); } BMessage* message = Looper()->CurrentMessage(); int32 index = IndexOf(where); int32 buttons = 0; if (message != NULL) message->FindInt32("buttons", &buttons); int32 modifiers = 0; if (message != NULL) message->FindInt32("modifiers", &modifiers); // If the user double (or more) clicked within the current selection, // we don't change the selection but invoke the selection. // TODO: move this code someplace where it can be shared everywhere // instead of every class having to reimplement it, once some sane // API for it is decided. BPoint delta = where - fTrack->drag_start; bigtime_t sysTime; Window()->CurrentMessage()->FindInt64("when", &sysTime); bigtime_t timeDelta = sysTime - fTrack->last_click_time; bigtime_t doubleClickSpeed; get_click_speed(&doubleClickSpeed); bool doubleClick = false; if (timeDelta < doubleClickSpeed && fabs(delta.x) < kDoubleClickThreshold && fabs(delta.y) < kDoubleClickThreshold && fTrack->item_index == index) { doubleClick = true; } if (doubleClick && index >= fFirstSelected && index <= fLastSelected) { fTrack->drag_start.Set(INT32_MAX, INT32_MAX); Invoke(); return BView::MouseDown(where); } if (!doubleClick) { fTrack->drag_start = where; fTrack->last_click_time = system_time(); fTrack->item_index = index; fTrack->was_selected = index >= 0 ? ItemAt(index)->IsSelected() : false; fTrack->try_drag = true; MouseDownThread<BListView>::TrackMouse(this, &BListView::_DoneTracking, &BListView::_Track); } if (index >= 0) { if (fListType == B_MULTIPLE_SELECTION_LIST) { if ((modifiers & B_SHIFT_KEY) != 0) { // select entire block // TODO: maybe review if we want it like in Tracker // (anchor item) if (index >= fFirstSelected && index < fLastSelected) { // clicked inside of selected items block, deselect all // but from the first selected item to the clicked item DeselectExcept(fFirstSelected, index); } else { Select(std::min(index, fFirstSelected), std::max(index, fLastSelected)); } } else { if ((modifiers & B_COMMAND_KEY) != 0) { // toggle selection state of clicked item (like in Tracker) // toggle selection state of clicked item if (ItemAt(index)->IsSelected()) Deselect(index); else Select(index, true); } else Select(index); } } else { // toggle selection state of clicked item if ((modifiers & B_COMMAND_KEY) != 0 && ItemAt(index)->IsSelected()) Deselect(index); else Select(index); } } else if ((modifiers & B_COMMAND_KEY) == 0) DeselectAll(); BView::MouseDown(where);}
开发者ID:mmuman,项目名称:haiku,代码行数:94,
示例8: SDL_GetTicksUint32 SDL_GetTicks(void){ return((system_time()-start)/1000);}
开发者ID:0-14N,项目名称:NDroid,代码行数:4,
示例9: Fake_TrueCurrentTimeMillisJNIEXPORT jlong JNICALL Fake_TrueCurrentTimeMillis(JNIEnv* env, jclass jc) { return system_time();}
开发者ID:akula1001,项目名称:jvmfaketime,代码行数:3,
示例10: D_METHOD//.........这里部分代码省略......... D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_RUNMODE_CHANGED)/n")); int32 mode; if (message->FindInt32("run_mode", &mode) == B_OK) { _changeRunModeForSelection(static_cast<uint32>(mode)); } break; } case M_LAYOUT_CHANGED: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_LAYOUT_CHANGED)/n")); layout_t layout; if (message->FindInt32("layout", (int32*)&layout) == B_OK) { if (layout != m_layout) { layoutChanged(layout); updateDataRect(); Invalidate(); } } break; } case M_NODE_START_TIME_SOURCE: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_START_TIME_SOURCE)/n")); int32 id; if(message->FindInt32("nodeID", &id) < B_OK) break; NodeRef* ref; if(manager->getNodeRef(id, &ref) < B_OK) break; bigtime_t when = system_time(); status_t err = manager->roster->StartTimeSource(ref->node(), when); if(err < B_OK) { PRINT(( "! StartTimeSource(%ld): '%s'/n", ref->id(), strerror(err))); } break; } case M_NODE_STOP_TIME_SOURCE: { D_MESSAGE(("MediaRoutingView::MessageReceived(M_NODE_STOP_TIME_SOURCE)/n")); int32 id; if(message->FindInt32("nodeID", &id) < B_OK) break; NodeRef* ref; if(manager->getNodeRef(id, &ref) < B_OK) break; bigtime_t when = system_time(); status_t err = manager->roster->StopTimeSource(ref->node(), when); if(err < B_OK) { PRINT(( "! StopTimeSource(%ld): '%s'/n", ref->id(), strerror(err))); } break; } case M_NODE_TWEAK_PARAMETERS: { D_MESSAGE((" -> M_NODE_TWEAK_PARAMETERS/n")); _openParameterWindowsForSelection(); break; }
开发者ID:HaikuArchives,项目名称:Cortex,代码行数:67,
示例11: SDL_StartTicksvoid SDL_StartTicks(void){ /* Set first ticks value */ start = system_time();}
开发者ID:0-14N,项目名称:NDroid,代码行数:5,
示例12: timed_wait bool timed_wait(unique_lock<mutex>& m,xtime const& wait_until,predicate_type pred) { return timed_wait(m,system_time(wait_until),pred); }
开发者ID:InstitutoDOr,项目名称:FriendENGINE,代码行数:4,
示例13: rvoidMainWin::MouseDown(BMessage *msg){ BPoint screen_where; uint32 buttons = msg->FindInt32("buttons"); // On Zeta, only "screen_where" is relyable, "where" and "be:view_where" // seem to be broken if (B_OK != msg->FindPoint("screen_where", &screen_where)) { // Workaround for BeOS R5, it has no "screen_where" fVideoView->GetMouse(&screen_where, &buttons, false); fVideoView->ConvertToScreen(&screen_where); }// msg->PrintToStream();// if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) { if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) { BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); if (r.Contains(fMouseDownMousePos)) { PostMessage(M_TOGGLE_FULLSCREEN); return; } } if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) { BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); if (r.Contains(fMouseDownMousePos)) { PostMessage(M_TOGGLE_NO_BORDER_NO_MENU); return; } }/* // very broken in Zeta: fMouseDownMousePos = fVideoView->ConvertToScreen( msg->FindPoint("where"));*/ fMouseDownMousePos = screen_where; fMouseDownWindowPos = Frame().LeftTop(); if (buttons == 1 && !fIsFullscreen) { // start mouse tracking fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY /* | B_LOCK_WINDOW_FOCUS */); fMouseDownTracking = true; } // pop up a context menu if right mouse button is down for 200 ms if ((buttons & 2) == 0) return; bigtime_t start = system_time(); bigtime_t delay = 200000; BPoint location; do { fVideoView->GetMouse(&location, &buttons); if ((buttons & 2) == 0) break; snooze(1000); } while (system_time() - start < delay); if (buttons & 2) ShowContextMenu(screen_where);}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:68,
示例14: keyboard_handle_intstatic int32keyboard_handle_int(ps2_dev *dev){ enum emergency_keys { EMERGENCY_LEFT_ALT = 0x01, EMERGENCY_RIGHT_ALT = 0x02, EMERGENCY_SYS_REQ = 0x04, }; static int emergencyKeyStatus = 0; at_kbd_io keyInfo; uint8 scancode = dev->history[0].data; if (atomic_and(&sKeyboardOpenMask, 1) == 0) return B_HANDLED_INTERRUPT; // TODO: Handle braindead "pause" key special case if (scancode == EXTENDED_KEY) { sIsExtended = true;// TRACE("Extended key/n"); return B_HANDLED_INTERRUPT; }// TRACE("scancode: %x/n", scancode); if ((scancode & 0x80) != 0) { keyInfo.is_keydown = false; scancode &= 0x7f; } else keyInfo.is_keydown = true; if (sIsExtended) { scancode |= 0x80; sIsExtended = false; } // Handle emergency keys if (scancode == LEFT_ALT_KEY || scancode == RIGHT_ALT_KEY) { // left or right alt-key pressed if (keyInfo.is_keydown) { emergencyKeyStatus |= scancode == LEFT_ALT_KEY ? EMERGENCY_LEFT_ALT : EMERGENCY_RIGHT_ALT; } else { emergencyKeyStatus &= ~(scancode == LEFT_ALT_KEY ? EMERGENCY_LEFT_ALT : EMERGENCY_RIGHT_ALT); } } else if (scancode == SYS_REQ_KEY) { if (keyInfo.is_keydown) emergencyKeyStatus |= EMERGENCY_SYS_REQ; else emergencyKeyStatus &= EMERGENCY_SYS_REQ; } else if (emergencyKeyStatus > EMERGENCY_SYS_REQ && debug_emergency_key_pressed(kUnshiftedKeymap[scancode])) { static const int kKeys[] = {LEFT_ALT_KEY, RIGHT_ALT_KEY, SYS_REQ_KEY}; int i; // we probably have lost some keys, so reset our key states emergencyKeyStatus = 0; // send key ups for alt-sysreq keyInfo.timestamp = system_time(); keyInfo.is_keydown = false; for (i = 0; i < sizeof(kKeys) / sizeof(kKeys[0]); i++) { keyInfo.scancode = kKeys[i]; if (packet_buffer_write(sKeyBuffer, (uint8 *)&keyInfo, sizeof(keyInfo)) != 0) release_sem_etc(sKeyboardSem, 1, B_DO_NOT_RESCHEDULE); } return B_HANDLED_INTERRUPT; } keyInfo.timestamp = dev->history[0].time; keyInfo.scancode = scancode; if (packet_buffer_write(sKeyBuffer, (uint8 *)&keyInfo, sizeof(keyInfo)) == 0) { // If there is no space left in the buffer, we drop this key stroke. We // avoid dropping old key strokes, to not destroy what already was // typed. return B_HANDLED_INTERRUPT; } release_sem_etc(sKeyboardSem, 1, B_DO_NOT_RESCHEDULE); return B_INVOKE_SCHEDULER;}
开发者ID:mmanley,项目名称:Antares,代码行数:87,
示例15: callout_threadstatic status_tcallout_thread(void* /*data*/){ status_t status = B_OK; do { bigtime_t timeout = B_INFINITE_TIMEOUT; if (status == B_TIMED_OUT || status == B_OK) { // scan timers for new timeout and/or execute a timer mutex_lock(&sLock); while (true) { struct callout* c = (callout*)list_get_next_item(&sTimers, c); if (c == NULL) break; if (c->due < system_time()) { struct mtx *mutex = c->c_mtx; // execute timer list_remove_item(&sTimers, c); c->due = -1; sCurrentCallout = c; mutex_unlock(&sLock); if (mutex != NULL) mtx_lock(mutex); c->c_func(c->c_arg); if (mutex != NULL) mtx_unlock(mutex); mutex_lock(&sLock); sCurrentCallout = NULL; c = NULL; // restart scanning as we unlocked the list } else { // calculate new timeout if (c->due < timeout) timeout = c->due; } } sTimeout = timeout; mutex_unlock(&sLock); } status = acquire_sem_etc(sWaitSem, 1, B_ABSOLUTE_TIMEOUT, timeout); // the wait sem normally can't be acquired, so we // have to look at the status value the call returns: // // B_OK - a new timer has been added or canceled // B_TIMED_OUT - look for timers to be executed // B_BAD_SEM_ID - we are asked to quit } while (status != B_BAD_SEM_ID); return B_OK;}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:62,
示例16: ext2_createstatic status_text2_create(fs_volume* _volume, fs_vnode* _directory, const char* name, int openMode, int mode, void** _cookie, ino_t* _vnodeID){ Volume* volume = (Volume*)_volume->private_volume; Inode* directory = (Inode*)_directory->private_node; TRACE("ext2_create()/n"); if (volume->IsReadOnly()) return B_READ_ONLY_DEVICE; if (!directory->IsDirectory()) return B_BAD_TYPE; TRACE("ext2_create(): Creating cookie/n"); // Allocate cookie file_cookie* cookie = new(std::nothrow) file_cookie; if (cookie == NULL) return B_NO_MEMORY; ObjectDeleter<file_cookie> cookieDeleter(cookie); cookie->open_mode = openMode; cookie->last_size = 0; cookie->last_notification = system_time(); TRACE("ext2_create(): Starting transaction/n"); Transaction transaction(volume->GetJournal()); TRACE("ext2_create(): Creating inode/n"); Inode* inode; bool created; status_t status = Inode::Create(transaction, directory, name, S_FILE | (mode & S_IUMSK), openMode, EXT2_TYPE_FILE, &created, _vnodeID, &inode, &gExt2VnodeOps); if (status != B_OK) return status; TRACE("ext2_create(): Created inode/n"); if ((openMode & O_NOCACHE) != 0) { status = inode->DisableFileCache(); if (status != B_OK) return status; } entry_cache_add(volume->ID(), directory->ID(), name, *_vnodeID); status = transaction.Done(); if (status != B_OK) { entry_cache_remove(volume->ID(), directory->ID(), name); return status; } *_cookie = cookie; cookieDeleter.Detach(); if (created) notify_entry_created(volume->ID(), directory->ID(), name, *_vnodeID); return B_OK;}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:65,
示例17: system_timestatus_tSeekSlider::Invoke(BMessage* message){ fLastTrackTime = system_time(); return BSlider::Invoke(message);}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:6,
示例18: IsActive bool IsActive() const { return fActiveUntil >= system_time(); }
开发者ID:DonCN,项目名称:haiku,代码行数:1,
示例19: lockerstatus_tFormatManager::MakeFormatFor(const media_format_description* descriptions, int32 descriptionCount, media_format& format, uint32 flags, void* _reserved){ BAutolock locker(fLock); int codec = fNextCodecID; switch (format.type) { case B_MEDIA_RAW_AUDIO: case B_MEDIA_RAW_VIDEO: // no marker break; case B_MEDIA_ENCODED_AUDIO: if (format.u.encoded_audio.encoding == 0) { format.u.encoded_audio.encoding = (media_encoded_audio_format::audio_encoding) fNextCodecID++; } else { UNIMPLEMENTED(); // TODO: Check the encoding and the format passed in for // compatibility and return B_MISMATCHED_VALUES if incompatible // or perhaps something else based on flags? } break; case B_MEDIA_ENCODED_VIDEO: if (format.u.encoded_video.encoding == 0) { format.u.encoded_video.encoding = (media_encoded_video_format::video_encoding) fNextCodecID++; } else { UNIMPLEMENTED(); // TODO: Check the encoding and the format passed in for // compatibility and return B_MISMATCHED_VALUES if incompatible // or perhaps something else based on flags? } break; case B_MEDIA_MULTISTREAM: if (format.u.multistream.format == 0) { format.u.multistream.format = fNextCodecID++; } else { UNIMPLEMENTED(); // TODO: Check the encoding and the format passed in for // compatibility and return B_MISMATCHED_VALUES if incompatible // or perhaps something else based on flags? } break; default: // nothing to do return B_OK; } fLastUpdate = system_time(); status_t result = B_OK; // TODO: Support "flags" (B_SET_DEFAULT, B_EXCLUSIVE, B_NO_MERGE)! for (int32 i = 0; i < descriptionCount; i++) { meta_format* metaFormat = new(std::nothrow) meta_format( descriptions[i], format, codec); if (metaFormat == NULL || !fList.BinaryInsert(metaFormat, meta_format::Compare)) { delete metaFormat; result = B_NO_MEMORY; break; } } return B_OK;}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:67,
示例20: pthread_mutex_lockstatic void *_out_buf_thread_func(void *context){ struct astream_out *out = (struct astream_out *)context; pthread_mutex_lock(&out->buf_lock); while(!out->buf_thread_exit) { size_t frames; frames = _out_frames_ready_locked(out); while (frames && !out->buf_thread_exit) { int retries = MAX_WRITE_RETRIES; uint64_t now; uint32_t elapsed_us; while (frames > 0 && !out->buf_thread_exit) { int ret; uint32_t buffer_duration_us; /* PCM format is always 16bit stereo */ size_t bytes = frames * sizeof(uint32_t); if (bytes > out->buffer_size) { bytes = out->buffer_size; } pthread_mutex_lock(&out->lock); if (out->standby) { /* abort and clear all pending frames if standby requested */ pthread_mutex_unlock(&out->lock); frames = _out_frames_ready_locked(out); _out_inc_rd_idx_locked(out, frames); goto wait; } /* indicate to out_standby_stream_locked() that a2dp_write() is active */ out->write_busy = true; pthread_mutex_unlock(&out->lock); pthread_mutex_unlock(&out->buf_lock); ret = a2dp_write(out->data, out->buf + out->buf_rd_idx, bytes); /* clear write_busy condition */ pthread_mutex_lock(&out->buf_lock); pthread_mutex_lock(&out->lock); out->write_busy = false; pthread_cond_signal(&out->write_cond); pthread_mutex_unlock(&out->lock); if (ret < 0) { LOGE("%s: a2dp_write failed (%d)/n", __func__, ret); /* skip pending frames in case of write error */ _out_inc_rd_idx_locked(out, frames); break; } else if (ret == 0) { if (retries-- == 0) { /* skip pending frames in case of multiple time out */ _out_inc_rd_idx_locked(out, frames); break; } continue; } ret /= sizeof(uint32_t); _out_inc_rd_idx_locked(out, ret); frames -= ret; /* XXX: PLEASE FIX ME!!!! */ /* if A2DP sink runs abnormally fast, sleep a little so that * audioflinger mixer thread does no spin and starve other threads. */ /* NOTE: It is likely that the A2DP headset is being disconnected */ now = system_time(); elapsed_us = (now - out->last_write_time) / 1000UL; buffer_duration_us = ((ret * 1000) / out->sample_rate) * 1000; if (elapsed_us < (buffer_duration_us / 4)) { LOGV("A2DP sink runs too fast"); usleep(buffer_duration_us - elapsed_us); } out->last_write_time = now; } frames = _out_frames_ready_locked(out); }wait: if (!out->buf_thread_exit) { pthread_cond_wait(&out->buf_cond, &out->buf_lock); } } pthread_mutex_unlock(&out->buf_lock); return NULL;}
开发者ID:cmotc,项目名称:schs738c-external_bluetooth,代码行数:89,
示例21: printfvoid SnowView::Calc(){ int i; uint32 cw = fCurrentWorkspace; /* check if the parent changed size */ BRect pFrame = fCachedParent->Frame(); if (fCachedWsWidth != pFrame.Width() || fCachedWsHeight != pFrame.Height()) { fCachedWsWidth = pFrame.IntegerWidth(); fCachedWsHeight = pFrame.IntegerHeight(); printf("BSnow: Parent resized to %" B_PRId32 " %" B_PRId32 "/n", fCachedWsWidth, fCachedWsHeight); fFallenReg->MakeEmpty(); /* remove all the fallen snow */ ResizeTo(pFrame.IntegerWidth(), pFrame.IntegerHeight()); fDragger->MoveTo(pFrame.IntegerWidth()-7, pFrame.IntegerHeight()-7); } /* make new flakes */ for (i=0; i<fNumFlakes; i++) { if (fFlakes[cw][i].weight == 0) { fFlakes[cw][i].weight = ((float)(rand() % WEIGHT_SPAN)) / WEIGHT_GRAN; fFlakes[cw][i].weight = MAX(fFlakes[cw][i].weight, 0.5); fFlakes[cw][i].pos.y = rand() % 5 - 2; fFlakes[cw][i].pos.x = (rand()%(fCachedWsWidth+2*fCachedWsHeight))-fCachedWsHeight; if (fFlakes[cw][i].pos.x < -10) { fFlakes[cw][i].pos.y = -fFlakes[cw][i].pos.x; if (fWind > 0) fFlakes[cw][i].pos.x = 0; else fFlakes[cw][i].pos.x = fCachedWsWidth; } if (fFlakes[cw][i].pos.x > fCachedWsWidth+10) { fFlakes[cw][i].pos.y = fFlakes[cw][i].pos.x - fCachedWsWidth; if (fWind > 0) fFlakes[cw][i].pos.x = 0; else fFlakes[cw][i].pos.x = fCachedWsWidth; } } } /* like a candle in the wind... */ if (fWindDuration < system_time()) { fWindDuration = system_time() + ((((bigtime_t)rand())*1000) % WIND_MAX_DURATION); fWind = (rand() % WIND_SPAN) - WIND_SPAN/2; printf("BSnow: wind change: %f/n", fWind); } // if (fFallenView->LockLooperWithTimeout(5000)) {// if (fFallenBmp) {// uint8 *fallenBits = (uint8 *)fFallenBmp->Bits(); BRegion desktopReg; GetClippingRegion(&desktopReg); /* let's add some gravity and wind */ for (i=0; i<fNumFlakes; i++) { float yinc; if (fFlakes[cw][i].weight == 0) continue; fFlakes[cw][i].opos = fFlakes[cw][i].pos; yinc = fFlakes[cw][i].weight - (rand() % 3); yinc = MAX(yinc, 0.5); fFlakes[cw][i].pos.y += yinc;// if (fFlakes[cw][i].pos.y > (fCachedWsHeight-FALLEN_HEIGHT)) { bool fallen = false; bool keepfalling = false; /* fallen on the flour */ if (fFlakes[cw][i].pos.y > fCachedWsHeight-2) fallen = true; /* fallon on another fallen flake */ else if (fFallenReg->Intersects(BRect(fFlakes[cw][i].pos - BPoint(0,1), fFlakes[cw][i].pos + BPoint(0,1)))) { /* don't accumulate too much */ if ((fFlakes[cw][i].pos.y > fCachedWsHeight-30) || !desktopReg.Intersects( BRect(fFlakes[cw][i].pos + BPoint(0,6), fFlakes[cw][i].pos + BPoint(0,10)))) fallen = true; /* fallen on a window */ } else if (!desktopReg.Intersects( BRect(fFlakes[cw][i].pos + BPoint(-1,-1-2), fFlakes[cw][i].pos + BPoint(1,1-1))) && desktopReg.Intersects( BRect(fFlakes[cw][i].pos + BPoint(-1,-1-3), fFlakes[cw][i].pos + BPoint(1,1-3)))) { //printf("fallen3 @ %f %f/n", fFlakes[cw][i].pos.x, fFlakes[cw][i].pos.y); fFlakes[cw][i].pos = fFlakes[cw][i].opos; fallen = true; keepfalling = true; /* but keep one falling */ } /* else if (fallenBits[ (long)(fFlakes[cw][i].pos.y * fFallenBmp->BytesPerRow() + fFlakes[cw][i].pos.y - (fCachedWsHeight-FALLEN_HEIGHT)) ] != B_TRANSPARENT_MAGIC_CMAP8) {//.........这里部分代码省略.........
开发者ID:naveedasmat,项目名称:haiku,代码行数:101,
示例22: real_time_clockuint32real_time_clock(void){ return (__arch_get_system_time_offset(sRealTimeData) + system_time()) / 1000000;}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:6,
示例23: switchboolRemoteEventStream::EventReceived(RemoteMessage& message){ uint16 code = message.Code(); uint32 what = 0; switch (code) { case RP_MOUSE_MOVED: what = B_MOUSE_MOVED; break; case RP_MOUSE_DOWN: what = B_MOUSE_DOWN; break; case RP_MOUSE_UP: what = B_MOUSE_UP; break; case RP_MOUSE_WHEEL_CHANGED: what = B_MOUSE_WHEEL_CHANGED; break; case RP_KEY_DOWN: what = B_KEY_DOWN; break; case RP_KEY_UP: what = B_KEY_UP; break; case RP_MODIFIERS_CHANGED: what = B_MODIFIERS_CHANGED; break; } if (what == 0) return false; BMessage* event = new BMessage(what); if (event == NULL) return false; event->AddInt64("when", system_time()); switch (code) { case RP_MOUSE_MOVED: case RP_MOUSE_DOWN: case RP_MOUSE_UP: { message.Read(fMousePosition); if (code != RP_MOUSE_MOVED) message.Read(fMouseButtons); event->AddPoint("where", fMousePosition); event->AddInt32("buttons", fMouseButtons); event->AddInt32("modifiers", fModifiers); if (code == RP_MOUSE_DOWN) { int32 clicks; if (message.Read(clicks) == B_OK) event->AddInt32("clicks", clicks); } if (code == RP_MOUSE_MOVED) fLatestMouseMovedEvent = event; break; } case RP_MOUSE_WHEEL_CHANGED: { float xDelta, yDelta; message.Read(xDelta); message.Read(yDelta); event->AddFloat("be:wheel_delta_x", xDelta); event->AddFloat("be:wheel_delta_y", yDelta); break; } case RP_KEY_DOWN: case RP_KEY_UP: { int32 numBytes; if (message.Read(numBytes) != B_OK) break; char* bytes = (char*)malloc(numBytes + 1); if (bytes == NULL) break; if (message.ReadList(bytes, numBytes) != B_OK) break; for (int32 i = 0; i < numBytes; i++) event->AddInt8("byte", (int8)bytes[i]); bytes[numBytes] = 0; event->AddData("bytes", B_STRING_TYPE, bytes, numBytes + 1, false); event->AddInt32("modifiers", fModifiers); int32 rawChar; if (message.Read(rawChar) == B_OK) event->AddInt32("raw_char", rawChar); int32 key; if (message.Read(key) == B_OK) event->AddInt32("key", key);//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,
示例24: real_time_clock_usecsbigtime_treal_time_clock_usecs(void){ return __arch_get_system_time_offset(sRealTimeData) + system_time();}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:5,
示例25: timer_current_timevoid timer_current_time(tm_time_t &t){ t = system_time();}
开发者ID:AlexandreCo,项目名称:macemu,代码行数:4,
示例26: system_timevoidBStopWatch::Resume(){ if (fSuspendTime) fStart = system_time() - fSuspendTime - fStart;}
开发者ID:mariuz,项目名称:haiku,代码行数:6,
注:本文中的system_time函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ systick_counter_enable函数代码示例 C++ system_os_task函数代码示例 |