void MeshViewerWidget::openFile(const QString & filename) { m_ready = false; qWarning() << "Loading file: "<< filename; if(m_obj){delete m_obj;} m_obj = new Mesh2f(); Mesh2IOUtils::OBJParser<NumericalTraitsXf> parser(m_obj); parser.read(filename.toStdString()); MeshUtils::normalize(*m_obj); std::cout << m_obj->vertices.size() << std::endl; std::cout << m_obj->faces.size() << std::endl; sendBuffers(); }
int TCPConnectionHandler::handle_output (ACE_HANDLE handle) { ACE_UNUSED_ARG (handle); if (!buffers_) ACE_ERROR ((LM_ERROR, ACE_TEXT ("TCPConnectionHandler::handle_output call for empty buffers (%d)\n"), handle)); if (0 > sendBuffers ()) // socket broken, kill yourself return -1; if (!buffers_) // everything already send, unregister { reactor ()->cancel_wakeup (this, ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL); reactor ()->remove_handler (this, ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL); } return 0; }
int TCPConnectionHandler::scheduleSend (ACE_Message_Block * buffer) { // link buffer to the end of buffers list if (buffers_) { ACE_Message_Block *lastBuffer = buffers_; while (lastBuffer->cont ()) lastBuffer = lastBuffer->cont () ; lastBuffer->cont (buffer); } else buffers_ = buffer; if (0 > sendBuffers ()) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT (" (%P) %p\n"), ACE_TEXT ("Cannot schedule TCP send.")), -1); return 0; }
void LevelSetViewerWidget::openFile(const QString & filename) { m_ready = false; qWarning() << "Loading file: "<< filename; if(m_obj){delete m_obj;} std::ifstream in(filename.toStdString().c_str()); if(m_grid){delete m_grid;} m_grid = new Gridf(); m_grid->read(in); std::cout << m_grid->NI() << " " << m_grid->NJ() << " " << m_grid->NK() << std::endl; MarchingSquaresGridf phi(*m_grid); m_obj = new Mesh2f(); phi.populateMesh(*m_obj,0); MeshUtils::normalize(*m_obj); std::cout << m_obj->vertices.size() << std::endl; std::cout << m_obj->faces.size() << std::endl; sendBuffers(); }
void MmalVideoCamera::createBufferPool() { if (m_videoPort == NULL) { throw Exception("Target port is not set."); } // Create pool of buffer headers for the output port to consume m_videoPort->buffer_num = VIDEO_OUTPUT_BUFFERS_NUM; m_videoPort->buffer_size = m_videoPort->buffer_size_recommended; m_pool = mmal_port_pool_create(m_videoPort, MAX(m_videoPort->buffer_num, NUM_IMAGE_BUFFERS), m_videoPort->buffer_size); if (m_pool == NULL) { throw Exception("Failed to create buffer header pool for encoder output port"); } // Set the userdata m_callbackData->pool = m_pool; m_callbackData->acquire = false; m_videoPort->userdata = (struct MMAL_PORT_USERDATA_T *) m_callbackData; // Enable the encoder output port and tell it its callback function if (mmal_port_enable(m_videoPort, EncoderBufferCallback) != MMAL_SUCCESS) { throw Exception("Error enabling the encoder buffer callback"); } else { m_videoPortEnabled = true; } // Send all the buffers to the encoder output port sendBuffers(); // Start the capture if (mmal_port_parameter_set_boolean(m_videoPort, MMAL_PARAMETER_CAPTURE, 1) != MMAL_SUCCESS) { throw Exception("Error starting the camera capture"); } }
static TR_STATUS sendBuffers(net_fd appfd, struct iovec *buffers, int bufferCount) { struct msghdr msg; int sent, n, s = appfd->s; struct timeval tv; fd_set wset; TR_STATUS ret = TR_OK; if (appfd->status != TR_OK) return TR_ERROR; while (bufferCount > 0 && ret == TR_OK) { memset(&msg, 0, sizeof(msg)); msg.msg_iov = buffers; msg.msg_iovlen = bufferCount; sent = sendmsg(s, &msg, 0); if (sent < 0) { int ec = WA_error(); if (WA_msgSize(ec)) { if (bufferCount > 1) { ret = sendBuffers(appfd, buffers, bufferCount/2); if (ret == TR_OK) ret = sendBuffers(appfd, &buffers[bufferCount/2], bufferCount - bufferCount/2); bufferCount = 0; } else ret = TR_ERROR; } else if (WA_wouldBlock(ec)) { FD_ZERO(&wset); FD_SET(s, &wset); tv.tv_sec = appfd->send_to; tv.tv_usec = 0; n = select(s + 1, NULL, &wset, NULL, &tv); if (n == 0) { /* Timed out */ WOLog(WO_DBG, "sendBuffers(): timed out"); ret = TR_TIMEOUT; } else if (n < 0) { char *errMsg = WA_errorDescription(WA_error()); WOLog(WO_ERR, "sendbytes(): select error: %s", errMsg); WA_freeErrorDescription(errMsg); ret = TR_ERROR; } /* Drop back into the while loop and retry the send() */ } else if (WA_intr(ec)) { /* Try send again */ } else if (WA_brokenPipe(ec)) { ret = TR_RESET; } else { /* If we get any other error, bail out. */ char *errMsg = WA_errorDescription(WA_error()); WOLog(WO_ERR, "sendBuffers(): send error: %s", errMsg); WA_freeErrorDescription(errMsg); ret = TR_ERROR; break; } } else { /* be sure all data was sent */ while (sent > 0) { if (sent >= buffers->iov_len) { sent -= buffers->iov_len; buffers++; bufferCount--; } else { buffers->iov_base = (caddr_t)buffers->iov_base + sent; buffers->iov_len -= sent; sent = 0; } } while (bufferCount > 0 && buffers->iov_len == 0) { buffers++; bufferCount--; } } } appfd->status = ret; return ret; }