コード例 #1
0
ファイル: NetMessageManager.cpp プロジェクト: A-K/naali
 void NetMessageManager::SendCompletePingCheck(uint8_t id)
 {
     NetOutMessage *m = StartNewMessage(RexNetMsgCompletePingCheck);
     assert(m);
     m->AddU8(pingId);
     FinishMessage(m);
 }
コード例 #2
0
ファイル: NetMessageManager.cpp プロジェクト: A-K/naali
 void NetMessageManager::SendStartPingCheck(uint8_t id, uint32_t oldestUnacked)
 {
     NetOutMessage *m = StartNewMessage(RexNetMsgStartPingCheck);
     assert(m);
     m->AddU8(id);
     m->AddU32(oldestUnacked);
     FinishMessage(m);
 }
コード例 #3
0
ファイル: DumpThread.cpp プロジェクト: powen-l/emacs.d
void DumpThread::run()
{
    CXIndex index = clang_createIndex(0, 0);
    CXTranslationUnit translationUnit = 0;
    String clangLine;
    RTags::parseTranslationUnit(mSource.sourceFile(), mSource.toCommandLine(Source::Default), translationUnit,
                                index, 0, 0, CXTranslationUnit_DetailedPreprocessingRecord, &clangLine);
    writeToConnetion(String::format<128>("Indexed: %s => %s", clangLine.constData(), translationUnit ? "success" : "failure"));
    if (translationUnit) {
        clang_visitChildren(clang_getTranslationUnitCursor(translationUnit), DumpThread::visitor, this);
        clang_disposeTranslationUnit(translationUnit);
    }

    clang_disposeIndex(index);
    EventLoop::mainEventLoop()->callLaterMove(std::bind((bool(Connection::*)(Message&&))&Connection::send, mConnection, std::placeholders::_1),
                                              FinishMessage());
}
コード例 #4
0
ファイル: NetMessageManager.cpp プロジェクト: A-K/naali
    ///\todo Have better delay method for pending ACKs, currently sends everything accumulated just over one frame
    void NetMessageManager::SendPendingACKs()
    {
        PROFILE(NetMessageManager_SendPendingACKs);
        // If we aren't even connected (or not connected anymore), clear any old pending ACKs and return.
        if (!connection)
        {
            pendingACKs.clear();
            return;
        }

        static const size_t max_acks_in_msg = 100;

        while (pendingACKs.size() > 0)
        {
            size_t acks_to_send = pendingACKs.size();
            if (acks_to_send > max_acks_in_msg)
                acks_to_send = max_acks_in_msg;

            NetOutMessage *m = StartNewMessage(RexNetMsgPacketAck);
            assert(m);
            m->SetVariableBlockCount(acks_to_send);
            
            std::set<uint32_t>::iterator i = pendingACKs.begin();
            size_t added_acks = 0;
            
            while (added_acks < acks_to_send)
            {
                // Note! Horrible protocol design issue! The sequence numbers that both
                // server and client use are sent in big endian, but in the ACK packets
                // they need to be transferred in little endian. !! So, no conversion to
                // big endian here.
                m->AddU32(*i);
                ++added_acks;
                ++i;
            }
            
            FinishMessage(m);
            
            pendingACKs.erase(pendingACKs.begin(), i);
        }
    }
コード例 #5
0
ファイル: ofApp.cpp プロジェクト: Yalexyo/SoundMaster
//--------------------------------------------------------------
void ofApp::setup() {

	ofSetFrameRate(60);
	ofSetVerticalSync(true);
	//ofSetLogLevel("Pd", OF_LOG_VERBOSE); // see verbose info inside

	// the number of libpd ticks per buffer,
	// used to compute the audio buffer len: tpb * blocksize (always 64)
	#ifdef TARGET_LINUX_ARM
		// longer latency for Raspberry PI
		int ticksPerBuffer = 32; // 32 * 64 = buffer len of 2048
		int numInputs = 0; // no built in mic
	#else
		int ticksPerBuffer = 8; // 8 * 64 = buffer len of 512
		int numInputs = 1;
	#endif
	int numOutputs = 2;

	// setup OF sound stream
	ofSoundStreamSetup(numOutputs, numInputs, this, 44100, ofxPd::blockSize()*ticksPerBuffer, 4);

	// allocate pd instance handles
	instanceMutex.lock();
	pdinstance1 = pdinstance_new();
	pdinstance2 = pdinstance_new();
	instanceMutex.unlock();
	
	// set a "current" instance before pd.init() or else Pd will make
    // an unnecessary third "default" instance
	instanceMutex.lock();
	pd_setinstance(pdinstance1);
	instanceMutex.unlock();
	
	// setup Pd
	//
	// set 4th arg to true for queued message passing using an internal ringbuffer,
	// this is useful if you need to control where and when the message callbacks
	// happen (ie. within a GUI thread)
	//
	// note: you won't see any message prints until update() is called since
	// the queued messages are processed there, this is normal
	//
	// ... here we'd sure like to be able to have number of channels be
    // per-instance.  The sample rate is still global within Pd but we might
    // also consider relaxing that restrction.
	//
	if(!pd.init(numOutputs, numInputs, 44100, ticksPerBuffer, false)) {
		ofExit(1);
	}
	pd.setReceiver(this);
	
	// allocate instance output buffers
	outputBufferSize = numOutputs*ticksPerBuffer*ofxPd::blockSize();
	outputBuffer1 = new float[outputBufferSize];
	outputBuffer2 = new float[outputBufferSize];
	memset(outputBuffer1, 0, outputBufferSize);
	memset(outputBuffer2, 0, outputBufferSize);

	instanceMutex.lock();
	pd_setinstance(pdinstance1);  // talk to first pd instance
	instanceMutex.unlock();

	// audio processing on
	pd.start();

	// open patch
	pd.openPatch("test.pd");

	instanceMutex.lock();
	pd_setinstance(pdinstance2); // talk to the second pd instance
	instanceMutex.unlock();

	// audio processing on
	pd.start();

	// open patch
	pd.openPatch("test.pd");
	
	// The following two messages can be sent without setting the pd instance
    // and anyhow the symbols are global so they may affect multiple instances.
    // However, if the messages change anything in the pd instance structure
    // (DSP state; current time; list of all canvases n our instance) those
    // changes will apply to the current Pd nstance, so the earlier messages,
    // for instance, were sensitive to which was the current one.
    //
    // Note also that I'm using the fact that $0 is set to 1003, 1004, ...
    // as patches are opened, it would be better to open the patches with
    // settable $1, etc parameters to openPatch().
	
	// [; pd frequency 220 (
	pd << StartMessage() << 440.0f << FinishMessage("1003-frequency", "float");

	// [; pd frequency 440 (
	pd << StartMessage() << 880.0f << FinishMessage("1004-frequency", "float");
}