本文整理汇总了C++中AudioOutputPtr::addFrameToBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ AudioOutputPtr::addFrameToBuffer方法的具体用法?C++ AudioOutputPtr::addFrameToBuffer怎么用?C++ AudioOutputPtr::addFrameToBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AudioOutputPtr
的用法示例。
在下文中一共展示了AudioOutputPtr::addFrameToBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFrame
void LoopPlayer::addFrame(const QByteArray &packet, int seq) {
if (DOUBLE_RAND < g.s.dPacketLoss) {
qWarning("Drop");
return;
}
bool restart = (qtLastFetch.elapsed() > 100);
{
QMutexLocker l(&qmLock);
double time = qtTicker.elapsed();
double r;
if (restart)
r = 0.0;
else
r = DOUBLE_RAND * g.s.dMaxPacketDelay;
qmPackets.insert(static_cast<float>(time + r), Packet(seq, packet));
}
// Restart check
if (qtLastFetch.elapsed() > 100) {
AudioOutputPtr ao = g.ao;
if (ao) {
ao->addFrameToBuffer(this, QByteArray(), 0);
}
}
}
示例2: fetchFrames
void LoopPlayer::fetchFrames() {
QMutexLocker l(&qmLock);
AudioOutputPtr ao = g.ao;
if (!ao || qmPackets.isEmpty())
return;
double cmp = qtTicker.elapsed();
QMultiMap<float, Packet>::iterator i = qmPackets.begin();
while (i != qmPackets.end()) {
if (i.key() > cmp)
break;
ao->addFrameToBuffer(this, i.value().second, i.value().first);
i = qmPackets.erase(i);
}
qtLastFetch.restart();
}
示例3: addFrame
//加入到音频播放队列
void LoopUser::addFrame(const QByteArray &packet) {
if (DOUBLE_RAND < g_struct.s.dPacketLoss) {
Trace("Drop");
return;
}
bool restart = (qtLastFetch.elapsed()*CLOCKS_PER_SEC > 100);
{
MutexLocker l(&qmLock);
double time = qtTicker.elapsed();
double r;
if (restart)
r = 0.0;
else
r = DOUBLE_RAND * g_struct.s.dMaxPacketDelay;
qmPackets.insert(make_pair(static_cast<float>(time + r), packet));
}
// Restart check
if (qtLastFetch.elapsed()*CLOCKS_PER_SEC > 100) {
AudioOutputPtr ao = g_struct.ao;
if (ao) {
MessageHandler::UDPMessageType msgType = MessageHandler::UDPVoiceAACPlus/*MessageHandler::UDPVoiceCELT*/;//static_cast<MessageHandler::UDPMessageType>((packet.at(0) >> 5) & 0x7);
for (int i=0; i<PER_FRAME_OF_SAMEPLE; i++)
{
ao->addFrameToBuffer(this, QByteArray(), 0, msgType);
char buf[512] = {0};
sprintf(buf,"LoopUser::addFrame QByteArray() t=%d\n",qtLastFetch.elapsed()*CLOCKS_PER_SEC );
//OutputDebugStringA(buf);
}
}
}
}
示例4: fetchFrames
//从音频队列中取帧
void LoopUser::fetchFrames() {
MutexLocker l(&qmLock);
AudioOutputPtr ao = g_struct.ao;
if (!ao || qmPackets.empty()) {
return;
}
double cmp = qtTicker.elapsed();
std::multimap<float, QByteArray>::iterator i = qmPackets.begin();
while (i != qmPackets.end()) {
// if (i->first > cmp)
// {
// char buf[512] = {0};
// sprintf(buf,"LoopUser::fetchFrames() cmp=%f\n",i->first );
// OutputDebugStringA(buf);
// break;
// }
const QByteArray &data = i->second;
PacketDataStream pds((char*)&data[0], data.size());
unsigned int msgFlags = 0;
int iSeq = static_cast<unsigned int>(pds.next8());
QByteArray qba;
pds.dataBlock(pds.left(), qba);
ao->addFrameToBuffer(this, qba, iSeq, MessageHandler::UDPVoiceAACPlus/*MessageHandler::UDPVoiceCELT*/);
i = qmPackets.erase(i);
}
qtLastFetch.restart();
}