// Return current sharing handle, width and height of a Sender // A receiver checks this all the time so it has to be compact // Does not have to be the info of this instance // so the creation pointer and handle may not be known bool spoutSenderNames::getSharedInfo(const char* sharedMemoryName, SharedTextureInfo* info) { SpoutSharedMemory mem; // Possibly faster because the functon is called all the time if(mem.Open(sharedMemoryName)) { char *pBuf = mem.Lock(); if(pBuf) { memcpy((void *)info, (void *)pBuf, sizeof(SharedTextureInfo) ); mem.Unlock(); return true; } } return false; } // end getSharedInfo
// Return current sharing handle, width and height of a Sender // A receiver checks this all the time so it has to be compact // Does not have to be the info of this instance // so the creation pointer and handle may not be known bool spoutSenderNames::getSharedInfo(const char* sharedMemoryName, SharedTextureInfo* info) { SpoutSharedMemory mem; bool result = mem.Open(sharedMemoryName); if (!result) return false; char *pBuf = mem.Lock(); if(!pBuf) { return false; } memcpy((void *)info, (void *)pBuf, sizeof(SharedTextureInfo) ); mem.Unlock(); return true; } // end getSharedInfo
// 12.06.15 - Added to allow direct modification of a sender's information in shared memory bool spoutSenderNames::setSharedInfo(const char* sharedMemoryName, SharedTextureInfo* info) { SpoutSharedMemory mem; bool result = mem.Open(sharedMemoryName); if (!result) { printf(" memory not found\n"); return false; } char *pBuf = mem.Lock(); if (!pBuf) { printf(" buffer not locked\n"); return false; } memcpy((void *)pBuf, (void *)info, sizeof(SharedTextureInfo) ); mem.Unlock(); return true; } // end getSharedInfo