コード例 #1
0
ファイル: client.cpp プロジェクト: ezhangle/OF-Engine
void gets2c()           // get updates from the server
{
    ENetEvent event;
    if(!clienthost) return;
    if(connpeer && totalmillis/3000 > connmillis/3000)
    {
        conoutf("attempting to connect...");
        connmillis = totalmillis;
        ++connattempts;
        if(connattempts > 3)
        {
            conoutf("\f3could not connect to server");
            abortconnect();
            return;
        }
    }
    while(clienthost && enet_host_service(clienthost, &event, 0)>0)
    switch(event.type)
    {
        case ENET_EVENT_TYPE_CONNECT:
            disconnect(false, false);
            localdisconnect(false);
            curpeer = connpeer;
            connpeer = NULL;
            conoutf("connected to server");
            throttle();
            if(rate) setrate(rate);
            game::gameconnect(true);
            break;

        case ENET_EVENT_TYPE_RECEIVE:
            if(discmillis) conoutf("attempting to disconnect...");
            else localservertoclient(event.channelID, event.packet);
            enet_packet_destroy(event.packet);
            break;

        case ENET_EVENT_TYPE_DISCONNECT:
            extern const char *disc_reasons[10]; /* because gcc 4.2 is retarded */
            if(event.data>=DISC_NUM) event.data = DISC_NONE;
            if(event.peer==connpeer)
            {
                conoutf("\f3could not connect to server");
                abortconnect();
            }
            else
            {
                if(!discmillis || event.data) conoutf("\f3server network error, disconnecting (%s) ...", disc_reasons[event.data]);
                disconnect();
            }
            return;

        default:
            break;
    }
}
コード例 #2
0
CButterXOver::CButterXOver()
{
	in_2=outA1=in_1=out_2_A2=out_1_A2=0.f;

	freq = (nPre-1) << 2;

	samplerate = 0.f;
	setrate(44100.0);
	
	settype(0.f);
}
コード例 #3
0
ファイル: client.cpp プロジェクト: red-eclipse/oldsvnbf
void gets2c()           // get updates from the server
{
    ENetEvent event;
    if(!clienthost) return;
    if(connpeer && totalmillis/3000 > connmillis/3000)
    {
        connmillis = totalmillis;
        ++connattempts;
        if(connattempts > 3)
        {
            conoutft(CON_MESG, "\frcould not connect to server");
            connectfail();
            return;
        }
        else conoutft(CON_MESG, "\faconnection attempt %d", connattempts);
    }
    while(clienthost && enet_host_service(clienthost, &event, 0)>0)
    switch(event.type)
    {
        case ENET_EVENT_TYPE_CONNECT:
            disconnect(1);
            curpeer = connpeer;
            connpeer = NULL;
            conoutft(CON_MESG, "\fgconnected to server");
            throttle();
            if(rate) setrate(rate);
            client::gameconnect(true);
            break;

        case ENET_EVENT_TYPE_RECEIVE:
            if(discmillis) conoutft(CON_MESG, "\faattempting to disconnect...");
            else localservertoclient(event.channelID, event.packet);
            enet_packet_destroy(event.packet);
            break;

        case ENET_EVENT_TYPE_DISCONNECT:
            if(event.data>=DISC_NUM) event.data = DISC_NONE;
            if(event.peer==connpeer)
            {
                conoutft(CON_MESG, "\frcould not connect to server");
                connectfail();
            }
            else
            {
                if(!discmillis || event.data) conoutft(CON_MESG, "\frserver network error, disconnecting (%s) ...", disc_reasons[event.data]);
                disconnect();
            }
            return;

        default:
            break;
    }
}
コード例 #4
0
bool multiplayer(bool msg)
{
    // check if we're playing alone
    int n = client::otherclients();
    if(n && msg) conoutft(CON_MESG, "\froperation not available with other clients");
    return n > 0;
}

void setrate(int rate)
{
   if(!curpeer) return;
    enet_host_bandwidth_limit(clienthost, rate*1024, rate*1024);
}

