Ejemplo n.º 1
0
int CPaInput::Open( int bBlocking, int nDev, int nChannels, int nFormat, double dLatency, double dSRate, int fpb )
{_STT();

	// Lose old stream
	Destroy();

	PaStreamParameters psp;
	oexZero( psp );

	if ( 0 > fpb )
		fpb = 1024;

	psp.device = nDev;
	psp.channelCount = nChannels;
	psp.suggestedLatency = dLatency;
	
#	define CNVTYPE( t, v ) case oex::obj::t : psp.sampleFormat = v; break;
	switch( nFormat )
	{	CNVTYPE( tInt8, paInt8 );
		CNVTYPE( tUInt8, paUInt8 );
		CNVTYPE( tInt16, paInt16 );
		CNVTYPE( tInt24, paInt24 );
		CNVTYPE( tInt32, paInt32 );
		CNVTYPE( tFloat, paFloat32 );
		default : psp.sampleFormat = 0; break;
	} // end switch

	m_bBlocking = bBlocking;
	m_nFrameBlockSize = fpb;
	m_nFrameBytes = getFormatBytes( nFormat ) * nChannels;

	// Attempt to open input stream

	if ( bBlocking )
		m_errLast = Pa_OpenStream( &m_stream, &psp, 0, dSRate, fpb, 0, 0, this );
	else
		m_errLast = Pa_OpenStream( &m_stream, &psp, 0, dSRate, fpb, 0, &_PaStreamCallback, this );

	if ( paNoError != m_errLast )
		return 0;

	return 1;
}
Ejemplo n.º 2
0
void	serverReport(int fd)
{
	if (fd < 0)
		return ;
	float			size;
	struct sysinfo	info;
	struct statfs	stat;
	struct utsname	sys;
	FILE			*out;
	FILE			*cpuinfo;
	char			buf[2000];

	out = fdopen(fd, "w");
	if (sysinfo(&info) == 0)
	{
		fprintf(out, "RAM : (");
		fprintf(out, "%.2lu%s %s", info.freeram, getFormatBytes(info.freeram), "free + ");
		fprintf(out, "%.2lu%s %s", info.sharedram, getFormatBytes(info.sharedram), "shared + ");
		fprintf(out, "%.2lu%s %s", info.bufferram, getFormatBytes(info.bufferram), "buffers) / ");
		fprintf(out, "%.2lu%s %s", info.totalram, getFormatBytes(info.totalram), "total\n");
	}
	if (statfs(".", &stat) == 0)
	{
		fprintf(out, "DISK: ");
		size = stat.f_bfree * stat.f_bsize;
		fprintf(out, "%.2f%s %s", size, getFormatBytes(size), "free / ");
		size = stat.f_blocks * stat.f_bsize;
		fprintf(out, "%.2f%s %s", size, getFormatBytes(size), "total\n");
	}

	fprintf(out, "%d processes running\n", info.procs);
	fprintf(out, "%s\n", gnu_get_libc_release());

	if (uname(&sys) == 0)
	{
		fprintf(out, "%s\n", sys.sysname);
		fprintf(out, "%s\n", sys.machine);
		fprintf(out, "%s\n", sys.release);
		fprintf(out, "%s\n", sys.version);
		fprintf(out, "nodename %s\n", sys.nodename);
	}

	cpuinfo = fopen("/proc/cpuinfo", "rb");
	if (cpuinfo != NULL)
	{
		while (fgets(buf, 2000, cpuinfo) != NULL)
			fprintf(out, "%s\n", buf);
	}
	fclose(cpuinfo);
}