status_t PanoramaThread::PanoramaStitchThread::waitForAndExecuteMessage()
{
    LOG2("@%s", __FUNCTION__);
    status_t status = NO_ERROR;
    Message msg;
    mMessageQueue.receive(&msg);

    switch (msg.id)
    {
        case MESSAGE_ID_STITCH:
            status = handleMessageStitch(msg.data.stitch);
            break;
        case MESSAGE_ID_EXIT:
            status = handleExit();
            break;
        case MESSAGE_ID_FLUSH:
            status = handleFlush();
            break;
        default:
            status = INVALID_OPERATION;
            break;
    }
    if (status != NO_ERROR) {
        LOGE("operation failed, ID = %d, status = %d", msg.id, status);
    }
    return status;
}
Esempio n. 2
0
void VideoWidget::clear()
{
    QMutexLocker locker(&m_mutex);

    m_images.clear();
    QImage img(m_width, m_height, QImage::Format_RGB32);
    img.fill(Qt::black);

    handleImage(img);
    handleFlush();
}
Esempio n. 3
0
Renderer::Renderer(VideoWidget *video) : m_background(0, 0)
{
    m_video = video;

    m_rawFrame.m_pixels = new uint8_t[0x10000];

    m_backgroundFrame = true;

    m_mode = 3;

    connect(this, SIGNAL(image(QImage)), m_video, SLOT(handleImage(QImage))); // Qt::BlockingQueuedConnection);
    connect(this, SIGNAL(flushImage()), m_video, SLOT(handleFlush())); //, Qt::BlockingQueuedConnection);
}
Esempio n. 4
0
void AnimationThread::threadMethod() {
	while (!_killThread.load(std::memory_order_relaxed)) {
		if (EventMan.quitRequested())
			break;

		if (handlePause())
			continue;

		handleYield();

		std::lock_guard<std::recursive_mutex> lock(_modelsMutex);

		registerQueuedModels();

		if (_models.empty()) {
			EventMan.delay(100);
			continue;
		}

		for (auto &m : _models) {
			if (EventMan.quitRequested() || (_pause.load(std::memory_order_seq_cst) == kPausePaused))
				break;

			if (m.second.skippedCount < getNumIterationsToSkip(m.second.model)) {
				++m.second.skippedCount;
				continue;
			} else {
				m.second.skippedCount = 0;
			}

			handleFlush();

			uint32 now = EventMan.getTimestamp();
			float dt = 0;
			if (m.second.lastChanged > 0) {
				dt = (now - m.second.lastChanged) / 1000.0f;
			}
			m.second.lastChanged = now;

			m.second.model->manageAnimations(dt);
		}
	}
}
Esempio n. 5
0
Renderer::Renderer(VideoWidget *video)
{
    m_video = video;

    m_frameData = new uint8_t[0x20000];
    m_backgroundFrame = true;

    m_hmin = 0x00;
    m_hmax = 0xff;
    m_smin = 0x00;
    m_smax = 0xff;
    m_vmin = 0x00;
    m_vmax = 0xff;
    m_cmin = 0x00;
    m_cmax = 0xff;
    m_lut = NULL;

    m_mode = 3;

    connect(this, SIGNAL(image(QImage)), m_video, SLOT(handleImage(QImage))); // Qt::BlockingQueuedConnection);
    connect(this, SIGNAL(flushImage()), m_video, SLOT(handleFlush())); //, Qt::BlockingQueuedConnection);
}
Esempio n. 6
0
int GenericChannel::handleWrite(const unsigned char *message, unsigned int length)
{
#ifdef TEST
    *logofs << "handleWrite: Called for FD#" << fd_ << ".\n" << logofs_flush;
#endif

    //
    // Create the buffer from which to
    // decode messages.
    //

    DecodeBuffer decodeBuffer(message, length);

#if defined(TEST) || defined(INFO) || defined(FLUSH)
    *logofs << "handleWrite: Decoding messages for FD#" << fd_
            << " with " << length << " bytes in the buffer.\n"
            << logofs_flush;
#endif

    unsigned char *outputMessage;
    unsigned int outputLength;

    //
    // Tag message as generic data
    // in decompression.
    //

    unsigned char outputOpcode = X_NXInternalGenericData;

    for (;;)
    {
        decodeBuffer.decodeValue(outputLength, 32, 14);

        if (outputLength == 0)
        {
            break;
        }

        if (isCompressed() == 1)
        {
            if (writeBuffer_.getAvailable() < outputLength ||
                    (int) outputLength >= control -> TransportFlushBufferSize)
            {
#ifdef DEBUG
                *logofs << "handleWrite: Using scratch buffer for "
                        << "generic data with size " << outputLength << " and "
                        << writeBuffer_.getLength() << " bytes in buffer.\n"
                        << logofs_flush;
#endif

                outputMessage = writeBuffer_.addScratchMessage(outputLength);
            }
            else
            {
                outputMessage = writeBuffer_.addMessage(outputLength);
            }

            const unsigned char *compressedData = NULL;
            unsigned int compressedDataSize = 0;

            int decompressed = handleDecompress(decodeBuffer, outputOpcode, 0,
                                                outputMessage, outputLength, compressedData,
                                                compressedDataSize);
            if (decompressed < 0)
            {
                return -1;
            }
        }
        else
        {
#ifdef DEBUG
            *logofs << "handleWrite: Using scratch buffer for "
                    << "generic data with size " << outputLength << " and "
                    << writeBuffer_.getLength() << " bytes in buffer.\n"
                    << logofs_flush;
#endif

            writeBuffer_.addScratchMessage((unsigned char *)
                                           decodeBuffer.decodeMemory(outputLength), outputLength);
        }

#if defined(TEST) || defined(OPCODES)
        *logofs << "handleWrite: Handled generic data for FD#" << fd_
                << ". "  << outputLength << " bytes out.\n"
                << logofs_flush;
#endif

        handleFlush(flush_if_needed);
    }

    //
    // Write any remaining data to socket.
    //

    if (handleFlush(flush_if_any) < 0)
    {
        return -1;
    }

    return 1;
}