示例#1
0
// The real thread function
void PspAudio::threadFunction() {
	assert(_callback);
	PSP_DEBUG_PRINT_FUNC("audio thread started\n");

	while (_init) {		// Keep looping so long as we haven't been told to stop
		if (_paused)
			PSP_DEBUG_PRINT("audio thread paused\n");
		while (_paused) {	// delay until we stop pausing
			PspThread::delayMicros(100000);	// 100ms
			if (!_paused)
				PSP_DEBUG_PRINT("audio thread unpaused\n");
		}

		PSP_DEBUG_PRINT("remaining samples[%d]\n", _remainingSamples);

		PSP_DEBUG_PRINT("filling buffer[%d]\n", _bufferToFill);
		_callback(_userData, _buffers[_bufferToFill], _bufferSize); // ask mixer to fill in data
		nextBuffer(_bufferToFill);

		PSP_DEBUG_PRINT("playing buffer[%d].\n", _bufferToPlay);
		playBuffer();
		nextBuffer(_bufferToPlay);
	} // while _init

	// destroy everything
	free(_buffers[0]);
	sceAudioChRelease(_pspChannel);
	PSP_DEBUG_PRINT("audio thread exiting. ****************************\n");
}
void ReceiveThread::readyRead() {

    QHostAddress metisAddress;
    quint16 metisPort;
    unsigned char buffer[1024];

    qDebug()<<"Discovery::readyRead";

    if(socket.readDatagram((char*)&buffer,(qint64)sizeof(buffer),&metisAddress,&metisPort)>0) {

        if(buffer[0]==0xEF && buffer[1]==0xFE) {
            switch(buffer[2]) {
            case 3:  // erase completed
                qDebug()<<"commandCompleted";
                emit eraseCompleted();
                break;
            case 4:  // ready for next buffer
                qDebug()<<"ready for next buffer";
                emit nextBuffer();
                break;
            default:
                qDebug()<<"invalid reply="<<buffer[3];
                break;
            }
        } else {
            qDebug() << "received invalid response in ReceiveThread";
        }
    } else {
        qDebug()<<"ReceiveThread::readyRead: readDatagram failed";
    }
}
// Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
void FramebufferSurface::onFrameAvailable() {
    sp<GraphicBuffer> buf;
    sp<Fence> acquireFence;
    status_t err = nextBuffer(buf, acquireFence);
    if (err != NO_ERROR) {
        ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)",
                strerror(-err), err);
        return;
    }
    err = mHwc.fbPost(mDisplayType, acquireFence, buf);
    if (err != NO_ERROR) {
        ALOGE("error posting framebuffer: %d", err);
    }
}
示例#4
0
// Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
// 直接重写ConsumerBase的方法,这样就不用设置listener也能收到BufferQueue来的数据
void FramebufferSurface::onFrameAvailable() { // 每过来一帧,直接往荧幕上贴
    sp<GraphicBuffer> buf;
    sp<Fence> acquireFence;
    status_t err = nextBuffer(buf, acquireFence); // 这个buffer是已经通过SF合成好的吗?
    											  // 已经通过EGL处理过,详见DisplayDevice
    if (err != NO_ERROR) {
        ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)",
                strerror(-err), err);
        return;
    }
    err = mHwc.fbPost(mDisplayType, acquireFence, buf);
    if (err != NO_ERROR) {
        ALOGE("error posting framebuffer: %d", err);
    }
}
// Overrides ConsumerBase::onFrameAvailable(), does not call base class impl.
void FramebufferSurface::onFrameAvailable() {
    sp<GraphicBuffer> buf;
    sp<Fence> acquireFence;
    status_t err = nextBuffer(buf, acquireFence);
    if (err != NO_ERROR) {
        ALOGE("error latching nnext FramebufferSurface buffer: %s (%d)",
                strerror(-err), err);
        return;
    }
    if (acquireFence.get() && acquireFence->isValid())
        mPrevFBAcquireFence = new Fence(acquireFence->dup());
    else
        mPrevFBAcquireFence = Fence::NO_FENCE;

    lastHandle = buf->handle;
}