本文整理汇总了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;
}
示例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;
}
示例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);
}