本文整理汇总了C++中PClip::GetAudio方法的典型用法代码示例。如果您正苦于以下问题:C++ PClip::GetAudio方法的具体用法?C++ PClip::GetAudio怎么用?C++ PClip::GetAudio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PClip
的用法示例。
在下文中一共展示了PClip::GetAudio方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OutputAudio
int AvxContext::OutputAudio() {
FILE *sink;
void *writeBuffer = NULL;
sighandler_t old_sigpipe = signal(SIGPIPE, SIG_IGN);
if (launchMPlayer) {
char command[1024];
if (MPlayerCommandAudio(command))
return -1;
AVXLOG_INFO("MPlayer command line: %s", command);
sink = popen(command, "w");
if (!sink) {
AVXLOG_ERROR("%s", "Error starting mplayer");
return -1;
}
} else {
sink = stdout;
}
#define AUDIO_SAMPLES 1000
try {
writeBuffer = malloc(vi.BytesPerAudioSample() * AUDIO_SAMPLES);
if (!writeBuffer) {
AVXLOG_ERROR("%s", "Unable to allocate memory");
goto fail;
}
for (__int64 i = 0; i < vi.num_audio_samples; i += AUDIO_SAMPLES) {
if (launchMPlayer && (feof(sink) || ferror(sink))) {
AVXLOG_ERROR("%s", "mplayer process exited");
break;
}
int read_samples;
if (vi.num_audio_samples - AUDIO_SAMPLES < i)
read_samples = vi.num_audio_samples - i;
else
read_samples = AUDIO_SAMPLES;
clip->GetAudio(writeBuffer, i, read_samples, avx_library.env);
fwrite(writeBuffer, vi.BytesPerAudioSample(), read_samples, sink);
}
} catch (AvisynthError &e) {
AVXLOG_ERROR("AvisynthError: %s", e.msg);
goto fail;
}
#undef AUDIO_SAMPLES
free(writeBuffer);
if (launchMPlayer)
pclose(sink);
signal(SIGPIPE, old_sigpipe);
return 0;
fail:
if (writeBuffer)
free(writeBuffer);
if (launchMPlayer)
pclose(sink);
signal(SIGPIPE, old_sigpipe);
return -1;
}