void Connection::dataWritten(LocalClient *, int bytes) { assert(mPendingWrite >= bytes); mPendingWrite -= bytes; if (!mPendingWrite) { if (bytes) sendComplete()(); if (mDone) { mClient->disconnect(); deleteLater(); } } }
tResult DriverFilter::OnPinEvent(IPin *source, tInt eventCore, tInt param1, tInt param2, IMediaSample *mediaSample) { RETURN_IF_POINTER_NULL(source); RETURN_IF_POINTER_NULL(mediaSample); if (eventCore == IPinEventSink::PE_MediaSampleReceived) { if (source == &this->juryStatePin) { static tInt8 actionId; static tInt16 maneuverId; RETURN_IF_FAILED_AND_LOG_ERROR_STR(getManeuver(mediaSample, actionId, maneuverId), "Cant get Maneuver from Jury"); switch (actionId) { case STOP: LOG_INFO(cString::Format("Jury sends stop in %d", maneuverId)); this->isFirstTimeRun = true; RETURN_IF_FAILED(sendError(maneuverId)); if (this->stopCounter <= 3) { RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, MANEUVER_STOP, mediaSample->GetTime())); this->stopCounter++; } break; case READY: LOG_INFO(cString::Format("Jury sends ready in %d", maneuverId)); RETURN_IF_FAILED(sendReady(maneuverId)); this->stopCounter = 0; break; case RUN: LOG_INFO(cString::Format("Jury sends run in %d", maneuverId)); if (this->isFirstTimeRun) { LOG_INFO("First time run!"); this->isFirstTimeRun = false; this->stopCounter = 0; getManeuverFromId(maneuverId, this->currentManeuver); this->currentManeuverId = maneuverId; LOG_INFO("Sending Manuever"); RETURN_IF_FAILED_AND_LOG_ERROR_STR(sendManeuver(this->currentManeuverPin, this->currentManeuver, mediaSample->GetTime()), "Cant send maneuver"); } RETURN_IF_FAILED(sendRunning(maneuverId)); break; } } else if (source == &this->maneuverFinishedPin) { LOG_WARNING("Got maneuver finished state"); this->stopCounter = 0; // lese den Zustand des aktuellen Befehls aus static tUInt16 maneuverValue; static tTimeStamp timeStamp; RETURN_IF_FAILED_AND_LOG_ERROR_STR(getManeuver(mediaSample, maneuverValue, timeStamp), "Cant get Maneuver from ManeuverFinishedPin"); if (isManeuverFinished(maneuverValue)) { // hole neuen befehl und sende ihn an das Juri modul und an den Befehlsauswerter if (getNextManeuver(this->currentManeuverId, this->currentManeuver)) { LOG_WARNING(cString::Format("next maneuver id: %d", this->currentManeuverId)); RETURN_IF_FAILED(sendRunning(this->currentManeuverId)); RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, this->currentManeuver, mediaSample->GetTime())); } else { LOG_INFO(cString::Format("send complete to jury in %d", this->currentManeuverId)); RETURN_IF_FAILED(sendComplete(this->currentManeuverId)); RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, MANEUVER_STOP, mediaSample->GetTime())); } } else { RETURN_IF_FAILED(sendRunning(this->currentManeuverId)); } } } RETURN_NOERROR; }