Exemplo n.º 1
0
void Contact::sendEventToListeners(CursorEventPtr pCursorEvent)
{
    switch (pCursorEvent->getType()) {
        case Event::CURSOR_DOWN:
            break;
        case Event::CURSOR_MOTION:
            notifySubscribers("CURSOR_MOTION", pCursorEvent);
            break;
        case Event::CURSOR_UP:
            notifySubscribers("CURSOR_UP", pCursorEvent);
            removeSubscribers();
            break;
        default:
            AVG_ASSERT_MSG(false, pCursorEvent->typeStr().c_str());
    }
    m_bSendingEvents = true;
    AVG_ASSERT(pCursorEvent->getContact() == shared_from_this());
    EventPtr pEvent = boost::dynamic_pointer_cast<Event>(pCursorEvent);
    m_bCurListenerIsDead = false;
    for (map<int, Listener>::iterator it = m_ListenerMap.begin(); 
            it != m_ListenerMap.end();)
    {
        Listener listener = it->second;
        m_CurListenerID = it->first;
        m_bCurListenerIsDead = false;
        switch (pCursorEvent->getType()) {
            case Event::CURSOR_MOTION:
                if (listener.m_pMotionCallback != Py_None) {
                    py::call<void>(listener.m_pMotionCallback, pEvent);
                }
                break;
            case Event::CURSOR_UP:
                if (listener.m_pUpCallback != Py_None) {
                    py::call<void>(listener.m_pUpCallback, pEvent);
                }
                break;
            default:
                AVG_ASSERT(false);
        }
        map<int, Listener>::iterator lastIt = it;
        ++it;
        if (m_bCurListenerIsDead) {
            m_ListenerMap.erase(lastIt);
            m_bCurListenerIsDead = false;
        }
    }
    m_bSendingEvents = false;
}
Exemplo n.º 2
0
void AreaNode::setViewport(float x, float y, float width, float height)
{
    glm::vec2 oldSize = getRelViewport().size();
    if (x == -32767) {
        x = getRelViewport().tl.x;
    }
    if (y == -32767) {
        y = getRelViewport().tl.y;
    }
    glm::vec2 mediaSize = glm::vec2(getMediaSize());
    if (width == -32767) {
        if (m_UserSize.x == 0.0) {
            width = mediaSize.x;
        } else {
            width = m_UserSize.x;
        } 
    }
    if (height == -32767) {
        if (m_UserSize.y == 0.0) {
            height = mediaSize.y;
        } else {
            height = m_UserSize.y;
        } 
    }
    if (width < 0 || height < 0) {
        throw Exception(AVG_ERR_OUT_OF_RANGE, "Negative size for a node.");
    }
    m_RelViewport = FRect(x, y, x+width, y+height);
    if (oldSize != m_RelViewport.size()) {
        notifySubscribers("SIZE_CHANGED", m_RelViewport.size());
    }
    m_bTransformChanged = true;
}
Exemplo n.º 3
0
ErrorCode FrameOrganizer::writeFrame(FrameWriter* writer, VideoFrame* frame)
{
    assertFinalized();
    ASSERT(frame);

    auto it = m_frame_catalouge.find(writer);

    writer->m_lock.lock();
    ErrorCode frame_writing_check = checkFrameWriting(it);

    if (frame_writing_check != ErrorCode::SUCCESS)
    {
        writer->m_lock.unlock();
        return frame_writing_check;
    }

    // Increase the counter
    it->second = it->second + 1;
    writer->m_lock.unlock();

    // notify subscribers
    notifySubscribers(writer, frame);

    return ErrorCode::SUCCESS;
}
      //-----------------------------------------------------------------------
      void TransportStream::write(
                                  SecureByteBlockPtr bufferToAdopt,
                                  StreamHeaderPtr header
                                  )
      {
        ZS_THROW_INVALID_ARGUMENT_IF(!bufferToAdopt)

        AutoRecursiveLock lock(getLock());

        if (isShutdown()) {
          ZS_LOG_WARNING(Detail, log("cannot write as already shutdown"))
          return;
        }

        if (mBlockQueue) {
          ZS_LOG_TRACE(log("write blocked thus putting buffer into block queue") + ZS_PARAM("size", bufferToAdopt->SizeInBytes()) + ZS_PARAM("header", (bool)header))
          if (!mBlockHeader) {
            mBlockHeader = header;
          }
          if (bufferToAdopt->SizeInBytes() > 0) {
            mBlockQueue->Put(bufferToAdopt->BytePtr(), bufferToAdopt->SizeInBytes());
          }
          return;
        }

        Buffer buffer;
        buffer.mBuffer = bufferToAdopt;
        buffer.mHeader = header;

        ZS_LOG_TRACE(log("buffer written") + ZS_PARAM("written", bufferToAdopt->SizeInBytes()) )

        mBuffers.push_back(buffer);

        notifySubscribers(false, true);
      }
