| 247 | #endif |
| 248 | |
| 249 | bool ImagingComponent::m_sendImageDataViaSharedMemory( |
| 250 | OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, |
| 251 | OSVR_ChannelCount sensor, OSVR_TimeValue const ×tamp) { |
| 252 | |
| 253 | m_growShmVecIfRequired(sensor); |
| 254 | uint32_t imageBufferSize = getBufferSize(metadata); |
| 255 | if (!m_shmBuf[sensor] || |
| 256 | m_shmBuf[sensor]->getEntrySize() != imageBufferSize) { |
| 257 | // create or replace the shared memory ring buffer. |
| 258 | auto makeName = |
| 259 | [](OSVR_ChannelCount sensor, std::string const &devName) { |
| 260 | std::ostringstream os; |
| 261 | os << "com.osvr.imaging/" << devName << "/" << int(sensor); |
| 262 | return os.str(); |
| 263 | }; |
| 264 | m_shmBuf[sensor] = IPCRingBuffer::create( |
| 265 | IPCRingBuffer::Options( |
| 266 | makeName(sensor, m_getParent().getDeviceName())) |
| 267 | .setEntrySize(imageBufferSize)); |
| 268 | } |
| 269 | if (!m_shmBuf[sensor]) { |
| 270 | OSVR_DEV_VERBOSE( |
| 271 | "Some issue creating shared memory for imaging, skipping out."); |
| 272 | return false; |
| 273 | } |
| 274 | auto &shm = *(m_shmBuf[sensor]); |
| 275 | auto seq = shm.put(imageData, imageBufferSize); |
| 276 | |
| 277 | Buffer<> buf; |
| 278 | messages::ImagePlacedInSharedMemory::MessageSerialization serialization( |
| 279 | messages::SharedMemoryMessage{metadata, seq, sensor, |
| 280 | IPCRingBuffer::getABILevel(), |
| 281 | shm.getBackend(), shm.getName()}); |
| 282 | serialize(buf, serialization); |
| 283 | m_getParent().packMessage( |
| 284 | buf, imagePlacedInSharedMemory.getMessageType(), timestamp); |
| 285 | |
| 286 | return true; |
| 287 | } |
| 288 | |
| 289 | bool ImagingComponent::m_sendImageDataOnTheWire( |
| 290 | OSVR_ImagingMetadata metadata, OSVR_ImageBufferElement *imageData, |
nothing calls this directly
no test coverage detected