Improvement
This commit is contained in:
@@ -11,6 +11,7 @@ void RenderOutputQueue::Configure(const VideoPlayoutPolicy& policy)
|
||||
mPolicy = NormalizeVideoPlayoutPolicy(policy);
|
||||
while (mReadyFrames.size() > CapacityLocked())
|
||||
{
|
||||
ReleaseFrame(mReadyFrames.front());
|
||||
mReadyFrames.pop_front();
|
||||
++mDroppedCount;
|
||||
}
|
||||
@@ -21,6 +22,7 @@ bool RenderOutputQueue::Push(RenderOutputFrame frame)
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
if (mReadyFrames.size() >= CapacityLocked())
|
||||
{
|
||||
ReleaseFrame(mReadyFrames.front());
|
||||
mReadyFrames.pop_front();
|
||||
++mDroppedCount;
|
||||
}
|
||||
@@ -48,6 +50,8 @@ bool RenderOutputQueue::TryPop(RenderOutputFrame& frame)
|
||||
void RenderOutputQueue::Clear()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mMutex);
|
||||
for (RenderOutputFrame& frame : mReadyFrames)
|
||||
ReleaseFrame(frame);
|
||||
mReadyFrames.clear();
|
||||
}
|
||||
|
||||
@@ -68,3 +72,10 @@ std::size_t RenderOutputQueue::CapacityLocked() const
|
||||
{
|
||||
return static_cast<std::size_t>(mPolicy.maxReadyFrames);
|
||||
}
|
||||
|
||||
void RenderOutputQueue::ReleaseFrame(RenderOutputFrame& frame)
|
||||
{
|
||||
if (frame.releaseFrame)
|
||||
frame.releaseFrame(frame.frame);
|
||||
frame.releaseFrame = {};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user