VARF(0, rate, 0, 0, 1024, setrate(rate));

void throttle();

VARF(0, throttle_interval, 0, 5, 30, throttle());
VARF(0, throttle_accel, 0, 2, 32, throttle());
VARF(0, throttle_decel, 0, 2, 32, throttle());

void throttle()
{
    if(!curpeer) return;
    ASSERT(ENET_PEER_PACKET_THROTTLE_SCALE==32);
    enet_peer_throttle_configure(curpeer, throttle_interval*1000, throttle_accel, throttle_decel);
}

bool connected(bool attempt, bool local)
コード例 #5
0
ファイル: irixread.c プロジェクト: Distrotech/audiofile
main (int argc, char **argv)
{
	AFfilehandle	file;
	AFframecount	count, frameCount;
	int		channelCount, sampleFormat, sampleWidth;
	float		frameSize;
	void		*buffer;
	double		sampleRate;

	ALport		outport;
	ALconfig	outportconfig;

	if (argc < 2)
		usage();

	file = afOpenFile(argv[1], "r", NULL);
	if (file == AF_NULL_FILEHANDLE)
	{
		fprintf(stderr, "Could not open file %s.\n", argv[1]);
		exit(EXIT_FAILURE);
	}

	frameCount = afGetFrameCount(file, AF_DEFAULT_TRACK);
	frameSize = afGetVirtualFrameSize(file, AF_DEFAULT_TRACK, 1);
	channelCount = afGetVirtualChannels(file, AF_DEFAULT_TRACK);
	sampleRate = afGetRate(file, AF_DEFAULT_TRACK);
	afGetVirtualSampleFormat(file, AF_DEFAULT_TRACK, &sampleFormat,
		&sampleWidth);

	if (sampleFormat == AF_SAMPFMT_UNSIGNED)
	{
		afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK,
			AF_SAMPFMT_TWOSCOMP, sampleWidth);
	}

	printf("frame count: %lld\n", frameCount);
	printf("frame size: %d bytes\n", (int) frameSize);
	printf("channel count: %d\n", channelCount);
	printf("sample rate: %.2f Hz\n", sampleRate);
	buffer = malloc(BUFFERED_FRAME_COUNT * frameSize);

	outportconfig = alNewConfig();
	setwidth(outportconfig, sampleWidth);
	setsampleformat(outportconfig, sampleFormat);
	alSetChannels(outportconfig, channelCount);

	count = afReadFrames(file, AF_DEFAULT_TRACK, buffer, BUFFERED_FRAME_COUNT);

	outport = alOpenPort("irixread", "w", outportconfig);
	setrate(outport, sampleRate);

	do
	{
		printf("count = %lld\n", count);
		alWriteFrames(outport, buffer, count);

		count = afReadFrames(file, AF_DEFAULT_TRACK, buffer,
			BUFFERED_FRAME_COUNT);
	} while (count > 0);

	waitport(outport);

	alClosePort(outport);
	alFreeConfig(outportconfig);

	afCloseFile(file);
}
コード例 #6
0
ファイル: client.cpp プロジェクト: red-eclipse/oldsvnbf
bool multiplayer(bool msg)
{
    // check if we're playing alone
    int n = client::otherclients();
    if(n && msg) conoutft(CON_MESG, "\froperation not available with other clients");
    return n > 0;
}

void setrate(int rate)
{
   if(!curpeer) return;
    enet_host_bandwidth_limit(clienthost, rate, rate);
}

VARF(0, rate, 0, 0, 25000, setrate(rate));

void throttle();

VARF(0, throttle_interval, 0, 5, 30, throttle());
VARF(0, throttle_accel, 0, 2, 32, throttle());
VARF(0, throttle_decel, 0, 2, 32, throttle());

void throttle()
{
    if(!curpeer) return;
    ASSERT(ENET_PEER_PACKET_THROTTLE_SCALE==32);
    enet_peer_throttle_configure(curpeer, throttle_interval*1000, throttle_accel, throttle_decel);
}

