コード例 #1
0
vector<MemoryBlock> Server::createMemoryBlock(unsigned char *ptr,int size)
{
    if(blocks.size()==293)
    {
        //throw emu_fatalerror("OOPS");
    }
    vector<MemoryBlock> retval;
    const int BYTES_IN_MB=1024*1024;
    if(size>BYTES_IN_MB)
    {
        for(int a=0;;a+=BYTES_IN_MB)
        {
            if(a+BYTES_IN_MB>=size)
            {
                vector<MemoryBlock> tmp = createMemoryBlock(ptr+a,size-a);
                retval.insert(retval.end(),tmp.begin(),tmp.end());
                break;
            }
            else
            {
                vector<MemoryBlock> tmp = createMemoryBlock(ptr+a,BYTES_IN_MB);
                retval.insert(retval.end(),tmp.begin(),tmp.end());
            }
        }
        return retval;
    }
    //printf("Creating memory block at %X with size %d\n",ptr,size);
    blocks.push_back(MemoryBlock(ptr,size));
    staleBlocks.push_back(MemoryBlock(size));
    initialBlocks.push_back(MemoryBlock(size));
    retval.push_back(blocks.back());
    return retval;
}
コード例 #2
0
MemoryBlock Server::createMemoryBlock(int size)
{
    blocks.push_back(MemoryBlock(size));
    staleBlocks.push_back(MemoryBlock(size));
    initialBlocks.push_back(MemoryBlock(size));
    return blocks.back();
}
コード例 #3
0
bool ChildProcessMaster::launchSlaveProcess (const File& executable, const String& commandLineUniqueID, int timeoutMs)
{
    connection = nullptr;
    jassert (childProcess.kill());

    const String pipeName ("p" + String::toHexString (Random().nextInt64()));

    StringArray args;
    args.add (executable.getFullPathName());
    args.add (getCommandLinePrefix (commandLineUniqueID) + pipeName);

    if (childProcess.start (args))
    {
        connection = new Connection (*this, pipeName, timeoutMs <= 0 ? defaultTimeoutMs : timeoutMs);

        if (connection->isConnected())
        {
            sendMessageToSlave (MemoryBlock (startMessage, specialMessageSize));
            return true;
        }

        connection = nullptr;
    }

    return false;
}
コード例 #4
0
ChildProcessMaster::~ChildProcessMaster()
{
    if (connection != nullptr)
    {
        sendMessageToSlave (MemoryBlock (killMessage, specialMessageSize));
        connection->disconnect();
        connection = nullptr;
    }
}
コード例 #5
0
void BinaryDataHandler::put(void const *src, UInt32 size)
{
    UInt8 const *data = static_cast<UInt8 const *>(src);

    if(_zeroCopyThreshold && size >= _zeroCopyThreshold)
    {
        if(_zeroCopyThreshold == 1)
        {
            write(const_cast<MemoryHandle>(data), size);
        }
        else
        {
            UInt8 tag = 1;

            // we have to write a tag, to indicate the membership
            // of this zero copy block to the current data block
            put(&tag, sizeof(tag));

            _zeroCopyBuffers.push_back(
                MemoryBlock(const_cast<MemoryHandle>(data), size, size));
        }
    }
    else
    {
        UInt32 copySize;

        while(size != 0)
        {
            if(_currentWriteBuffer == writeBufEnd())
            {
                pushBuffer();
            }

            copySize = osgMin((_currentWriteBuffer->getSize() -
                               _currentWriteBufferPos),
                              size);

            memcpy(_currentWriteBuffer->getMem() + _currentWriteBufferPos,
                    data,
                    copySize);

             size                  -= copySize;
            _currentWriteBufferPos += copySize;
             data                  += copySize;

            // skip to next buffer if current buffer is full
            if(_currentWriteBufferPos == _currentWriteBuffer->getSize())
            {
                _currentWriteBuffer->setDataSize(_currentWriteBufferPos);
                _currentWriteBuffer++;
                _currentWriteBufferPos = 0;
            }
        }
    }
}
コード例 #6
0
    void run() override
    {
        while (! threadShouldExit())
        {
            if (--countdown <= 0 || ! sendPingMessage (MemoryBlock (pingMessage, specialMessageSize)))
            {
                triggerConnectionLostMessage();
                break;
            }

            wait (1000);
        }
    }
