本文整理汇总了C++中PacketBuffer::setBufferValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketBuffer::setBufferValue方法的具体用法?C++ PacketBuffer::setBufferValue怎么用?C++ PacketBuffer::setBufferValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer::setBufferValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
updateBufferState();
if (!demuxer->readFrame()) {
continue;
}
stream = demuxer->stream();
pkt = demuxer->packet();
Packet apkt;
bool audio_has_pic = demuxer->hasAttacedPicture();
int a_ext = 0;
if (ademuxer) {
QMutexLocker locker(&buffer_mutex);
Q_UNUSED(locker);
if (ademuxer) {
a_ext = -1;
audio_has_pic = ademuxer->hasAttacedPicture();
// FIXME: buffer full but buffering!!!
// avoid read external track everytime. aqueue may not block full
// vqueue will not block if aqueue is not enough
if (!aqueue->isFull() || aqueue->isBuffering()) {
if (ademuxer->readFrame()) {
if (ademuxer->stream() == ademuxer->audioStream()) {
a_ext = 1;
apkt = ademuxer->packet();
}
}
// no continue otherwise. ademuxer finished earlier than demuxer
}
}
}
//qDebug("vqueue: %d, aqueue: %d/isbuffering %d isfull: %d, buffer: %d/%d", vqueue->size(), aqueue->size(), aqueue->isBuffering(), aqueue->isFull(), aqueue->buffered(), aqueue->bufferValue());
//QMutexLocker locker(&buffer_mutex); //TODO: seems we do not need to lock
//Q_UNUSED(locker);
/*1 is empty but another is enough, then do not block to
ensure the empty one can put packets immediatly.
But usually it will not happen, why?
*/
/* demux thread will be blocked only when 1 queue is full and still put
* if vqueue is full and aqueue becomes empty, then demux thread
* will be blocked. so we should wake up another queue when empty(or threshold?).
* TODO: the video stream and audio stream may be group by group. provide it
* stream data: aaaaaaavvvvvvvaaaaaaaavvvvvvvvvaaaaaa, it happens
* stream data: aavavvavvavavavavavavavavvvaavavavava, it's ok
*/
//TODO: use cache queue, take from cache queue if not empty?
const bool a_internal = stream == demuxer->audioStream();
if (a_internal || a_ext > 0) {//apkt.isValid()) {
if (a_internal && !a_ext) // internal is always read even if external audio used
apkt = demuxer->packet();
/* if vqueue if not blocked and full, and aqueue is empty, then put to
* vqueue will block demuex thread
*/
if (aqueue) {
if (!audio_thread || !audio_thread->isRunning()) {
aqueue->clear();
continue;
}
// must ensure bufferValue set correctly before continue
if (m_buffer != aqueue)
aqueue->setBufferValue(m_buffer->isBuffering() ? std::numeric_limits<qint64>::max() : buf2);
// always block full if no vqueue because empty callback may set false
// attached picture is cover for song, 1 frame
aqueue->blockFull(!video_thread || !video_thread->isRunning() || !vqueue || audio_has_pic);
// external audio: a_ext < 0, stream = audio_idx=>put invalid packet
if (a_ext >= 0)
aqueue->put(apkt); //affect video_thread
}
}
// always check video stream if use external audio
if (stream == demuxer->videoStream()) {
if (vqueue) {
if (!video_thread || !video_thread->isRunning()) {
vqueue->clear();
continue;
}
vqueue->blockFull(!audio_thread || !audio_thread->isRunning() || !aqueue || aqueue->isEnough());
vqueue->put(pkt); //affect audio_thread
}
} else if (demuxer->subtitleStreams().contains(stream)) { //subtitle
Q_EMIT internalSubtitlePacketRead(demuxer->subtitleStreams().indexOf(stream), pkt);
} else {
continue;
}
}
m_buffering = false;
m_buffer = 0;
while (audio_thread && audio_thread->isRunning()) {
qDebug("waiting audio thread.......");
aqueue->blockEmpty(false); //FIXME: why need this
audio_thread->wait(500);
}
while (video_thread && video_thread->isRunning()) {
qDebug("waiting video thread.......");
vqueue->blockEmpty(false);
video_thread->wait(500);
}
thread->disconnect(this, SIGNAL(seekFinished(qint64)));
qDebug("Demux thread stops running....");
emit mediaStatusChanged(QtAV::EndOfMedia);
}