本文整理汇总了C++中Filter::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Filter::clear方法的具体用法?C++ Filter::clear怎么用?C++ Filter::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Filter
的用法示例。
在下文中一共展示了Filter::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_err
PosibErr<void> setup_filter(Filter & filter,
Config * config,
bool use_decoder, bool use_filter, bool use_encoder)
{
StringList sl;
config->retrieve_list("filter", &sl);
StringListEnumeration els = sl.elements_obj();
const char * filter_name;
String fun;
StackPtr<IndividualFilter> ifilter;
filter.clear();
while ((filter_name = els.next()) != 0) {
//fprintf(stderr, "Loading %s ... \n", filter_name);
FilterEntry * f = get_standard_filter(filter_name);
// In case libdl is not available a filter is only available if made
// one of the standard filters. This is done by statically linking
// the filter sources.
// On systems providing libdl or in case libtool mimics libdl
// The following code parts assure that all filters needed and requested
// by user are loaded properly or be reported to be missing.
//
FilterHandle decoder_handle, filter_handle, encoder_handle;
#ifdef HAVE_LIBDL
FilterEntry dynamic_filter;
if (!f) {
RET_ON_ERR_SET(get_dynamic_filter(config, filter_name),
const ConfigModule *, module);
if (!(decoder_handle = dlopen(module->file,RTLD_NOW)) ||
!(encoder_handle = dlopen(module->file,RTLD_NOW)) ||
!(filter_handle = dlopen(module->file,RTLD_NOW)))
return make_err(cant_dlopen_file,dlerror()).with_file(filter_name);
fun = "new_aspell_";
fun += filter_name;
fun += "_decoder";
dynamic_filter.decoder = (FilterFun *)dlsym(decoder_handle.get(), fun.str());
fun = "new_aspell_";
fun += filter_name;
fun += "_encoder";
dynamic_filter.encoder = (FilterFun *)dlsym(encoder_handle.get(), fun.str());
fun = "new_aspell_";
fun += filter_name;
fun += "_filter";
dynamic_filter.filter = (FilterFun *)dlsym(filter_handle.get(), fun.str());
if (!dynamic_filter.decoder &&
!dynamic_filter.encoder &&
!dynamic_filter.filter)
return make_err(empty_filter,filter_name);
dynamic_filter.name = filter_name;
f = &dynamic_filter;
}
#else
if (!f)
return make_err(no_such_filter, filter_name);
#endif
if (use_decoder && f->decoder && (ifilter = f->decoder())) {
RET_ON_ERR_SET(ifilter->setup(config), bool, keep);
ifilter->handle = decoder_handle.release();
if (!keep) {
ifilter.del();
} else {
filter.add_filter(ifilter.release());
}
}
if (use_filter && f->filter && (ifilter = f->filter())) {
RET_ON_ERR_SET(ifilter->setup(config), bool, keep);
ifilter->handle = filter_handle.release();
if (!keep) {
ifilter.del();
} else {
filter.add_filter(ifilter.release());
}
}
示例2: if
//.........这里部分代码省略.........
vector <MessageAudio>::iterator audio;
audio = vAudioQueue.begin();
do {
LOG4CXX_INFO(narratorLog, "Saying: " << audio->getText());
AudioStream *audioStream;
std::string encoding = ((MessageAudio&)*audio).getEncoding();
if (encoding == "ogg")
{
audioStream = new OggStream;
}
else if (encoding == "mp3")
{
audioStream = new Mp3Stream;
}
else
{
LOG4CXX_ERROR(narratorLog, "encoding '" << encoding << "' not supported");
audio++;
continue;
}
if(!audioStream->open(*audio)) {
LOG4CXX_ERROR(narratorLog, "error opening audio stream");
audioStream->close();
break;
}
if (portaudio.getRate() != audioStream->getRate())
{
long waitms = portaudio.getRemainingms();
if (waitms != 0)
{
LOG4CXX_DEBUG(narratorLog, "Waiting for current playback to finish");
while (waitms > 0)
{
usleep(100000);
waitms -= 100;
}
}
}
if(!portaudio.open(audioStream->getRate(), audioStream->getChannels())) {
LOG4CXX_ERROR(narratorLog, "error initializing portaudio");
break;
}
if(!filter.open(audioStream->getRate(), audioStream->getChannels())) {
LOG4CXX_ERROR(narratorLog, "error initializing filter");
break;
}
int inSamples = 0;
soundtouch::SAMPLETYPE* buffer = new soundtouch::SAMPLETYPE[audioStream->getChannels()*BUFFERSIZE];
do {
// change gain, tempo and pitch
adjustGainTempoPitch(n, filter, gain, tempo, pitch);
// read some stuff from the audio stream
inSamples = audioStream->read(buffer, BUFFERSIZE*audioStream->getChannels());
if(inSamples != 0) {
filter.write(buffer, inSamples);
writeSamplesToPortaudio( n, portaudio, filter, buffer );
} else {
LOG4CXX_INFO(narratorLog, "Flushing soundtouch buffer");
filter.flush();
}
state = n->getState();
} while (inSamples != 0 && state == Narrator::PLAY && !n->bResetFlag);
if(buffer != NULL) delete [] (buffer);
audioStream->close();
audio++;
} while(audio != vAudioQueue.end() && state == Narrator::PLAY && !n->bResetFlag);
}
//Cleanup message object
delete(pi.mMessage);
}
// Abort stream?
if(n->bResetFlag) {
n->bResetFlag = false;
portaudio.stop();
filter.clear();
}
} while(state != Narrator::EXIT);
LOG4CXX_INFO(narratorLog, "Shutting down playbackthread");
pthread_exit(NULL);
return NULL;
}