Exemplo n.º 5
0
void RectNode::setSize(const glm::vec2& pt) 
{
    m_Rect.setWidth(pt.x);
    m_Rect.setHeight(pt.y);
    notifySubscribers("SIZE_CHANGED", m_Rect.size());
    setDrawNeeded();
}
Exemplo n.º 6
0
// Publish event
void EBRouter::publishEvent(EBEvent &event, DistType distType) {

   event.publisherID = publisherID;

   if (distType == SHARED) {
      pubQueue.push(event);
   } else {
      notifySubscribers(event);
   }
}
Exemplo n.º 7
0
void ConfigurationManager::init()
{
    KAA_MUTEX_LOCKING("configurationGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(configurationGuardLock, configurationGuard_);
    KAA_MUTEX_LOCKED("configurationGuard_");

    if (!isConfigurationLoaded_) {
        loadConfiguration();
    }

    notifySubscribers(configuration_);
}
Exemplo n.º 8
0
void SoundNode::onEOF()
{
    seek(0);
    if (!m_bLoop) {
        changeSoundState(Paused);
    }
    if (m_pEOFCallback) {
        PyObject * arglist = Py_BuildValue("()");
        PyObject * result = PyEval_CallObject(m_pEOFCallback, arglist);
        Py_DECREF(arglist);
        if (!result) {
            throw py::error_already_set();
        }
        Py_DECREF(result);
    }
    notifySubscribers("END_OF_FILE");
}
Exemplo n.º 9
0
void ConfigurationManager::processConfigurationData(const std::vector<std::uint8_t>& data, bool fullResync)
{
    if (!fullResync) {
        throw KaaException("Partial configuration updates are not supported");
    }

    KAA_MUTEX_LOCKING("configurationGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(configurationGuardLock, configurationGuard_);
    KAA_MUTEX_LOCKED("configurationGuard_");

    updateConfiguration(data.data(), data.size());

    if (storage_) {
        storage_->saveConfiguration(data);
    }

    notifySubscribers(configuration_);
}
Exemplo n.º 10
0
void AreaNode::connectDisplay()
{
    IntPoint MediaSize = getMediaSize();
    if (m_UserSize.x == 0.0) {
        m_RelViewport.setWidth(float(MediaSize.x));
    } else {
        m_RelViewport.setWidth(float(m_UserSize.x));
    }
    if (m_UserSize.y == 0.0) {
        m_RelViewport.setHeight(float(MediaSize.y));
    } else {
        m_RelViewport.setHeight(float(m_UserSize.y));
    }
    if (m_UserSize.x == 0.0 || m_UserSize.y == 0) {
        notifySubscribers("SIZE_CHANGED", m_RelViewport.size());
    }
    m_bTransformChanged = true;
    Node::connectDisplay();
}
Exemplo n.º 11
0
void EBRouter::run() {

   DDSEventChannel::EventContainerSeq eventContainerSeq;
   DDSEventChannel::EventContainer rcvEventContainer;
   DDS::SampleInfoSeq infoSeq;

   init();

   while (!shutdownRequested) {

      eventContainerDataReader->take_w_condition(eventContainerSeq, infoSeq,
            DDS::LENGTH_UNLIMITED, readCondition);

      if (infoSeq.length() > 0) {

         for (unsigned int i = 0; i < eventContainerSeq.length(); i++) {

            if (infoSeq[i].valid_data) {

               EBEvent event;
               rcvEventContainer = eventContainerSeq[i];

               event.publisherID = rcvEventContainer.publisherID;
               event.eventID = rcvEventContainer.eventID;
               event.eventCatType = rcvEventContainer.eventCatType;
               event.eventDefType = rcvEventContainer.eventDefType;
               event.eventData = rcvEventContainer.eventData;

               notifySubscribers(event);
            }
         }
      }

      eventContainerDataReader->return_loan(eventContainerSeq, infoSeq);

      publishPending();

      boost::this_thread::sleep(boost::posix_time::milliseconds(30));
   }

   threadHasComplete = true;
}
Exemplo n.º 12
0
void MessageDelivery::deliverToModule(Message* message)
{
	notifySubscribers(message);
}