当前位置: 首页>>代码示例>>C++>>正文


C++ AudioDevice::setAudio方法代码示例

本文整理汇总了C++中AudioDevice::setAudio方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDevice::setAudio方法的具体用法?C++ AudioDevice::setAudio怎么用?C++ AudioDevice::setAudio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AudioDevice的用法示例。


在下文中一共展示了AudioDevice::setAudio方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

AudioDevice *Audio::getDevice(unsigned index, DeviceMode mode)
{
	int dsp, mixer;
	char fname[33];
	AudioDevice *dev;

	if(index)
		snprintf(fname, sizeof(fname), "/dev/dsp%d", index);
	else
		snprintf(fname, sizeof(fname), "/dev/dsp");

	dsp = ::open(fname, O_RDWR | O_NDELAY);
	if(dsp < 0)
		return NULL;

	if(index)
		snprintf(fname, sizeof(fname), "/dev/mixer%d", index);
	else
		snprintf(fname, sizeof(fname), "/dev/mixer");

	mixer = ::open(fname, O_RDWR | O_NONBLOCK);
	if(mixer < 0) {
		::close(dsp);
		return NULL;
	}

	dev = new OSSAudioDevice(dsp, mixer, mode);
	if(!dev->setAudio(rate8khz, false))
		dev->setAudio(rate44khz, true);
	return dev;
}
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:31,代码来源:oss.cpp

示例2:

AudioDevice *Audio::getDevice(unsigned index, DeviceMode mode)
{
	AudioDevice *dev;

	if(index > MAX_DEVICES)
		return NULL;

	if(mode != PLAY)
		return NULL;

	dev = new W32AudioDevice(index);
	dev->setAudio(rate8khz, false);
	return dev;
}
开发者ID:tws67,项目名称:bayonne-cygwin,代码行数:14,代码来源:w32.cpp

示例3: play

void Tool::play(char **argv)
{
	AudioDevice *dev;
	PlayStream playfile;
	const char *path = *argv;
	Linear buffer;
	Info info;
	unsigned bufcount, pages;
	
	dev = getDevice();

	if(!hasDevice() && !dev)
	{
		cerr << "no device supported" << endl;
		exit(-1);
	}
	else if(!dev)
	{
		cerr << "device unavailable" << endl;
		exit(-1);
	}

	playfile.open(argv);

	if(!playfile.isOpen())
	{
		cerr << "audiotool: " << path << ": unable to access" << endl;
		exit(-1);
	}

	if(!playfile.isStreamable())
	{
		cerr << "audiotool: " << path << ": missing needed codec" << endl;
		exit(-1);
	}

	playfile.getInfo(&info);
	if(!dev->setAudio((Rate)info.rate, isStereo(info.encoding), 10))
	{
		cerr << "audiotool: sound device does not support rate" << endl;
		exit(-1);
	}

	bufcount = playfile.getCount();
	if(isStereo(info.encoding))
		buffer = new Sample[bufcount * 2];
	else
		buffer = new Sample[bufcount];

	for(;;)
	{
		if(isStereo(info.encoding))
			pages = playfile.getStereo(buffer, 1);
		else
			pages = playfile.getMono(buffer, 1);

		if(!pages)
			break;

		dev->putSamples(buffer, bufcount);
	}

	dev->sync();
	delete dev;
	playfile.close();		
	exit(0);
}
开发者ID:tws67,项目名称:bayonne-base-windows,代码行数:67,代码来源:play.cpp


注:本文中的AudioDevice::setAudio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。