Example #1
0
void sample_queue::push(const int16_t* samples, size_t count)
{
	threads::alock h(mlock);
	size_t dsize = _available();
	if(dsize + count > size) {
		//Expand the buffer.
		std::vector<int16_t> newbuffer;
		newbuffer.resize((dsize + count + BLOCKSIZE - 1) / BLOCKSIZE * BLOCKSIZE);
		size_t trptr = rptr;
		for(size_t i = 0; i < dsize; i++) {
			newbuffer[i] = data[trptr++];
			if(trptr == size)
				trptr = 0;
		}
		data.swap(newbuffer);
		size = data.size();
		rptr = 0;
		wptr = dsize;
	}

	while(count) {
		data[wptr++] = *samples;
		if(wptr == size)
			wptr = 0;
		blank = false;
		samples++;
		count--;
	}
}
Example #2
0
int
UIPClient::available()
{
  if (*this)
    return _available(data);
  return 0;
}
Example #3
0
void KLController::h_connect(bool result)
{
    if(!result) {
        stopStream();
    }
    emit _available(result);
}
Example #4
0
void KLController::open()
{
    if(isOpened() && checkThread && checkThread->isRunning()) {
        return;
    }
    checkThread->stop();
    checkThread->wait();
    safeRelease(sensor);

    HRESULT hr = GetDefaultKinectSensor(&sensor);
    if(SUCCEEDED(hr)) {
        hr = sensor->Open();
    } else {
        emit _hrError(hr);
    }
    if(SUCCEEDED(hr)) {
        hr = sensor->get_CoordinateMapper(&coordMapper);
    } else {
        emit _hrError(hr);
    }
    if(SUCCEEDED(hr)) {
        checkThread->setSensor(sensor);
        checkThread->start();
        qDebug()<<"[KLController] Opened";
        emit _open(true);
        if(isAvailable()) {
            qDebug()<<"[KLController] Connected";
            emit _available(true);
        } else {
            qDebug()<<"[KLController] Disconnected";
            emit _available(false);
        }
    } else {
        emit _hrError(hr);
    }
}
Example #5
0
int main(int ac,char *av[])
{	const char *CC;
	const char *sym;
	int avail;
	FILE *tmp;

	if( ac < 3 ){
		fprintf(stderr,"Usage: %s CC function_name\n",av[0]);
		return -1;
	}

	tmp = tmpfile();
	CC = av[1];
	sym = av[2];
	avail = _available(tmp,sym,CC,"","");
	printf("%s is %s\n",sym,avail?"available":"not available");
	exit(avail);
}
Example #6
0
size_t sample_queue::available()
{
	threads::alock h(mlock);
	return _available();
}
Example #7
0
int
UIPClient::available()
{
  return _available(_uip_conn);
}