| 448 | // private |
| 449 | |
| 450 | bool CSubPicQueue::EnqueueSubPic(CComPtr<ISubPic>& pSubPic, bool bBlocking) |
| 451 | { |
| 452 | auto canAddToQueue = [this]() { |
| 453 | return (int)m_queue.size() < m_nMaxSubPic; |
| 454 | }; |
| 455 | |
| 456 | bool bAdded = false; |
| 457 | |
| 458 | std::unique_lock<std::mutex> lock(m_mutexQueue); |
| 459 | if (bBlocking) { |
| 460 | // Wait for enough room in the queue |
| 461 | m_condQueueFull.wait(lock, canAddToQueue); |
| 462 | } |
| 463 | |
| 464 | if (canAddToQueue()) { |
| 465 | if (m_bInvalidate && pSubPic->GetStop() > m_rtInvalidate) { |
| 466 | #if SUBPIC_TRACE_LEVEL > 1 |
| 467 | DLog(L"Subtitle Renderer Thread: Dropping rendered subpic because of invalidation"); |
| 468 | #endif |
| 469 | } else { |
| 470 | m_queue.emplace_back(pSubPic); |
| 471 | lock.unlock(); |
| 472 | m_condQueueReady.notify_one(); |
| 473 | bAdded = true; |
| 474 | } |
| 475 | pSubPic.Release(); |
| 476 | } |
| 477 | |
| 478 | return bAdded; |
| 479 | } |
| 480 | |
| 481 | REFERENCE_TIME CSubPicQueue::GetCurrentRenderingTime() |
| 482 | { |