本文整理汇总了C++中sendEvent函数的典型用法代码示例。如果您正苦于以下问题:C++ sendEvent函数的具体用法?C++ sendEvent怎么用?C++ sendEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendEvent函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sendEvent
void PluginWidgetAndroid::exitFullScreen(bool pluginInitiated) {
if (!m_isFullScreen || !m_embeddedView) {
return;
}
// remove the full screen surface from the view hierarchy
if (pluginInitiated) {
m_core->hideFullScreenPlugin();
}
// add the embedded view back
if (m_drawingModel != kOpenGL_ANPDrawingModel)
m_core->updateSurface(m_embeddedView, m_pluginWindow->x, m_pluginWindow->y,
m_pluginWindow->width, m_pluginWindow->height);
// send event to notify plugin of full screen change
ANPEvent event;
SkANP::InitEvent(&event, kLifecycle_ANPEventType);
event.data.lifecycle.action = kExitFullScreen_ANPLifecycleAction;
sendEvent(event);
m_isFullScreen = false;
}
开发者ID:AndDiSa,项目名称:platform_external_webkit,代码行数:23,代码来源:PluginWidgetAndroid.cpp
示例2: updateScreenShape
bool
COSXScreen::onDisplayChange()
{
// screen resolution may have changed. save old shape.
SInt32 xOld = m_x, yOld = m_y, wOld = m_w, hOld = m_h;
// update shape
updateScreenShape();
// do nothing if resolution hasn't changed
if (xOld != m_x || yOld != m_y || wOld != m_w || hOld != m_h) {
if (m_isPrimary) {
// warp mouse to center if off screen
if (!m_isOnScreen) {
warpCursor(m_xCenter, m_yCenter);
}
}
// send new screen info
sendEvent(m_events->forIPrimaryScreen().shapeChanged());
}
return true;
}
开发者ID:rakete,项目名称:synergy-foss,代码行数:24,代码来源:COSXScreen.cpp
示例3: Rect
void GUIListGadget::updateItem(GUIListItem* Item, dim::point2di &Pos)
{
if (!Item || !Item->getVisible())
return;
dim::rect2di Rect(
Rect_.Left, Pos.Y, Rect_.Right, Pos.Y + Item->getItemSize()
);
if (VertScroll_.getVisible())
Rect.Right -= SCROLLBAR_SIZE;
if (HorzScroll_.getVisible() && Rect.Bottom > Rect_.Bottom - SCROLLBAR_SIZE)
Rect.Bottom = Rect_.Bottom - SCROLLBAR_SIZE;
Pos.Y += Item->getItemSize();
/* Update current item */
if (mouseOver(Rect))
{
Item->isPicked_ = true;
if (mouseLeft())
{
SelectedItem_ = Item;
SGUIEvent Event;
{
Event.Object = EVENT_GADGET;
Event.Type = EVENT_ACTIVATE;
Event.Gadget = this;
Event.SubData = Item;
}
sendEvent(Event);
}
}
}
开发者ID:bekasov,项目名称:SoftPixelEngine,代码行数:36,代码来源:spGUIListGadget.cpp
示例4: n
//----------------------------------------------------------------
void GraphView::addNodesInternal(unsigned int nbAdded, const std::vector<node> *nodes) {
_nodes.reserve(_nodes.size() + nbAdded);
std::vector<node>::const_iterator it;
if (nodes)
it = nodes->begin();
else {
nodes = &getSuperGraph()->nodes();
it = nodes->begin() + nodes->size() - nbAdded;
}
std::vector<node>::const_iterator ite = nodes->end();
for (; it != ite; ++it) {
node n(*it);
assert(getRootImpl()->isElement(n));
_nodeData.set(n.id, new SGraphNodeData());
_nodes.add(n);
}
if (hasOnlookers())
sendEvent(GraphEvent(*this, GraphEvent::TLP_ADD_NODES, nbAdded));
}
开发者ID:tulip5,项目名称:tulip,代码行数:25,代码来源:GraphView.cpp
示例5: mTouch
//*************************************************************************
//
// mTouch -- simulates the multi touch protocol A sequence (see the Linux
// input protocol definition). Expects x,y coordinates
// followed by the finger id and the pressure. Finger ID is
// currently ignored. If pressure is > 0 then we assume this is
// a touch down event otherwise it is a touch up event which is
// signled by a empty MT and SYNC report.
//
//*************************************************************************
void mTouch ( int conn, int dev)
{
int x,y,s,f;
x = getInt (conn);
y = getInt (conn);
f = getInt (conn);
s = getInt (conn);
sendEvent (dev, EV_ABS, ABS_MT_POSITION_X, x);
sendEvent (dev, EV_ABS, ABS_MT_POSITION_Y, y);
sendEvent (dev, EV_KEY, BTN_TOUCH, (s>0));
sendEvent (dev, EV_SYN, SYN_MT_REPORT, 0);
if (s == 0)
{
sendEvent (dev, EV_SYN, SYN_MT_REPORT, 0);
sendEvent (dev, EV_SYN, SYN_REPORT, 0);
}
if (verbose) printf(" %d %d %d %d\n",x,y,f,s);
}
开发者ID:Topographic0cean,项目名称:src,代码行数:31,代码来源:touchd.c
示例6: UAVObjLoad
/**
* Load an object from the file system (SD card).
* A file with the name of the object will be opened.
* The object data can be saved using the UAVObjSave function.
* @param[in] obj The object handle.
* @param[in] instId The object instance
* @return 0 if success or -1 if failure
*/
int32_t UAVObjLoad(UAVObjHandle obj, uint16_t instId)
{
#if defined(PIOS_INCLUDE_FLASH_SECTOR_SETTINGS)
ObjectList *objEntry = (ObjectList *) obj;
if (objEntry == NULL)
return -1;
ObjectInstList *instEntry = getInstance(objEntry, instId);
if (instEntry == NULL)
return -1;
if (instEntry->data == NULL)
return -1;
// Fire event on success
if (PIOS_FLASHFS_ObjLoad(obj, instId, instEntry->data) == 0)
sendEvent(objEntry, instId, EV_UNPACKED);
else
return -1;
#endif
#if defined(PIOS_INCLUDE_SDCARD)
FILEINFO file;
ObjectList *objEntry;
UAVObjHandle loadedObj;
ObjectList *loadedObjEntry;
uint8_t filename[14];
// Check for file system availability
if (PIOS_SDCARD_IsMounted() == 0) {
return -1;
}
// Lock
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
// Cast to object
objEntry = (ObjectList *) obj;
// Get filename
objectFilename(objEntry, filename);
// Open file
if (PIOS_FOPEN_READ(filename, file)) {
xSemaphoreGiveRecursive(mutex);
return -1;
}
// Load object
loadedObj = UAVObjLoadFromFile(&file);
if (loadedObj == 0) {
PIOS_FCLOSE(file);
xSemaphoreGiveRecursive(mutex);
return -1;
}
// Check that the IDs match
loadedObjEntry = (ObjectList *) loadedObj;
if (loadedObjEntry->id != objEntry->id) {
PIOS_FCLOSE(file);
xSemaphoreGiveRecursive(mutex);
return -1;
}
// Done, close file and unlock
PIOS_FCLOSE(file);
xSemaphoreGiveRecursive(mutex);
#endif /* PIOS_INCLUDE_SDCARD */
return 0;
}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:76,代码来源:uavobjectmanager.c
示例7: notificationForWrapper
void NotificationPresenterClientQt::sendDisplayEvent(NotificationWrapper* wrapper)
{
Notification* notification = notificationForWrapper(wrapper);
if (notification)
sendEvent(notification, "show");
}
开发者ID:fmalita,项目名称:webkit,代码行数:6,代码来源:NotificationPresenterClientQt.cpp
示例8: LOGV
void MtpServer::sendObjectRemoved(MtpObjectHandle handle) {
LOGV("sendObjectRemoved %d\n", handle);
sendEvent(MTP_EVENT_OBJECT_REMOVED, handle);
}
开发者ID:28vicky,项目名称:platform_frameworks_base,代码行数:4,代码来源:MtpServer.cpp
示例9: UAVObjLoadFromFile
/**
* Load an object from the file system (SD card).
* @param[in] file File to read from
* @return The handle of the object loaded or NULL if a failure
*/
UAVObjHandle UAVObjLoadFromFile(FILEINFO * file)
{
#if defined(PIOS_INCLUDE_SDCARD)
uint32_t bytesRead;
ObjectList *objEntry;
ObjectInstList *instEntry;
uint32_t objId;
uint16_t instId;
UAVObjHandle obj;
// Check for file system availability
if (PIOS_SDCARD_IsMounted() == 0) {
return NULL;
}
// Lock
xSemaphoreTakeRecursive(mutex, portMAX_DELAY);
// Read the object ID
if (PIOS_FREAD(file, &objId, sizeof(objId), &bytesRead)) {
xSemaphoreGiveRecursive(mutex);
return NULL;
}
// Get the object
obj = UAVObjGetByID(objId);
if (obj == 0) {
xSemaphoreGiveRecursive(mutex);
return NULL;
}
objEntry = (ObjectList *) obj;
// Get the instance ID
instId = 0;
if (!objEntry->isSingleInstance) {
if (PIOS_FREAD
(file, &instId, sizeof(instId), &bytesRead)) {
xSemaphoreGiveRecursive(mutex);
return NULL;
}
}
// Get the instance information
instEntry = getInstance(objEntry, instId);
// If the instance does not exist create it and any other instances before it
if (instEntry == NULL) {
instEntry = createInstance(objEntry, instId);
if (instEntry == NULL) {
// Error, unlock and return
xSemaphoreGiveRecursive(mutex);
return NULL;
}
}
// Read the instance data
if (PIOS_FREAD
(file, instEntry->data, objEntry->numBytes, &bytesRead)) {
xSemaphoreGiveRecursive(mutex);
return NULL;
}
// Fire event
sendEvent(objEntry, instId, EV_UNPACKED);
// Unlock
xSemaphoreGiveRecursive(mutex);
return obj;
#else /* PIOS_INCLUDE_SDCARD */
return NULL;
#endif
}
开发者ID:LeeSaferite,项目名称:OpenPilot,代码行数:72,代码来源:uavobjectmanager.c
示例10: ignore_but_report_signals
//.........这里部分代码省略.........
eDebug("wait for driver eof timeout");
#if defined(__sh__) // Fix to ensure that event evtEOF is called at end of playbackl part 2/3
if (already_empty)
{
break;
}
else
{
already_empty = true;
continue;
}
#else
continue;
#endif
case 1:
eDebug("wait for driver eof ok");
break;
default:
eDebug("wait for driver eof aborted by signal");
/* Check m_stop after interrupted syscall. */
if (m_stop)
break;
continue;
}
}
if (m_stop)
break;
/* in stream_mode, we are sending EOF events
over and over until somebody responds.
in stream_mode, think of evtEOF as "buffer underrun occurred". */
sendEvent(evtEOF);
if (m_stream_mode)
{
eDebug("reached EOF, but we are in stream mode. delaying 1 second.");
sleep(1);
continue;
}
else if (++eofcount < 10)
{
eDebug("reached EOF, but the file may grow. delaying 1 second.");
sleep(1);
continue;
}
break;
} else
{
/* Write data to mux */
int buf_start = 0;
filterRecordData(m_buffer, buf_end);
while ((buf_start != buf_end) && !m_stop)
{
int w = write(m_fd_dest, m_buffer + buf_start, buf_end - buf_start);
if (w <= 0)
{
/* Check m_stop after interrupted syscall. */
if (m_stop) {
w = 0;
buf_start = 0;
buf_end = 0;
break;
}
开发者ID:Adga52,项目名称:enigma2,代码行数:67,代码来源:filepush.cpp
示例11: while
void ResourceManager::loop()
{
iMustStopLoop = false;
while( !iMustStopLoop )
{
_updateElapsedTime();
UpdateEvent updateEvent(this, iElapsedTime);
// The 'ResourceManager::loop()' function only updates the 'logical' objects. Renderers are updated
// using the 'Renderer::launch()' function. To draw a RenderTarget, use 'Renderer::registerTarget()' to
// enable it to drawing.
// This loop only updates every Windows, and every RenderSceneManager.
// First, we update every Windows objects.
WindowHolderList whlist = iWindowManager->getWindows();
if(whlist.empty() && iCloseBehaviour == CloseBehaviour::AllWindowClosed)
{
iMustStopLoop = true;
}
else
{
if( !whlist.empty() )
{
for(auto wholder : whlist)
{
if(wholder)
{
if(wholder->hasBeenClosed())
{
// Window has been closed, we can destroy it.
iWindowManager->remove(wholder->getName());
}
else
{
// For now , we have to lock the mutex here to be sure any operations are made
// within a valid mutex.
wholder->lockGuard();
wholder->onEvent(updateEvent);
wholder->unlockGuard();
iPerWindowBehaviours.call();
}
}
}
}
iLoopBehaviours.call();
}
// Update also the RenderScene's objects.
RenderSceneHolderList smhlist = iRenderSceneManager->getAll();
if( !smhlist.empty() )
{
for(auto smholder : smhlist)
{
if( smholder )
{
smholder->onEvent(updateEvent);
}
}
}
// Finally we send update event to every Listeners.
sendEvent(updateEvent);
}
}
开发者ID:luk2010,项目名称:GRE,代码行数:76,代码来源:ResourceManager.cpp
示例12: setIoPrio
//.........这里部分代码省略.........
}
if (errno == EINTR || errno == EBUSY || errno == EAGAIN)
continue;
if (errno == EOVERFLOW)
{
eWarning("OVERFLOW while playback?");
continue;
}
eDebug("eFilePushThread *read error* (%m) - not yet handled");
}
/* a read might be mis-aligned in case of a short read. */
int d = buf_end % m_blocksize;
if (d)
buf_end -= d;
if (buf_end == 0)
{
/* on EOF, try COMMITting once. */
if (m_send_pvr_commit)
{
struct pollfd pfd;
pfd.fd = m_fd_dest;
pfd.events = POLLIN;
switch (poll(&pfd, 1, 250)) // wait for 250ms
{
case 0:
eDebug("wait for driver eof timeout");
continue;
case 1:
eDebug("wait for driver eof ok");
break;
default:
eDebug("wait for driver eof aborted by signal");
/* Check m_stop after interrupted syscall. */
if (m_stop)
break;
continue;
}
}
if (m_stop)
break;
/* in stream_mode, we are sending EOF events
over and over until somebody responds.
in stream_mode, think of evtEOF as "buffer underrun occurred". */
sendEvent(evtEOF);
if (m_stream_mode)
{
eDebug("reached EOF, but we are in stream mode. delaying 1 second.");
sleep(1);
continue;
}
else if (++eofcount < 10)
{
eDebug("reached EOF, but the file may grow. delaying 1 second.");
sleep(1);
continue;
}
break;
} else
{
/* Write data to mux */
int buf_start = 0;
filterRecordData(m_buffer, buf_end);
while ((buf_start != buf_end) && !m_stop)
{
int w = write(m_fd_dest, m_buffer + buf_start, buf_end - buf_start);
if (w <= 0)
{
/* Check m_stop after interrupted syscall. */
if (m_stop) {
w = 0;
buf_start = 0;
buf_end = 0;
break;
}
if (w < 0 && (errno == EINTR || errno == EAGAIN || errno == EBUSY))
continue;
eDebug("eFilePushThread WRITE ERROR");
sendEvent(evtWriteError);
break;
}
buf_start += w;
}
eofcount = 0;
m_current_position += buf_end;
bytes_read += buf_end;
if (m_sg)
current_span_remaining -= buf_end;
}
}
sendEvent(evtStopped);
eDebug("FILEPUSH THREAD STOP");
}
开发者ID:Ophiuchus1312,项目名称:enigma2-master,代码行数:101,代码来源:filepush.cpp
示例13: printf
void CCombatNPC::update(s32 elapsedTime) {
IAIEntity::update(elapsedTime);
#ifdef NPC_DEBUG
printf("NPC (%i) Update nodes\n", node->getID());
#endif
if (FieldOfView) {
FieldOfView->setPosition(Node->getAbsolutePosition());
FieldOfView->setRotation(Node->getRotation() + FOV_ROTATION);
}
if (DebugFOV) {
DebugFOV->updateAbsolutePosition();
DebugFOV->setPosition(Node->getAbsolutePosition());
DebugFOV->setRotation(Node->getRotation() + FOV_ROTATION);
}
#ifdef NPC_DEBUG
printf("NPC (%i) check FOV\n", Node->getID());
#endif
checkFieldOfVision();
switch (State) {
case ENST_WAITING: {
#ifdef NPC_DEBUG
printf("NPC (%i) waiting\n", node->getID());
#endif
if (StayPut) {// If we want to stay put then keep waiting, whilst scanning the area
return;
} else {
// If we've completed our path we return
if (PathToDestination.size() == 0 && CurrentWaypoint == PathDestinationWaypoint) {
sendEvent(ENET_AT_GOAL, NULL);
changeState(ENST_WAITING);
} else
changeState(ENST_FOLLOWING_PATH); // Keep on going!
}
break;
}
case ENST_MOVING: {
#ifdef NPC_DEBUG
printf("NPC (%i) moving\n", node->getID());
#endif
if (DestinationWaypoint && !(Node->getAbsolutePosition().getDistanceFrom(DestinationWaypoint->getPosition() + NodeOffset) <= AtDestinationThreshold) ) {
// Not at our destination yet so move a bit closer
core::vector3df dir = ((DestinationWaypoint->getPosition() + NodeOffset) - Node->getAbsolutePosition()).normalize();
f32 factor = elapsedTime * MoveSpeed;
Node->setPosition(Node->getAbsolutePosition() + dir * factor);
break;
} else { // reached destination, wait for what to do next
//currentWaypoint = destinationWaypoint;
changeState(ENST_WAITING);
}
break;
}
case ENST_FOLLOWING_PATH: {
#ifdef NPC_DEBUG
printf("NPC (%i) following path\n", node->getID());
#endif
// If we're not at the current waypoint then go there (this can happen when stopping mid-path)
if (DestinationWaypoint && !(Node->getPosition().getDistanceFrom(DestinationWaypoint->getPosition() + NodeOffset) <= AtDestinationThreshold) ) {
DestinationWaypoint = CurrentWaypoint;
} else {
if (PathToDestination.size() == 0) {
changeState(ENST_WAITING);
break;
}
// Take the next waypoint in the path (the path is in reverse so we take from the back)
DestinationWaypoint = PathToDestination[PathToDestination.size()-1];
// remove the waypoint we've just taken
PathToDestination.erase(PathToDestination.size()-1);
}
if (DestinationWaypoint) {
// Rotate to face new destination and set running animation
rotateToFace(DestinationWaypoint->getPosition() + NodeOffset);
// Update current waypoint, that being the one we're aiming for.
CurrentWaypoint = DestinationWaypoint;
changeState(ENST_MOVING);
} else changeState(ENST_WAITING);
break;
}
}
#ifdef NPC_DEBUG
printf("NPC (%i) updated\n", Node->getID());
#endif
}
开发者ID:Assyr,项目名称:PlasmaDefence,代码行数:92,代码来源:CCombatNPC.cpp
示例14: sizeof
//.........这里部分代码省略.........
// Go through devices that have been lost since last run
_deviceHash::iterator itPrev;
for ( itPrev = deviceHashPrev.begin(); itPrev != deviceHashPrev.end(); ++itPrev ) {
wxString key = itPrev->first;
CDetectedDevice *pDev = itPrev->second;
if ( NULL == pDev ) {
continue;
}
if ( false == pDev->m_bfound ) {
if ( bSendTokenActivity ) {
vscpEventEx evx;
memset( evx.GUID, 0, 16 ); // Use interface GUID
evx.vscp_class = VSCP_CLASS2_LEVEL1_INFORMATION;
evx.vscp_type = VSCP_TYPE_INFORMATION_TOKEN_ACTIVITY;
evx.timestamp = wxDateTime::Now().GetTicks();
evx.head = VSCP_PRIORITY_NORMAL;
evx.sizeData = 8;
evx.data[ 0 ] = ( 18 << 2 ) + 2; // Bluetooth device + "Released"
evx.data[ 1 ] = zone;
evx.data[ 2 ] = subzone;
evx.data[ 3 ] = 0; // Frame 0
evx.data[ 4 ] = pDev->m_address[ 0 ];
evx.data[ 5 ] = pDev->m_address[ 1 ];
evx.data[ 6 ] = pDev->m_address[ 2 ];
evx.data[ 7 ] = pDev->m_address[ 3 ];
sendEvent( evx ); // Send the event
memset( evx.GUID, 0, 16 ); // Use interface GUID
evx.vscp_class = VSCP_CLASS2_LEVEL1_INFORMATION;
evx.vscp_type = VSCP_TYPE_INFORMATION_TOKEN_ACTIVITY;
evx.timestamp = wxDateTime::Now().GetMillisecond();
evx.head = VSCP_PRIORITY_NORMAL;
evx.sizeData = 6;
evx.data[ 0 ] = ( 18 << 2 ) + 2; // Bluetooth device + "Released"
evx.data[ 1 ] = zone;
evx.data[ 2 ] = subzone;
evx.data[ 3 ] = 1; // Frame 1
evx.data[ 4 ] = pDev->m_address[ 4 ];
evx.data[ 5 ] = pDev->m_address[ 5 ];
sendEvent( evx );
}
// Remove it
delete pDev;
deviceHashPrev[ key ] = NULL;
}
else {
// Prepare for next detection loop
pDev->m_bfound = false;
}
}
开发者ID:ajje,项目名称:vscp,代码行数:66,代码来源:vscpbtdetect.cpp
示例15: nodeName
void HttpInterface::evVariableOrEvent(HttpRequest* req, strings& args)
{
string nodeName(args[0]);
size_t eventPos;
if ( ! commonDefinitions.events.contains(UTF8ToWString(args[1]), &eventPos))
{
// this is a variable
if (req->method.find("POST") == 0 || args.size() >= 3)
{
// set variable value
strings values;
if (args.size() >= 3)
values.assign(args.begin()+1, args.end());
else
{
// Parse POST form data
values.push_back(args[1]);
parse_json_form(req->content, values);
}
if (values.size() == 0)
{
finishResponse(req, 404, "");
if (verbose)
cerr << req << " evVariableOrEevent 404 can't set variable " << args[0] << ", no values" << endl;
return;
}
sendSetVariable(nodeName, values);
finishResponse(req, 200, "");
if (verbose)
cerr << req << " evVariableOrEevent 200 set variable " << values[0] << endl;
}
else
{
// get variable value
strings values;
values.assign(args.begin()+1, args.begin()+2);
unsigned source, start;
if ( ! getNodeAndVarPos(nodeName, values[0], source, start))
{
finishResponse(req, 404, "");
if (verbose)
cerr << req << " evVariableOrEevent 404 no such variable " << values[0] << endl;
return;
}
sendGetVariables(nodeName, values);
pendingVariables[std::make_pair(source,start)].insert(req);
if (verbose)
cerr << req << " evVariableOrEevent schedule var " << values[0]
<< "(" << source << "," << start << ") add " << req << " to subscribers" << endl;
return;
}
}
else
{
// this is an event
// arguments are args 1..N
strings data;
data.push_back(args[1]);
if (args.size() >= 3)
for (size_t i=2; i<args.size(); ++i)
data.push_back((args[i].c_str()));
else if (req->method.find("POST") == 0)
{
// Parse POST form data
parse_json_form(std::string(req->content, req->content.size()), data);
}
sendEvent(nodeName, data);
finishResponse(req, 200, ""); // or perhaps {"return_value":null,"cmd":"sendEvent","name":nodeName}?
return;
}
}
开发者ID:bluemagic-club,项目名称:aseba,代码行数:75,代码来源:http.cpp
示例16: setIoPrio
void eFilePushThread::thread()
{
setIoPrio(prio_class, prio);
off_t dest_pos = 0, source_pos = 0;
size_t bytes_read = 0;
off_t current_span_offset = 0;
size_t current_span_remaining = 0;
size_t written_since_last_sync = 0;
eDebug("FILEPUSH THREAD START");
/* we set the signal to not restart syscalls, so we can detect our signal. */
struct sigaction act;
act.sa_handler = signal_handler; // no, SIG_IGN doesn't do it. we want to receive the -EINTR
act.sa_flags = 0;
sigaction(SIGUSR1, &act, 0);
hasStarted();
source_pos = m_raw_source.lseek(0, SEEK_CUR);
/* m_stop must be evaluated after each syscall. */
while (!m_stop)
{
/* first try flushing the bufptr */
if (m_buf_start != m_buf_end)
{
/* filterRecordData wants to work on multiples of blocksize.
if it returns a negative result, it means that this many bytes should be skipped
*in front* of the buffer. Then, it will be called again. with the newer, shorter buffer.
if filterRecordData wants to skip more data then currently available, it must do that internally.
Skipped bytes will also not be output.
if it returns a positive result, that means that only these many bytes should be used
in the buffer.
In either case, current_span_remaining is given as a reference and can be modified. (Of course it
doesn't make sense to decrement it to a non-zero value unless you return 0 because that would just
skip some data). This is probably a very special application for fast-forward, where the current
span is to be cancelled after a complete iframe has been output.
we always call filterRecordData with our full buffer (otherwise we couldn't easily strip from the end)
we filter data only once, of course, but it might not get immediately written.
that's what m_filter_end is for - it points to the start of the unfiltered data.
*/
int filter_res;
do
{
filter_res = filterRecordData(m_buffer + m_filter_end, m_buf_end - m_filter_end, current_span_remaining);
if (filter_res < 0)
{
eDebug("[eFilePushThread] filterRecordData re-syncs and skips %d bytes", -filter_res);
m_buf_start = m_filter_end + -filter_res; /* this will also drop unwritten data */
ASSERT(m_buf_start <= m_buf_end); /* otherwise filterRecordData skipped more data than available. */
continue; /* try again */
}
/* adjust end of buffer to strip dropped tail bytes */
m_buf_end = m_filter_end + filter_res;
/* mark data as filtered. */
m_filter_end = m_buf_end;
} while (0);
ASSERT(m_filter_end == m_buf_end);
if (m_buf_start == m_buf_end)
continue;
/* now write out data. it will be 'aligned' (according to filterRecordData).
absolutely forbidden is to return EINTR and consume a non-aligned number of bytes.
*/
int w = write(m_fd_dest, m_buffer + m_buf_start, m_buf_end - m_buf_start);
// fwrite(m_buffer + m_buf_start, 1, m_buf_end - m_buf_start, f);
// eDebug("wrote %d bytes", w);
if (w <= 0)
{
if (errno == EINTR || errno == EAGAIN || errno == EBUSY)
continue;
eDebug("eFilePushThread WRITE ERROR");
sendEvent(evtWriteError);
break;
// ... we would stop the thread
}
written_since_last_sync += w;
if (written_since_last_sync >= 512*1024)
{
int toflush = written_since_last_sync > 2*1024*1024 ?
2*1024*1024 : written_since_last_sync &~ 4095; // write max 2MB at once
dest_pos = lseek(m_fd_dest, 0, SEEK_CUR);
dest_pos -= toflush;
posix_fadvise(m_fd_dest, dest_pos, toflush, POSIX_FADV_DONTNEED);
//.........这里部分代码省略.........
开发者ID:FFTEAM,项目名称:enigma2-5,代码行数:101,代码来源:filepush.cpp
示例17: sendEvent
status_t DashPlayerDriver::prepare() {
sendEvent(MEDIA_SET_VIDEO_SIZE, 0, 0);
return OK;
}
开发者ID:GiggleKatDevs,项目名称:GiggleKat_moto_msm8960jbbl,代码行数:4,代码来源:DashPlayerDriver.cpp
示例18: sendEvent
void Controller::update(double delta_time)
{
symulation.update(delta_time* time_speed);
if (symulation.isWindowOpen() != last_window_state)
if (symulation.isWindowOpen())
sendEvent(EventType::WindowOpened);
else
sendEvent(EventType::WindowClosed);
if (symulation.isRaining() != last_rain_state)
if (symulation.isRaining())
sendEvent(EventType::RainStarted);
else
sendEvent(EventType::RainEnded);
if (symulation.isDay() != last_day_state)
if (symulation.isDay())
sendEvent(EventType::DayStarted);
else
sendEvent(EventType::NightStarted);
if (symulation.isSun() != last_sun_state)
if (symulation.isSun())
sendEvent(EventType::SunStarted);
else
sendEvent(EventType::SunEnded);
bool new_summer_state = symulation.getOutsideTemerarure() > symulation.getInsideTemerature();
if (last_summer_state != new_summer_state)
if (new_summer_state)
sendEvent(EventType::SummerStarted);
else
sendEvent(EventType::WinterStarted);
if (symulation.getInsideTemerature() > td + td_hist)
sendEvent(EventType::TooHot);
if (symulation.getInsideTemerature() < td - td_hist)
sendEvent(EventType::TooCold);
if (std::abs(symulation.getInsideTemerature() - td) < tconf_hist)
sendEvent(EventType::Comfort);
else
sendEvent(EventType::OutOfComfort);
last_window_state = symulation.isWindowOpen();
last_rain_state = symulation.isRaining();
last_summer_state = symulation.getOutsideTemerarure() > symulation.getInsideTemerature();
last_day_state = symulation.isDay();
last_sun_state = symulation.isSun();
if (!symulation.isCooling() && !symulation.isHeating())
{
std::cout << "cookie!";
}
}
开发者ID:pmjoniak,项目名称:AI,代码行数:58,代码来源:Controller.cpp
示例19: sendEvent
void CrossfireServer::eventClosed() {
CrossfireEvent eventObj;
eventObj.setName(EVENT_CLOSED);
sendEvent(&eventObj);
}
开发者ID:AlexRee,项目名称:webtools.jsdt.debug,代码行数:5,代码来源:CrossfireServer.cpp
示例20: incomingMsg
static Iface_DEFUN incomingMsg(struct Message* msg, struct Pathfinder_pvt* pf)
{
struct Address addr;
struct RouteHeader* hdr = (struct RouteHeader*) msg->bytes;
Message_shift(msg, -(RouteHeader_SIZE + DataHeader_SIZE), NULL);
Bits_memcpy(addr.ip6.bytes, hdr->ip6, 16);
Bits_memcpy(addr.key, hdr->publicKey, 32);
addr.protocolVersion = Endian_bigEndianToHost32(hdr->version_be);
addr.padding = 0;
addr.path = Endian_bigEndianToHost64(hdr->sh.label_be);
//Log_debug(pf->log, "Incoming DHT");
struct DHTMessage dht = {
.address = &addr,
.binMessage = msg,
.allocator = msg->alloc
};
DHTModuleRegistry_handleIncoming(&dht, pf->registry);
struct Message* nodeMsg = Message_new(0, 256, msg->alloc);
Iface_CALL(sendNode, nodeMsg, &addr, 0xfffffff0u, pf);
if (dht.pleaseRespond) {
// what a beautiful hack, see incomingFromDHT
return Iface_next(&pf->pub.eventIf, msg);
}
return NULL;
}
static Iface_DEFUN incomingFromEventIf(struct Message* msg, struct Iface* eventIf)
{
struct Pathfinder_pvt* pf = Identity_containerOf(eventIf, struct Pathfinder_pvt, pub.eventIf);
enum PFChan_Core ev = Message_pop32(msg, NULL);
if (Pathfinder_pvt_state_INITIALIZING == pf->state) {
Assert_true(ev == PFChan_Core_CONNECT);
return connected(pf, msg);
}
// Let the PF send another 128 path changes again because it's basically a new tick.
pf->bestPathChanges = 0;
switch (ev) {
case PFChan_Core_SWITCH_ERR: return switchErr(msg, pf);
case PFChan_Core_SEARCH_REQ: return searchReq(msg, pf);
case PFChan_Core_PEER: return peer(msg, pf);
case PFChan_Core_PEER_GONE: return peerGone(msg, pf);
case PFChan_Core_SESSION: return session(msg, pf);
case PFChan_Core_SESSION_ENDED: return sessionEnded(msg, pf);
case PFChan_Core_DISCOVERED_PATH: return discoveredPath(msg, pf);
case PFChan_Core_MSG: return incomingMsg(msg, pf);
case PFChan_Core_PING: return handlePing(msg, pf);
case PFChan_Core_PONG: return handlePong(msg, pf);
case PFChan_Core_UNSETUP_SESSION:
case PFChan_Core_LINK_STATE:
case PFChan_Core_CTRL_MSG: return NULL;
default:;
}
Assert_failure("unexpected event [%d]", ev);
}
static void sendEvent(struct Pathfinder_pvt* pf, enum PFChan_Pathfinder ev, void* data, int size)
{
struct Allocator* alloc = Allocator_child(pf->alloc);
struct Message* msg = Message_new(0, 512+size, alloc);
Message_push(msg, data, size, NULL);
Message_push32(msg, ev, NULL);
Iface_send(&pf->pub.eventIf, msg);
Allocator_free(alloc);
}
static void init(void* vpf)
{
struct Pathfinder_pvt* pf = Identity_check((struct Pathfinder_pvt*) vpf);
struct PFChan_Pathfinder_Connect conn = {
.superiority_be = Endian_hostToBigEndian32(1),
.version_be = Endian_hostToBigEndian32(Version_CURRENT_PROTOCOL)
};
CString_strncpy(conn.userAgent, "Cjdns internal pathfinder", 64);
sendEvent(pf, PFChan_Pathfinder_CONNECT, &conn, PFChan_Pathfinder_Connect_SIZE);
}
struct Pathfinder* Pathfinder_register(struct Allocator* allocator,
struct Log* log,
struct EventBase* base,
struct Random* rand,
struct Admin* admin)
{
struct Allocator* alloc = Allocator_child(allocator);
struct Pathfinder_pvt* pf = Allocator_calloc(alloc, sizeof(struct Pathfinder_pvt), 1);
Identity_set(pf);
pf->alloc = alloc;
pf->log = log;
pf->base = base;
pf->rand = rand;
pf->admin = admin;
pf->pub.eventIf.send = incomingFromEventIf;
pf->dhtModule.context = pf;
//.........这里部分代码省略.........
开发者ID:cjdelisle,项目名称:cjdns,代码行数:101,代码来源:Pathfinder.c
注:本文中的sendEvent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论