コード例 #7
0
ファイル: CtrlrWindows.cpp プロジェクト: RomanKubiak/ctrlr
const Result CtrlrWindows::readResource (void *handle, const LPSTR resourceId, const LPSTR resourceType, MemoryBlock &resourceData)
{
	HRSRC	panelResource;
	HGLOBAL panelLoadedResource;
	String  data;
	char	*dataPointer;
	DWORD	dataSize;
	HMODULE myModuleHandle;

	if (handle != nullptr)
	{
		myModuleHandle = (HMODULE)handle;
	}
	else
	{
		myModuleHandle = GetModuleHandle(File::getSpecialLocation(File::currentExecutableFile).getFullPathName().toUTF8());
	}

	if (myModuleHandle)
	{
		panelResource = FindResource(myModuleHandle, resourceId, resourceType);

		if (panelResource)
		{
			panelLoadedResource = LoadResource(myModuleHandle, panelResource);

			if (panelLoadedResource)
			{
				dataSize	= SizeofResource (myModuleHandle, panelResource);
				dataPointer = (char *) LockResource (panelLoadedResource);

				resourceData = MemoryBlock(dataPointer,dataSize);

				return (Result::ok());
			}
			else
			{
				return (Result::fail("Windows Native: LoadResource() failed"));
			}
		}
		else
		{
			return (Result::fail("Windows Native: FindResource() failed"));
		}
	}
	else
	{
		return (Result::fail("Windows Native: GetModuleHandle() for: \""+File::getSpecialLocation(File::currentExecutableFile).getFullPathName()+"\" failed"));
	}
}
コード例 #8
0
void CtrlrMidiDevice::handleIncomingMidiMessage (MidiInput* source, const MidiMessage& message)
{
	_MIN(getProperty(Ids::name), message);

#ifdef JUCE_LINUX
    uint8 *ptr = message.getRawData();

    if (!message.isSysEx() && *(ptr + (message.getRawDataSize() - 1)) == 0xf7)
    {
        dataCollector.append (ptr, message.getRawDataSize());

        deviceListeners.call (&CtrlrMidiDevice::Listener::handleMIDIFromDevice, MidiMessage (dataCollector.getData(), dataCollector.getSize()));

        return;
    }
#endif

	if (message.isSysEx())
	{
#ifdef JUCE_LINUX


        if (*(ptr + (message.getRawDataSize() - 1)) == 0xf7)
        {
            deviceListeners.call (&CtrlrMidiDevice::Listener::handleMIDIFromDevice, message);
        }
        else
        {
            dataCollector = MemoryBlock (ptr, message.getRawDataSize());
        }
#else
		deviceListeners.call (&CtrlrMidiDevice::Listener::handleMIDIFromDevice, message);
#endif
	}
	else
	{
        lastMessageWasSysex = false;

		for (int i=0; i<deviceListeners.size(); i++)
		{
			const int ch = deviceListeners.getListeners() [i]->getListenerInputMidiChannel();

			if (ch == message.getChannel() || ch == 0 || message.getChannel() == 0)
			{
				deviceListeners.getListeners() [i]->handleMIDIFromDevice (message);
			}
		}
	}
}
コード例 #9
0
void CtrlrMidiInputComparatorSingle::matchSysEx(const MidiMessage &m)
{
	BigInteger bi = memoryToBits(MemoryBlock(m.getRawData(), m.getRawDataSize()));

	CtrlrMultiMidiMapIterator it;

	for (it=mapSysEx.begin(); it != mapSysEx.end(); it++)
	{
		if (compareMemory ((*it).first.toMemoryBlock(), messageContainer.getData()))
		{
			for (int i=0; i < (*it).second.targets.size(); i++)
			{
				(*it).second.targets[i]->getProcessor().setValueFromMIDI (messageContainer, source);
			}

			updateCacheSysEx (it);
			break;
		}
	}
}
コード例 #10
0
CtrlrMIDILibraryRequest::CtrlrMIDILibraryRequest(const CtrlrMIDILibraryRequest &other, const MidiMessage _response)
	:	currentAction(other.currentAction), 
		data(other.data), 
		status(other.status),
		createdTime(other.createdTime), 
		delay(other.delay), 
		expectedPrefixSize(other.expectedPrefixSize),
		timeout(other.timeout), 
		responseData(_response), 
		timestamp(other.timestamp),
		index(other.index), 
		item(other.item), 
		dataFile(other.dataFile), 
		matchSize(other.matchSize), 
		matchPrefix(other.matchPrefix),
		customRequestIndex(other.customRequestIndex),
		programNumber(other.programNumber),
		bankNumber(other.bankNumber)
{
	expectedPrefix = MemoryBlock (other.expectedPrefix);
}
コード例 #11
0
ファイル: Gsp1101.cpp プロジェクト: jabelardo/GIRL
void Gsp1101::handleIncomingMidiMessage(MidiInput *source, MidiMessage const& message)
{
    MemoryBlock mb (message.getRawData(), message.getRawDataSize());
    Logger::outputDebugString("\nMidiInput = " + asHex(mb));

    juce::uint8 const* msgBuff = message.getSysExData();
    if (!msgBuff)
    {
        lastMidiInput_M.setSize(0);
        return;
    }
    lastMidiInput_M = MemoryBlock(message.getSysExData(), message.getSysExDataSize());

    // A sysx ACK is:
    // F0 00 00 10 XX XX XX 7E 00 (procedure) (checksum) F7
    if (msgBuff[6] == 0x7e)
    {}

    // A sysx NACK is:
    // F0 00 00 10 XX XX XX 7F 00 (procedure) (err code) (checksum) F7
    else if (msgBuff[6] == 0x7f)
    {
        deviceReady_M = false;
        // NACK error codes:
#define SYSX_INVALID_CHECKSUM          7
#define MERR_OVERRUN                   10
#define MIDI_PROC_FAILED               12
        switch (msgBuff[9])
        {
        case SYSX_INVALID_CHECKSUM:
        case MERR_OVERRUN:
        case MIDI_PROC_FAILED:
        default:
            break;
        }
        //Logger::outputDebugString("MidiInput error = " + String(msgBuff[9]));
    }
    else
    {}
}
コード例 #12
0
MemoryBlock MemoryOutputStream::getMemoryBlock() const
{
    return MemoryBlock (getData(), getDataSize());
}
コード例 #13
0
 static bool sendMessageCallback (void* userInfo, const void* data, size_t dataSize)
 {
     return static_cast<InterprocessConnection*> (static_cast<ServerIPC*> (userInfo))
               ->sendMessage (MemoryBlock (data, dataSize));
 }
コード例 #14
0
void CtrlrPanelMIDIInputThread::handlePartialMIDIFromDevice (const uint8* messageData, const int numBytesSoFar, const double timestamp)
{
	const ScopedWriteLock sl (lock);

	devicePartialBuffer.add (MemoryBlock (messageData, numBytesSoFar));
}