Exemple #1
0
bool CoreAV::startCall(uint32_t friendNum, bool video)
{
    if (QThread::currentThread() != coreavThread.get())
    {
        if (threadSwitchLock.test_and_set(std::memory_order_acquire))
        {
            qDebug() << "CoreAV::startCall: Backed off of thread-switch lock";
            return false;
        }

        bool ret;
        QMetaObject::invokeMethod(this, "startCall", Qt::BlockingQueuedConnection,
                                  Q_RETURN_ARG(bool, ret),
                                  Q_ARG(uint32_t, friendNum),
                                  Q_ARG(bool, video));

        threadSwitchLock.clear(std::memory_order_release);
        return ret;
    }

    qDebug() << QString("Starting call with %1").arg(friendNum);
    if (calls.contains(friendNum))
    {
        qWarning() << QString("Can't start call with %1, we're already in this call!").arg(friendNum);
        return false;
    }

    uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
    if (!toxav_call(toxav, friendNum, AUDIO_DEFAULT_BITRATE, videoBitrate, nullptr))
        return false;

    auto call = calls.insert({friendNum, video, *this});
    call->startTimeout();
    return true;
}
Exemple #2
0
   DialogBox(
      const QString& windowTitle,
      const QString& message,
      int period,
      int timeout
      )
    : _period(period),
      _timeout(timeout)
   {
      setIcon( QMessageBox::Information );
      setWindowTitle( windowTitle );
      setText( message );
      setWindowFlags( Qt::WindowStaysOnTopHint );

      startTimeout();
   }
Exemple #3
0
void TCPConnectionPair::onPeerConnectSuccess(net::Socket& socket)
{
    TraceS(this) << "Peer Connect request success" << endl;
    assert(&socket == peer.get());
    peer->Connect -= slot(this, &TCPConnectionPair::onPeerConnectSuccess);
    peer->Error -= slot(this, &TCPConnectionPair::onPeerConnectError);

    // If no ConnectionBind request associated with this peer data
    // connection is received after 30 seconds, the peer data connection
    // MUST be closed.

    allocation.sendPeerConnectResponse(this, true);

    // TODO: Ensure this is implemented properly
    startTimeout();
}
Exemple #4
0
void Client::parse(char *line, size_t len)
{
    startTimeout();

    line[len - 1] = '\0';

    LOG_DEBUG("[%s:%u] received (%d bytes): \"%s\"", m_url.host(), m_url.port(), len, line);

    if (len < 32 || line[0] != '{') {
        if (!m_quiet) {
            LOG_ERR("[%s:%u] JSON decode failed", m_url.host(), m_url.port());
        }

        return;
    }

    rapidjson::Document doc;
    if (doc.ParseInsitu(line).HasParseError()) {
        if (!m_quiet) {
            LOG_ERR("[%s:%u] JSON decode failed: \"%s\"", m_url.host(), m_url.port(), rapidjson::GetParseError_En(doc.GetParseError()));
        }

        return;
    }

    if (!doc.IsObject()) {
        return;
    }

    const rapidjson::Value &id = doc["id"];
    if (id.IsInt64()) {
        parseResponse(id.GetInt64(), doc["result"], doc["error"]);
    }
    else {
        parseNotification(doc["method"].GetString(), doc["params"], doc["error"]);
    }
}
void TimeoutCommand::start() {
    if (m_manager->isLoading()) {
        connect(m_manager, SIGNAL(pageFinished(bool)), this, SLOT(pendingLoadFinished(bool)));
        startTimeout();
    } else {
Exemple #6
0
void ManufactureTestButtonPress(void)
{
	startTimeout(&biosUnused, BIOS_UNUSED_MS);
	while(1)
	{
		uint8_t red = LED_OFF;
		uint8_t green = LED_OFF;
		uint8_t blue = LED_OFF;		
		
		WatchdogPet();
		
		if (buttonActivated(B_START) & buttonActivated(B_SELECT))
		{
			delay_ms(500);
			reset_do_soft_reset();
		}
		
		if(checkTimeout(&biosUnused))
		{
			cancelTimeout(&biosUnused);
			setLEDValue(0, 0, 0);
			powerOff(global_header.powerOffSoftware);
		}

		if( buttonActivated(B_UP) ||
			buttonActivated(B_DOWN) ||
			buttonActivated(B_LEFT) ||
			buttonActivated(B_RIGHT) ||
			buttonActivated(B_A) ||
			buttonActivated(B_B) ||
			buttonActivated(B_X) ||
			buttonActivated(B_Y) ||
			buttonActivated(B_START) ||
			buttonActivated(B_SELECT) ||
			buttonActivated(B_LB) ||
			buttonActivated(B_RB) ||
			buttonActivated(B_LT) ||
			buttonActivated(B_RT) ||
			buttonActivated(B_JL) ||
			buttonActivated(B_JR)
		)
		{
			green = LED_DIM;
		}
		
		for(uint8_t idx = 0 ; idx<NUM_JOYSTICKS; idx++) 
		{
			uint16_xy raw;
			raw.x = sampleAnalogChannel(joysticks[idx].adc_channel_x);
			raw.y = sampleAnalogChannel(joysticks[idx].adc_channel_y);
			
			int16_xy out;
			SimpleJoystickAdj( center[idx], &deadzone, &raw, &out );
			
			//Write raw and adjusted X,Y values to USB serial port
			PrintXY(raw.x,raw.y);
			sendUSBString("->", false);
			PrintXY(out.x,out.y);
			sendUSBLine("");
			
			if( out.y<0 )
			{
				//up is yellow
				red = LED_DIM;
				green = LED_DIM;
			}
			else if( out.y>0 )
			{
				//down is blue
				blue = LED_DIM;
			}
			else if( out.x>0 )
			{
				//right is Red
				red = LED_DIM;
			}
			else if( out.x<0 )
			{
				//left is green
				green = LED_DIM;
			}
		}
		
		setLEDValue(red, green, blue);
				
	} // end while(1)
}