Esempio n. 1
0
    void Button::onMouseClick(MouseButton button, MouseState state, const Vector2& mousePosition)
    {
        if (button == BUTTON_LEFT)
        {
            mIsPressed = !mIsPressed;

			computeState();

            if (state == MOUSE_DOWN)
                mCallBack(button, state, mousePosition);
        }
    }
void CommandGetSplineData::execute()
{
	SplineDataModel* data = nullptr;
	Model* model = static_cast<Model*>(PropertyOwner::lockPropertyOwner(mModel));
	if (model != nullptr) {
		data = model->getSplineDataModel(mSpline);
		model->unLock();
	}

	mCallBack(data);

	delete data;
	data = nullptr;
}
Esempio n. 3
0
void USBBuffer::transfer_callback(struct libusb_transfer *transfer) {
	mCallBack(this);
}
Esempio n. 4
0
void AVSyncer::ThdRun() {
	int result;
	unsigned long    stp;
	unsigned long    curTime = 0;
	struct timespec  sys_time = {0,0};
	struct timespec  ts;
	struct timeval   tt;
	AVSyncRtpData *  ptr;
	mThdRun = true;
	//pthread_detach(pthread_self());
	//sem_post(&mSyncSem);
	while(mThdRun) {
		gettimeofday(&tt, NULL);
		//ts.tv_sec = tt.tv_sec + WAITTIMEOUT;
		//ts.tv_nsec = tt.tv_usec*1000;
		ts.tv_sec = tt.tv_sec + (tt.tv_usec/1000 + WAITTIMEOUT)/1000;
		ts.tv_nsec = ((tt.tv_usec + WAITTIMEOUT*1000)%1000000) * 1000;
#ifdef __MACH__
        result = sem_timedwait(mSyncSem, &ts);
#else
        result = sem_timedwait(&mSyncSem, &ts);
#endif
		if(!mThdRun){
			break;
		}
		if(result == 0){
			//LOGE("result is 0?\n");
			// 有信号过来
			// 1. 同步,2. 组帧
			/***  视频  ***/
			if(0 == pthread_mutex_lock(&mVideoLock)) {
				//lock
				if(mVideoListHead != NULL) {
					stp = mVideoListHead->mRtpStp;
					clock_gettime(CLOCK_MONOTONIC,&sys_time);
					curTime = sys_time.tv_sec * 1000 + sys_time.tv_nsec/1000000;
					if(curTime >= stp) {
						// stp过去时间,音视频应该被播放了
						/*if(checkMark(stp)) {
							// have mark, 组帧
						} else {
							// drop
						}*/
						resetRtpUnpack();
						// mark不一定有,看time stamp是否一样
						while(NULL != mVideoListHead && mVideoListHead->mRtpStp == stp) {
							unpackH264(mVideoListHead->mAVData + FIXRTPHEADLEN,
									mVideoListHead->mDataLen - FIXRTPHEADLEN);
							ptr = mVideoListHead;//需要删除
                            // sps/pps/I 帧放到一起。sei跟I/P帧放一起。所以,不看mark位了,只看时间戳。
							/*if(mVideoListHead->mMarker) {
								mVideoListHead = mVideoListHead->next;
								if(NULL != mVideoListHead){
									mVideoListHead->prev = NULL;
								}
								deleteRtpData(ptr);
								break;//mark位,双重判断
							}*/
							mVideoListHead = mVideoListHead->next;
							if(NULL != mVideoListHead){
								mVideoListHead->prev = NULL;
							}
							deleteRtpData(ptr);
						} // end while
						if(mMediaInfo.frame_len > 0) {
							//call back
							if(mCallBack) {
								mCallBack(mMediaInfo.memory_buf, mMediaInfo.frame_len, 0, stp);
							}
							/*LOGI("date len=%u, stp=%u, %x-%x-%x-%x-%x-%x", mMediaInfo.frame_len, stp,
									mMediaInfo.memory_buf[0], mMediaInfo.memory_buf[1],
									mMediaInfo.memory_buf[2], mMediaInfo.memory_buf[3],
									mMediaInfo.memory_buf[4], mMediaInfo.memory_buf[5]);*/
						}
					}
				}
				//unlock
				pthread_mutex_unlock(&mVideoLock);
			}
			/***  音频  ***/
			if(0 == pthread_mutex_lock(&mAudioLock)) {
				// lock
				if(mAudioListHead != NULL) {
					stp = mAudioListHead->mRtpStp;
					clock_gettime(CLOCK_MONOTONIC,&sys_time);
					curTime = sys_time.tv_sec * 1000 + sys_time.tv_nsec/1000000;
					if(curTime >= stp) {
						resetRtpUnpack();
						while(NULL != mAudioListHead && mAudioListHead->mRtpStp == stp) {
							unpackPCM(mAudioListHead->mAVData + FIXRTPHEADLEN,
									mAudioListHead->mDataLen - FIXRTPHEADLEN);
							ptr = mAudioListHead;//需要删除
							if(mAudioListHead->mMarker) {
								mAudioListHead = mAudioListHead->next;
								if(NULL != mAudioListHead) {
									mAudioListHead->prev = NULL;
								}
								deleteRtpData(ptr);
								break;//mark位,双重判断
							}
							mAudioListHead = mAudioListHead->next;
							if(NULL != mAudioListHead) {
								mAudioListHead->prev = NULL;
							}
							deleteRtpData(ptr);
						}
                        LOGE("audio info len=%d\n", mMediaInfo.frame_len);
						if(mMediaInfo.frame_len > 0) {
							//call back
							if(mCallBack) {
								mCallBack(mMediaInfo.memory_buf, mMediaInfo.frame_len, 1, stp);
							}
						}
					}
				}
				// unlock
				pthread_mutex_unlock(&mAudioLock);
			}
		} else {
			//LOGE("errno value :%d ,it means %s\n", errno, strerror(errno));
			// 超时
			// 清空队列?
		}
	}// end while
	// 释放资源,防止内存泄漏
	if(0 == pthread_mutex_lock(&mVideoLock)){
		while(NULL != mVideoListHead){
			ptr = mVideoListHead;
			mVideoListHead = mVideoListHead->next;
			if(NULL != mVideoListHead){
				mVideoListHead->prev = NULL;
			}
			deleteRtpData(ptr);
		}
		pthread_mutex_unlock(&mVideoLock);
	}
	if(0 == pthread_mutex_lock(&mAudioLock)) {
		while(NULL != mAudioListHead){
			ptr = mAudioListHead;
			mAudioListHead = mAudioListHead->next;
			if(NULL != mAudioListHead) {
				mAudioListHead->prev = NULL;
			}
			deleteRtpData(ptr);
		}
	}
}// thread