bool connected(bool attempt)
コード例 #7
0
ファイル: mwlstats.c プロジェクト: JabirTech/Source
static int
mwl_get_totstat(struct statfoo *sf, int s, char b[], size_t bs)
{
	struct mwlstatfoo_p *wf = (struct mwlstatfoo_p *) sf;
#define	STAT(x) \
	snprintf(b, bs, "%u", wf->total.mst_##x); return 1
#define	HWSTAT(x) \
	snprintf(b, bs, "%u", wf->total.hw_stats.x); return 1
#define	TXANT(x) \
	snprintf(b, bs, "%u", wf->total.mst_ant_tx[x]); return 1
#define	RXANT(x) \
	snprintf(b, bs, "%u", wf->total.mst_ant_rx[x]); return 1

	switch (s) {
	case S_INPUT:
		snprintf(b, bs, "%lu", (u_long)wf->total.mst_rx_packets);
		return 1;
	case S_OUTPUT:
		snprintf(b, bs, "%lu", (u_long) wf->total.mst_tx_packets);
		return 1;
	case S_RATE:
		setrate(b, bs, wf->total.mst_tx_rate);
		return 1;
	case S_TX_RETRY:	HWSTAT(TxRetrySuccesses);
	case S_TX_MRETRY:	HWSTAT(TxMultipleRetrySuccesses);
	case S_TX_RTSGOOD:	HWSTAT(RTSSuccesses);
	case S_TX_RTSBAD:	HWSTAT(RTSFailures);
	case S_TX_NOACK:	HWSTAT(AckFailures);
	case S_RX_DUPLICATE:	HWSTAT(RxDuplicateFrames);
	case S_RX_FCS:		HWSTAT(FCSErrorCount);
	case S_TX_WATCHDOG:	HWSTAT(TxWatchDogTimeouts);
	case S_RX_OVERFLOW:	HWSTAT(RxOverflows);
	case S_RX_FRAGERROR:	HWSTAT(RxFragErrors);
	case S_RX_MEMERROR:	HWSTAT(RxMemErrors);
	case S_PTRERROR:	HWSTAT(PointerErrors);
	case S_TX_UNDERFLOW:	HWSTAT(TxUnderflows);
	case S_TX_DONE:		HWSTAT(TxDone);
	case S_TX_DONEBUFPUT:	HWSTAT(TxDoneBufPut);
	case S_TX_WAIT4BUF:	HWSTAT(Wait4TxBuf);
	case S_TX_ATTEMPTS:	HWSTAT(TxAttempts);
	case S_TX_SUCCESS:	HWSTAT(TxSuccesses);
	case S_TX_FRAGS:	HWSTAT(TxFragments);
	case S_TX_MCAST:	HWSTAT(TxMulticasts);
	case S_RX_NONCTL:	HWSTAT(RxNonCtlPkts);
	case S_RX_MCAST:	HWSTAT(RxMulticasts);
	case S_RX_UNDECRYPT:	HWSTAT(RxUndecryptableFrames);
	case S_RX_ICVERROR:	HWSTAT(RxICVErrors);
	case S_RX_EXCLUDE:	HWSTAT(RxExcludedFrames);
	case S_TX_MGMT:		STAT(tx_mgmt);
	case S_TX_DISCARD:	STAT(tx_discard);
	case S_TX_QSTOP:	STAT(tx_qstop);
	case S_TX_ENCAP:	STAT(tx_encap);
	case S_TX_NOMBUF:	STAT(tx_nombuf);
	case S_TX_LINEAR:	STAT(tx_linear);
	case S_TX_NODATA:	STAT(tx_nodata);
	case S_TX_BUSDMA:	STAT(tx_busdma);
	case S_TX_SHORTPRE:	STAT(tx_shortpre);
	case S_TX_NOHEADROOM:	STAT(tx_noheadroom);
	case S_TX_BADFRAMETYPE:	STAT(tx_badframetype);
	case S_RX_CRYPTO_ERR:	STAT(rx_crypto);
	case S_RX_TKIPMIC:	STAT(rx_tkipmic);
	case S_RX_NODMABUF:	STAT(rx_nodmabuf);
	case S_RX_DMABUFMISSING:STAT(rx_dmabufmissing);
	case S_RX_NOMBUF:	STAT(rx_nombuf);
	case S_RX_BUSDMA:	STAT(rx_busdma);
	case S_AMPDU_NOSTREAM:	STAT(ampdu_nostream);
	case S_AMPDU_REJECT:	STAT(ampdu_reject);
	case S_ADDBA_NOSTREAM:	STAT(addba_nostream);
	case S_TX_TSO:		STAT(tx_tso);
	case S_TSO_BADETH:	STAT(tso_badeth);
	case S_TSO_NOHDR:	STAT(tso_nohdr);
	case S_TSO_BADSPLIT:	STAT(tso_badsplit);
	case S_BAWATCHDOG:	STAT(bawatchdog);
	case S_BAWATCHDOG_NOTFOUND:STAT(bawatchdog_notfound);
	case S_BAWATCHDOG_EMPTY: STAT(bawatchdog_empty);
	case S_BAWATCHDOG_FAILED:STAT(bawatchdog_failed);
	case S_RADARDETECT:	STAT(radardetect);
	case S_RX_RSSI:
		snprintf(b, bs, "%d", wf->total.mst_rx_rssi);
		return 1;
	case S_ANT_TX0:		TXANT(0);
	case S_ANT_TX1:		TXANT(1);
	case S_ANT_TX2:		TXANT(2);
	case S_ANT_TX3:		TXANT(3);
	case S_ANT_RX0:		RXANT(0);
	case S_ANT_RX1:		RXANT(1);
	case S_ANT_RX2:		RXANT(2);
	case S_ANT_RX3:		RXANT(3);
	case S_RX_NOISE:
		snprintf(b, bs, "%d", wf->total.mst_rx_noise);
		return 1;
	case S_RX_SIGNAL:
		snprintf(b, bs, "%d",
			wf->total.mst_rx_rssi + wf->total.mst_rx_noise);
		return 1;
	}
	b[0] = '\0';
	return 0;
#undef RXANT
#undef TXANT
#undef HWSTAT
#undef STAT
}
コード例 #8
0
ファイル: client.cpp プロジェクト: bartbes/CubeCreate
void gets2c()           // get updates from the server
{
    ENetEvent event;
    if(!clienthost) return;
    if(connpeer && totalmillis/3000 > connmillis/3000)
    {
        conoutf("attempting to connect...");
        connmillis = totalmillis;
        ++connattempts; 
        if(connattempts > 3)
        {
            conoutf("\f3could not connect to server");
            abortconnect();
            return;
        }
    }
    while(clienthost && enet_host_service(clienthost, &event, 0)>0)
    switch(event.type)
    {
        case ENET_EVENT_TYPE_CONNECT:
            disconnect(false, false); 
            localdisconnect(false);
            curpeer = connpeer;
            connpeer = NULL;
            conoutf("connected to server");
            throttle();
            if(GETIV(rate)) setrate(GETIV(rate));
            game::gameconnect(true);
            break;
         
        case ENET_EVENT_TYPE_RECEIVE:
#if CLIENT // INTENSITY
            if(discmillis) conoutf("attempting to disconnect...");
            else localservertoclient(event.channelID, event.packet);
            enet_packet_destroy(event.packet);
#else // SERVER
            assert(0);
#endif
            break;

        case ENET_EVENT_TYPE_DISCONNECT:
//            LogicSystem::init(); // INTENSITY: Not sure about this...?

            extern const char *disc_reasons[];
            if(event.data>=DISC_NUM) event.data = DISC_NONE;
            if(event.peer==connpeer)
            {
                conoutf("\f3could not connect to server");
                abortconnect();
            }
            else
            {
                if(!discmillis || event.data) conoutf("\f3server network error, disconnecting (%s) ...", disc_reasons[event.data]);
                disconnect();
            }
            return;

        default:
            break;
    }
}