Beispiel #1
0
int rtdal_itfspscq_pop(r_itf_t obj, void **ptr, int *len, int tstamp) {
	cast(obj,itf);
	RTDAL_ASSERT_PARAM(ptr);
	RTDAL_ASSERT_PARAM(len);

	*ptr = NULL;
	*len = 0;

	if (spscq_is_empty(itf)) {
		qdebug("[empty] read=%d, tstamp=%d\n",itf->read,itf->packets[itf->read].tstamp);
		return 0;
	}
	if (itf->packets[itf->read].tstamp > tstamp) {
		qdebug("[delay] read=%d, tstamp=%d\n",itf->read,itf->packets[itf->read].tstamp);
		return 0;
	}
	if (itf->packets[itf->read].tstamp < tstamp && itf->parent.delay) {
		rtdal_itfspscq_release(obj);
	}

	qdebug("[ok] read=%d, tstamp=%d (now=%d)\n",itf->read,itf->packets[itf->read].tstamp,tstamp);
	*ptr = itf->packets[itf->read].data;
	*len = itf->packets[itf->read].len;

	return 1;
}
Beispiel #2
0
int rtdal_itfspscq_release(r_itf_t obj) {
	cast(obj,itf);
	if (spscq_is_empty(itf)) {
		qdebug("[empty] read=%d, tstamp=%d\n",itf->read,itf->packets[itf->read].tstamp);
		return 0;
	}

	qdebug("read=%d, tstamp=%d\n",itf->read,itf->packets[itf->read].tstamp);
	itf->packets[itf->read].valid = 0;
	itf->read += (itf->read+1 >= itf->max_msg) ? (1-itf->max_msg) : 1;

	return 1;
}
Beispiel #3
0
int rtdal_itfspscq_pop(r_itf_t obj, void **ptr, int *len, int tstamp) {
	cast(obj,itf);
	RTDAL_ASSERT_PARAM(ptr);
	RTDAL_ASSERT_PARAM(len);

	*ptr = NULL;
	*len = 0;

	if (spscq_is_empty(itf,tstamp)) {
		if (itf->parent.delay==-2) {
			usleep(1000);
		}
		qdebug("[empty] read=%d write=%d\n",itf->read,itf->write);
		return 0;
	}

	if (itf->parent.delay >= 0 ) {
#ifdef USE_SYSTEM_TSTAMP
		tstamp=rtdal_time_slot();
#endif
		if (itf->packets[itf->read].tstamp > tstamp) {
			qdebug("[delay] read=%d, tstamp=%d now=%d\n",itf->read,itf->packets[itf->read].tstamp,tstamp);
			return 0;
		}
/*
		if (itf->packets[itf->read].tstamp < tstamp-1) {
			qdebug("[old] read=%d, tstamp=%d now=%d\n",itf->read,itf->packets[itf->read].tstamp,tstamp);
			rtdal_itfspscq_release(obj,NULL,0);
			return 2;
		}
*/
	}

	qdebug("[ok] read=%d, tstamp=%d (now=%d)\n",itf->read,itf->packets[itf->read].tstamp,tstamp);
	*ptr = itf->packets[itf->read].data;
	*len = itf->packets[itf->read].len;

	return 1;
}