示例#1
0
文件: fcgi.c 项目: amery/clip-itk
int
clip_FCGI_ACCEPT(ClipMachine *mp)
{
	int r;

	if (inited)
	{
		flush_bufs();
		FCGX_Finish();
	}

	r = FCGX_Accept(&in, &out, &err, &envp);
	/*r = FCGI_Accept();*/
	_clip_retl(mp, (r >= 0) ? 1 : 0);

	if (!inited)
	{
		inited = 1;

		init_Buf(&obuf);
		init_Buf(&ebuf);

		mp->obuf = &obuf;
		mp->ebuf = &ebuf;
	}

	return 0;
}
示例#2
0
文件: fcgi.c 项目: amery/clip-itk
int
clip_FCGI_FLUSH(ClipMachine *mp)
{
	int r;

	if (!inited)
		return EG_ARG;

	r = flush_bufs();

	_clip_retl(mp, !r);

	return 0;
}
示例#3
0
int send_cached_pkts(VhostServer* port,  void* input_buf, size_t size){
	int ret=0;
	VringTable* vring_table = &port->vring_table;

	ret = flush_bufs(vring_table);
	if (input_buf != 0) {
		if (vring_table->start_i == vring_table->end_i) {
			ret = send_pkt(&port->vring_table, VHOST_CLIENT_VRING_IDX_RX,input_buf, size);
			if (ret < 0) {
				ret = 0;
				ret = insert_buf(vring_table, input_buf, size);
			}
			return ret;
		} else {
			ret = ret + insert_buf(vring_table, input_buf, size);
		}
	}

	return ret;
}
示例#4
0
int cross_stitch(dataptr dz) {
	double srate = (double)dz->infile->srate;
	int n = 0, mbf, sbf, procend, input_procend;
	int exit_status, t = 0,v=0,m=0,done = 0;
	double *brrk = NULL, thisval, nextval = 0.0, valincr, atten = 0.0, val_here;
	double time_here, lastrtime,nextrtime, lastval, tratio;

	int nexttime = 0, thistime;
	float *buf0 = dz->sampbuf[0];
	float *buf1 = dz->sampbuf[1];
	int typ;
	int input_procskip, samps_to_skip = 0;

	if(dz->param[MIX_SKEW] <= dz->param[MIX_SKIP]) {
		sprintf(errstr,"Start and end times of mix are reversed, or equal.\n");
		return(DATA_ERROR);
	}
	/* RWD make this samps */
	dz->tempsize = 
	(int)round((dz->param[MIX_SKEW] - dz->param[MIX_SKIP]) * (double)(srate * 
	max(dz->infile->channels,dz->otherfile->channels)));
	display_virtual_time(0,dz);
	if(dz->infile->channels > 2) {
		typ = 4;	/* multichan multichan */
	} else if(dz->infile->channels==1) {
		if(dz->otherfile->channels==1) {
			typ = 0; 	/* mono mono */
		} else {	
			typ = 1;	/* mono stereo */
		}
	} else {
		if(dz->otherfile->channels==1) {
			typ = 2; 	/* stereo mono */
		} else {	
			typ = 3;	/* stereo stereo */
		}
	}
	procend = dz->insams[0]/dz->infile->channels;
	input_procend = (int)round(dz->param[MIX_SKEW] * srate);
	procend = min(procend,input_procend);

	if((input_procskip = (int)round(dz->param[MIX_SKIP] * srate)) > 0) {
		samps_to_skip = input_procskip * dz->infile->channels;
//TW SAFE??
//		samps_to_skip /= (F_SECSIZE * dz->infile->channels);
//		samps_to_skip *= (F_SECSIZE * dz->infile->channels);	/* skip to nearest sector */

		if((sndseekEx(dz->ifd[0],samps_to_skip,0))<0) {
			sprintf(errstr,"seek() failed searching for startpoint of mix in first file.\n");
			return(SYSTEM_ERROR);
		}
		samps_to_skip = input_procskip * dz->otherfile->channels;
//TW SAFE??
//		samps_to_skip /= (F_SECSIZE * dz->otherfile->channels);
//		samps_to_skip *= (F_SECSIZE * dz->otherfile->channels);	/* skip to nearest sector */

		if((sndseekEx(dz->ifd[1],samps_to_skip,0))<0) {
			sprintf(errstr,"sndseek() failed searching for startpoint of mix in second file.\n");
			return(SYSTEM_ERROR);
		}
	}
	if(dz->brksize[MIX_STAGGER]) {
		brrk = dz->brk[MIX_STAGGER];
		if(input_procskip > 0) {
			thistime = samps_to_skip/dz->otherfile->channels;
			time_here = (double)thistime/srate;
			m = 0;
			while(brrk[m] <= time_here) {
				m += 2;
				if(m >= dz->brksize[MIX_STAGGER]) {			/* IF beyond end of brk */
					dz->param[MIX_STAGGER] = brrk[m-1];		/* set atten to last brkval */
					dz->brksize[MIX_STAGGER] = 0;			/* set brkfile as not existing */
					break;
				}
			}
			if(dz->brksize[MIX_STAGGER]) {					/* If still in brkfile */
				lastrtime = brrk[m-2];						/* Note previous brkpnt-time+val */
				lastval   = brrk[m-1];
				n = thistime;								/* set the internal sample counter to here */
				t = m;										/* set pointer for (following) brkpnt times */
				v = m+1;									/* set pointer for (following) brkpnt vals */
				m /= 2;										/* set position in brk-pairs */
				nextrtime = brrk[t];
				nexttime  = round(nextrtime * srate);
				nextval   = brrk[v];						
															/* calc value at start-time */
				tratio = (double)(time_here - lastrtime)/(double)(nextrtime - lastrtime);
				val_here = ((nextval - lastval) * tratio) + lastval;
				nexttime = thistime;						/* set up starting time & val */
				nextval  = val_here;
			}								
		} else {
			nexttime = round(brrk[0] * srate);
			nextval  = brrk[1];	/* set up starting time & val */
			n = 0;			   	/* set the internal sample counter to start */
			t = 2;			   	/* set pointer for (following) brkpnt times */
			v = 3;			   	/* set pointer for (following) brkpnt vals */
			m = 1;			   	/* set position in brk-pairs */
		}
	} else {
		n = input_procskip;
	}
	memset((char *)buf0,0,dz->buflen * dz->infile->channels* sizeof(float));
	memset((char *)buf1,0,dz->buflen * dz->otherfile->channels * sizeof(float));
	if((fgetfbufEx(buf0,dz->buflen * dz->infile->channels,dz->ifd[0],0)) < 0) {
		sprintf(errstr,"Can't read samps from 1st soundfile.\n");
		return(SYSTEM_ERROR);
	}
	if((fgetfbufEx(buf1,dz->buflen * dz->otherfile->channels,dz->ifd[1],0)) < 0) {
		sprintf(errstr,"Can't read samps from 2nd soundfile.\n");
		return(SYSTEM_ERROR);
	}
	mbf = 0;
	sbf = 0;
	if(dz->brksize[MIX_STAGGER] == 0)
		atten = dz->param[MIX_STAGGER];
	else {
		for(; m < dz->brksize[MIX_STAGGER]; m++,t+=2,v+=2) {
			thistime = nexttime;
			thisval  = nextval;
			nexttime = round(brrk[t] * srate);
			nextval  = brrk[v];
			valincr = (nextval - thisval)/(double)(nexttime - thistime);
			if(nexttime >= procend) {		/* IF brktable extends beyond end of sound */
				nexttime = procend;
				done = 1;
			}
			atten = thisval;
			while(n < nexttime) {
  				if(do_stitch(typ,&mbf,&sbf,buf0,buf1,atten,dz->buflen,dz)) {
					if((exit_status = renew_bufs(typ,buf0,buf1,dz))<0)
						return(exit_status);
					mbf = 0;
					sbf = 0;
				}
				atten += valincr;
				n++;
			}
			if(done)				   	/* IF brktable extends beyond end of sound: break */
				break;
		}
	}
	while(n < procend) {				/* IF brktable stops short of end of sound, or no brktable */
		if(do_stitch(typ,&mbf,&sbf,buf0,buf1,atten,dz->buflen,dz)) {
			if((exit_status = renew_bufs(typ,buf0,buf1,dz))<0)
				return(exit_status);
			mbf = 0;
			sbf = 0;
		}
		n++;
	}
	return flush_bufs(typ,&mbf,&sbf,buf0,buf1,dz);
}