void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification notification) { if (notification.type() != Notification::FunctionType) LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - notification %s", this, notificationName(notification)); m_queueMutex.lock(); // It is important to always process the properties in the order that we are notified, // so always go through the queue because notifications happen on different threads. m_queuedNotifications.append(notification); #if OS(WINDOWS) bool delayDispatch = true; #else bool delayDispatch = m_delayCallbacks || !isMainThread(); #endif if (delayDispatch && !m_mainThreadCallPending) { m_mainThreadCallPending = true; callOnMainThread(mainThreadCallback, this); } m_queueMutex.unlock(); if (delayDispatch) { if (notification.type() != Notification::FunctionType) LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - early return", this); return; } dispatchNotification(); }
void MediaPlayerPrivateAVFoundation::mainThreadCallback() { LOG(Media, "MediaPlayerPrivateAVFoundation::mainThreadCallback(%p)", this); clearMainThreadPendingFlag(); dispatchNotification(); }
/** * Do some sanity checks and forward message to the proper handler */ void MsgpackIODevice::dispatch(msgpack_object& req) { // // neovim msgpack rpc calls are // [type(int), msgid(int), method(int), args(array)] // if (req.type != MSGPACK_OBJECT_ARRAY) { qDebug() << "Received Invalid msgpack: not an array"; return; } if (req.via.array.size < 3 || req.via.array.size > 4) { qDebug() << "Received Invalid msgpack: message len MUST be 3 or 4"; return; } if (req.via.array.ptr[0].type != MSGPACK_OBJECT_POSITIVE_INTEGER) { qDebug() << "Received Invalid msgpack: msg type MUST be an integer"; return; } uint64_t type = req.via.array.ptr[0].via.u64; switch(type) { case 0: if (req.via.array.ptr[1].type != MSGPACK_OBJECT_POSITIVE_INTEGER) { qDebug() << "Received Invalid request: msg id MUST be a positive integer"; sendError(req, tr("Msg Id must be a positive integer")); return; } if (req.via.array.ptr[2].type != MSGPACK_OBJECT_BIN && req.via.array.ptr[2].type != MSGPACK_OBJECT_STR) { qDebug() << "Received Invalid request: method MUST be a String" << req.via.array.ptr[2]; sendError(req, tr("Method id must be a positive integer")); return; } if (req.via.array.ptr[3].type != MSGPACK_OBJECT_ARRAY) { qDebug() << "Invalid request: arguments MUST be an array"; sendError(req, tr("Paremeters must be an array")); return; } dispatchRequest(req); break; case 1: if (req.via.array.ptr[1].type != MSGPACK_OBJECT_POSITIVE_INTEGER) { qDebug() << "Received Invalid response: msg id MUST be a positive integer"; return; } dispatchResponse(req); break; case 2: dispatchNotification(req); break; default: qDebug() << "Unsupported msg type" << type; } }
void NodeListManager::addNodeList( NodeList* list ) { // Before we store the node list, we should check if anyone has registered // an interest in it, but only if the list is complete. if (list->mListComplete) { if (dispatchNotification( list )) { delete list; return; } } // Nothing is registered or the list is not complete, so store the list for later mNodeLists.push_back( list ); }
bool NodeListManager::dispatchNotification( U32 listId ) { // Find the matching list NodeList* list = NULL; for (U32 i=0; i<mNodeLists.size(); ++i) { if (mNodeLists[i]->mId == listId) { list = mNodeLists[i]; break; } } if (list) return dispatchNotification( list ); return false; }
void MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(Notification::Type type, double time) { LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - notification %d", this, static_cast<int>(type)); m_queueMutex.lock(); // It is important to always process the properties in the order that we are notified, // so always go through the queue because notifications happen on different threads. m_queuedNotifications.append(Notification(type, time)); bool delayDispatch = m_delayCallbacks || !isMainThread(); if (delayDispatch && !m_mainThreadCallPending) { m_mainThreadCallPending = true; callOnMainThread(mainThreadCallback, this); } m_queueMutex.unlock(); if (delayDispatch) { LOG(Media, "MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification(%p) - early return", this); return; } dispatchNotification(); }