本文整理汇总了C++中PacketBuffer::setBlocking方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketBuffer::setBlocking方法的具体用法?C++ PacketBuffer::setBlocking怎么用?C++ PacketBuffer::setBlocking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer::setBlocking方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void AVDemuxThread::run()
{
m_buffering = false;
end = false;
if (audio_thread && !audio_thread->isRunning())
audio_thread->start(QThread::HighPriority);
if (video_thread && !video_thread->isRunning())
video_thread->start();
int stream = 0;
Packet pkt;
pause(false);
qDebug("get av queue a/v thread = %p %p", audio_thread, video_thread);
PacketBuffer *aqueue = audio_thread ? audio_thread->packetQueue() : 0;
PacketBuffer *vqueue = video_thread ? video_thread->packetQueue() : 0;
// aqueue as a primary buffer: music with/without cover
AVThread* thread = !video_thread || (audio_thread && demuxer->hasAttacedPicture()) ? audio_thread : video_thread;
m_buffer = thread->packetQueue();
const qint64 buf2 = aqueue ? aqueue->bufferValue() : 1; // TODO: may be changed by user. Deal with audio track change
if (aqueue) {
aqueue->clear();
aqueue->setBlocking(true);
}
if (vqueue) {
vqueue->clear();
vqueue->setBlocking(true);
}
connect(thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished(qint64)), Qt::DirectConnection);
seek_tasks.clear();
bool was_end = false;
if (ademuxer) {
ademuxer->seek(0LL);
}
while (!end) {
processNextSeekTask();
//vthread maybe changed by AVPlayer.setPriority() from no dec case
vqueue = video_thread ? video_thread->packetQueue() : 0;
if (demuxer->atEnd()) {
// if avthread may skip 1st eof packet because of a/v sync
if (aqueue && (!was_end || aqueue->isEmpty())) {
aqueue->put(Packet::createEOF());
aqueue->blockEmpty(false); // do not block if buffer is not enough. block again on seek
}
if (vqueue && (!was_end || vqueue->isEmpty())) {
vqueue->put(Packet::createEOF());
vqueue->blockEmpty(false);
}
m_buffering = false;
Q_EMIT mediaStatusChanged(QtAV::BufferedMedia);
was_end = true;
// wait for a/v thread finished
msleep(100);
continue;
}
was_end = false;
if (tryPause()) {
continue; //the queue is empty and will block
}
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
//.........这里部分代码省略.........