本文整理汇总了C++中Audio::start方法的典型用法代码示例。如果您正苦于以下问题:C++ Audio::start方法的具体用法?C++ Audio::start怎么用?C++ Audio::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Audio
的用法示例。
在下文中一共展示了Audio::start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
id = argc;
Audio audio;
char input;
for (unsigned int i = 8192; i > 2; i /= 2) {
audio.start(i);
sleep(1);
audio.stop();
}
}
示例2: cui_main
int cui_main(int argc, char *argv[])
{
uint32_t tid = syscall_mthread_create(inputLoop);
struct audio_data_format defaultFormat = {0, 2, 16, 4400};
Audio* audio = new Audio(&defaultFormat, AUDIO_OUTPUT);
if (-1 == audio->start())
{
_printf("Can not connect to AUDIO server!\n");
}
strings oggFiles;
if (strcmp(argv[1], "-d") == 0 && argc > 2)
{
listOggfiles(argv[2], oggFiles);
}
else
{
for (int i = 1; i < argc; i++)
{
oggFiles.push_back(argv[i]);
}
}
for (int i = 0; i < oggFiles.size(); i++)
{
FILE* fp = fopen(oggFiles[i].data(), "rb");
if (NULL == fp)
{
fprintf(stderr, "File open error: %s.\n", oggFiles[i].data());
delete audio;
return -1;
}
OggVorbis_File vf;
if (ov_open(fp, &vf, NULL, 0) < 0)
{
fprintf(stderr, "Skipped, %s does not appear to be an Ogg bitstream.\n", argv[i]);
continue;
}
char** infoTexts = ov_comment(&vf, -1)->user_comments;
vorbis_info* vi=ov_info(&vf, -1);
while(*infoTexts)
{
fprintf(stderr, "%s\n", *infoTexts);
++infoTexts;
}
// fprintf(stderr, "\nBitstream is %d channel, %dHz\n", vi->channels, vi->rate);
// fprintf(stderr, "\nDecoded length: %d samples\n",(long)ov_pcm_total(&vf, -1));
// fprintf(stderr, "Encoded by: %s\n\n", ov_comment(&vf, -1)->vendor);
struct audio_data_format format = {0, vi->channels, 16, vi->rate};
audio->setFormat(&format);
int current_section;
char pcmout[4096];
fprintf(stdout, "key q(quit) <=(prev) =>(next)\n");
for (;;)
{
switch(command)
{
case COMMAND_FORWARD:
command = COMMAND_NONE;
goto replay;
case COMMAND_BACKWARD:
command = COMMAND_NONE;
i -= 2;
goto replay;
case COMMAND_EXIT:
i = oggFiles.size();
goto replay;
case COMMAND_VOLUME_UP:
case COMMAND_VOLUME_DOWN:
break;
default:
break;
}
long ret = ov_read(&vf, pcmout, sizeof(pcmout), ¤t_section);
if (ret == 0)
{
break;
}
else if (ret < 0)
{
fprintf(stderr, "Warning data broken? %s\n", argv[i]);
}
else
{
audio->write(pcmout, ret);
}
}
replay:
fclose(fp);
}
audio->stop();
delete audio;
// cleanup causes crash!
// ov_clear(&vf);
}