本文整理汇总了C++中AudioDecoder::resampler方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioDecoder::resampler方法的具体用法?C++ AudioDecoder::resampler怎么用?C++ AudioDecoder::resampler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioDecoder
的用法示例。
在下文中一共展示了AudioDecoder::resampler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
*TODO: 1. how to choose the value
* 2. use last delay when seeking
*/
if (qAbs(d.delay) < 2.718) {
if (d.delay < -kSyncThreshold) { //Speed up. drop frame?
//continue;
}
while (d.delay > kSyncThreshold) { //Slow down
//d.delay_cond.wait(&d.mutex, d.delay*1000); //replay may fail. why?
//qDebug("~~~~~wating for %f msecs", d.delay*1000);
usleep(kSyncThreshold * 1000000UL);
if (d.stop)
d.delay = 0;
else
d.delay -= kSyncThreshold;
}
if (d.delay > 0)
usleep(d.delay * 1000000UL);
} else { //when to drop off?
if (d.delay > 0) {
msleep(64);
} else {
//audio packet not cleaned up?
continue;
}
}
} else {
d.clock->updateValue(pkt.pts);
}
//DO NOT decode and convert if ao is not available or mute!
bool has_ao = ao && ao->isAvailable();
//if (!has_ao) {//do not decode?
// TODO: move resampler to AudioFrame, like VideoFrame does
if (has_ao && dec->resampler()) {
if (dec->resampler()->speed() != ao->speed()
|| dec->resampler()->outAudioFormat() != ao->audioFormat()) {
//resample later to ensure thread safe. TODO: test
if (d.resample) {
qDebug("decoder set speed: %.2f", ao->speed());
dec->resampler()->setOutAudioFormat(ao->audioFormat());
dec->resampler()->setSpeed(ao->speed());
dec->resampler()->prepare();
d.resample = false;
} else {
d.resample = true;
}
}
} else {
if (dec->resampler() && dec->resampler()->speed() != d.clock->speed()) {
if (d.resample) {
qDebug("decoder set speed: %.2f", d.clock->speed());
dec->resampler()->setSpeed(d.clock->speed());
dec->resampler()->prepare();
d.resample = false;
} else {
d.resample = true;
}
}
}
if (d.stop) {
qDebug("audio thread stop before decode()");
break;
}
QMutexLocker locker(&d.mutex);
Q_UNUSED(locker);
if (!dec->decode(pkt.data)) {