From 88e00e0636826308db97e71b0fa58dc6b9fb0c72 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Sat, 18 May 2013 20:17:57 +0200 Subject: renderer: replace render buffer indices with queues --- xbmc/cores/VideoRenderers/RenderManager.cpp | 101 +++++++++++++++++----------- xbmc/cores/VideoRenderers/RenderManager.h | 17 ++--- 2 files changed, 68 insertions(+), 50 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index a7788d1b0f..afc72239c8 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -95,7 +95,7 @@ CXBMCRenderManager::CXBMCRenderManager() m_presenttime = 0; m_presentstep = PRESENT_IDLE; m_rendermethod = 0; - m_presentsource = 0; + m_presentsource = -1; m_presentmethod = PRESENT_METHOD_SINGLE; m_bReconfigured = false; m_hasCaptures = false; @@ -105,8 +105,6 @@ CXBMCRenderManager::CXBMCRenderManager() memset(&m_errorbuff, 0, ERRORBUFFSIZE); m_errorindex = 0; m_QueueSize = 2; - m_QueueRender = 0; - m_QueueOutput = 0; m_QueueSkip = 0; } @@ -287,8 +285,13 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi m_pRenderer->SetBufferSize(m_QueueSize); m_pRenderer->Update(); - m_QueueRender = 0; - m_QueueOutput = 0; + + m_queued.clear(); + m_discard.clear(); + m_free.clear(); + m_presentsource = -1; + for (int i=0; iReleaseBuffer(m_QueueRender); - m_overlays.Release(m_QueueRender); - m_QueueRender = (m_QueueRender + 1) % m_QueueSize; - count++; - } - - if(count > 1) - m_QueueSkip += count - 1; - m_pRenderer->FlipPage(m_presentsource); m_presentstep = PRESENT_FRAME; m_presentevent.notifyAll(); } + + /* release all previous */ + std::deque::iterator it = m_discard.begin(); + while(it != m_discard.end()) + { + // TODO check for fence + int idx = *it; + it = m_discard.erase(it); + m_free.push_back(idx); + m_pRenderer->ReleaseBuffer(idx); + m_overlays.Release(idx); + } } } @@ -433,8 +435,6 @@ unsigned int CXBMCRenderManager::PreInit() UpdateDisplayLatency(); m_QueueSize = 2; - m_QueueRender = 0; - m_QueueOutput = 0; m_QueueSkip = 0; return m_pRenderer->PreInit(); @@ -696,7 +696,8 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L m_Queue[source].timestamp = timestamp; m_Queue[source].presentfield = sync; m_Queue[source].presentmethod = presentmethod; - m_QueueOutput = source; + m_free.pop_front(); + m_queued.push_back(source); /* signal to any waiters to check state */ if(m_presentstep == PRESENT_IDLE) @@ -763,7 +764,8 @@ void CXBMCRenderManager::Render(bool clear, DWORD flags, DWORD alpha) else PresentSingle(clear, flags, alpha); - m_overlays.Render(m_presentsource); + if (m_presentsource >= 0) + m_overlays.Render(m_presentsource); } /* simple present method */ @@ -993,23 +995,23 @@ int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout) m_overlays.Release(GetNextDecode()); // return buffer level - return (m_QueueOutput - m_QueueRender + m_QueueSize) % m_QueueSize; + return m_queued.size() + m_discard.size();; } int CXBMCRenderManager::GetNextRender() { - if (m_QueueOutput == m_QueueRender) + if (m_queued.empty()) return -1; - return (m_QueueRender + 1) % m_QueueSize; + else + return m_queued.front(); } int CXBMCRenderManager::GetNextDecode() { - int outputPlus1 = (m_QueueOutput + 1) % m_QueueSize; - if (outputPlus1 == m_QueueRender) + if (m_free.empty()) return -1; else - return outputPlus1; + return m_free.front(); } void CXBMCRenderManager::PrepareNextRender() @@ -1029,16 +1031,19 @@ void CXBMCRenderManager::PrepareNextRender() double frametime = 1.0 / GetMaximumFPS(); /* see if any future queued frames are already due */ - int prv; - int idx = m_QueueOutput; - while(idx != nxt) + std::deque::reverse_iterator curr, prev; + int idx; + curr = prev = m_queued.rbegin(); + ++prev; + while (prev != m_queued.rend()) { - prv = (idx + m_QueueSize - 1) % m_QueueSize; - if(clocktime > m_Queue[prv].timestamp /* previous frame is late */ - && clocktime > m_Queue[idx].timestamp - frametime) /* selected frame is close to it's display time */ + if(clocktime > m_Queue[*prev].timestamp /* previous frame is late */ + && clocktime > m_Queue[*curr].timestamp - frametime) /* selected frame is close to it's display time */ break; - idx = prv; + ++curr; + ++prev; } + idx = *curr; /* in fullscreen we will block after render, but only for MAXPRESENTDELAY */ bool next; @@ -1049,11 +1054,23 @@ void CXBMCRenderManager::PrepareNextRender() if (next) { + /* skip late frames */ + int skip; + while((skip = m_queued.front()) != idx) + { + m_queued.pop_front(); + m_discard.push_back(skip); + m_QueueSkip++; + } + m_presenttime = m_Queue[idx].timestamp; m_presentmethod = m_Queue[idx].presentmethod; m_presentfield = m_Queue[idx].presentfield; m_presentstep = PRESENT_FLIP; + if(m_presentsource >= 0) + m_discard.push_back(m_presentsource); m_presentsource = idx; + m_queued.pop_front(); m_presentevent.notifyAll(); } } @@ -1062,11 +1079,17 @@ void CXBMCRenderManager::DiscardBuffer() { CSharedLock lock(m_sharedSection); CSingleLock lock2(m_presentlock); - while(m_QueueOutput != m_QueueRender) + + while(!m_queued.empty()) + { + int idx = m_queued.front(); + m_queued.pop_front(); + m_discard.push_back(idx); + } + if (m_presentsource >= 0) { - m_pRenderer->ReleaseBuffer(m_QueueOutput); - m_overlays.Release(m_QueueOutput); - m_QueueOutput = (m_QueueOutput + m_QueueSize - 1) % m_QueueSize; + m_discard.push_back(m_presentsource); + m_presentsource = -1; } if(m_presentstep == PRESENT_READY) m_presentstep = PRESENT_IDLE; diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h index d947e9e3d6..03c5ab9974 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoRenderers/RenderManager.h @@ -29,6 +29,7 @@ #include "threads/Thread.h" #include "settings/VideoSettings.h" #include "OverlayRenderer.h" +#include class CRenderCapture; @@ -107,7 +108,7 @@ public: void AddOverlay(CDVDOverlay* o, double pts) { CSharedLock lock(m_sharedSection); - m_overlays.AddOverlay(o, pts, (m_QueueOutput + 1) % m_QueueSize); + m_overlays.AddOverlay(o, pts, m_free.front()); } void AddCleanup(OVERLAY::COverlay* o) @@ -218,16 +219,6 @@ protected: double m_displayLatency; void UpdateDisplayLatency(); - // Render Buffer State Description: - // - // Output: is the buffer about to or having its texture prepared for render (ie from output thread). - // Cannot go past the "Displayed" buffer (otherwise we will probably overwrite buffers not yet - // displayed or even rendered). - // Render: is the current buffer being or having been submitted for render to back buffer. - // Cannot go past "Output" buffer (else it would be rendering old output). - - int m_QueueRender; - int m_QueueOutput; int m_QueueSize; int m_QueueSkip; @@ -238,6 +229,10 @@ protected: EPRESENTMETHOD presentmethod; } m_Queue[NUM_BUFFERS]; + std::deque m_free; + std::deque m_queued; + std::deque m_discard; + double m_presenttime; double m_presentcorr; double m_presenterr; -- cgit v1.2.3 From d869662832c82228929dd9605f7d5ae33ab3bac0 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 13 Jun 2013 23:29:45 +0200 Subject: renderer: simplify code by always maintaining one front buffer --- xbmc/cores/VideoRenderers/RenderManager.cpp | 49 ++++++++++++----------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index afc72239c8..5be41ab9cf 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -86,6 +86,12 @@ private: CCriticalSection &m_owned; }; +static void requeue(std::deque &trg, std::deque &src) +{ + trg.push_back(src.front()); + src.pop_front(); +} + CXBMCRenderManager::CXBMCRenderManager() { m_pRenderer = NULL; @@ -95,7 +101,7 @@ CXBMCRenderManager::CXBMCRenderManager() m_presenttime = 0; m_presentstep = PRESENT_IDLE; m_rendermethod = 0; - m_presentsource = -1; + m_presentsource = 0; m_presentmethod = PRESENT_METHOD_SINGLE; m_bReconfigured = false; m_hasCaptures = false; @@ -289,8 +295,8 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi m_queued.clear(); m_discard.clear(); m_free.clear(); - m_presentsource = -1; - for (int i=0; i::iterator it = m_discard.begin(); - while(it != m_discard.end()) + for(std::deque::iterator it = m_discard.begin(); it != m_discard.end(); ) { // TODO check for fence - int idx = *it; + m_pRenderer->ReleaseBuffer(*it); + m_overlays.Release(*it); + m_free.push_back(*it); it = m_discard.erase(it); - m_free.push_back(idx); - m_pRenderer->ReleaseBuffer(idx); - m_overlays.Release(idx); } } } @@ -696,8 +700,7 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L m_Queue[source].timestamp = timestamp; m_Queue[source].presentfield = sync; m_Queue[source].presentmethod = presentmethod; - m_free.pop_front(); - m_queued.push_back(source); + requeue(m_queued, m_free); /* signal to any waiters to check state */ if(m_presentstep == PRESENT_IDLE) @@ -764,8 +767,7 @@ void CXBMCRenderManager::Render(bool clear, DWORD flags, DWORD alpha) else PresentSingle(clear, flags, alpha); - if (m_presentsource >= 0) - m_overlays.Render(m_presentsource); + m_overlays.Render(m_presentsource); } /* simple present method */ @@ -1055,11 +1057,9 @@ void CXBMCRenderManager::PrepareNextRender() if (next) { /* skip late frames */ - int skip; - while((skip = m_queued.front()) != idx) + while(m_queued.front() != idx) { - m_queued.pop_front(); - m_discard.push_back(skip); + requeue(m_discard, m_queued); m_QueueSkip++; } @@ -1067,8 +1067,7 @@ void CXBMCRenderManager::PrepareNextRender() m_presentmethod = m_Queue[idx].presentmethod; m_presentfield = m_Queue[idx].presentfield; m_presentstep = PRESENT_FLIP; - if(m_presentsource >= 0) - m_discard.push_back(m_presentsource); + m_discard.push_back(m_presentsource); m_presentsource = idx; m_queued.pop_front(); m_presentevent.notifyAll(); @@ -1081,16 +1080,8 @@ void CXBMCRenderManager::DiscardBuffer() CSingleLock lock2(m_presentlock); while(!m_queued.empty()) - { - int idx = m_queued.front(); - m_queued.pop_front(); - m_discard.push_back(idx); - } - if (m_presentsource >= 0) - { - m_discard.push_back(m_presentsource); - m_presentsource = -1; - } + requeue(m_discard, m_queued); + if(m_presentstep == PRESENT_READY) m_presentstep = PRESENT_IDLE; m_presentevent.notifyAll(); -- cgit v1.2.3 From 39fd0caf3c1a93a28fe77d89cbd8a179daa9a77c Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 13 Jun 2013 23:39:55 +0200 Subject: renderer: remove now pointless GetNext(Decode/Render) function --- xbmc/cores/VideoRenderers/RenderManager.cpp | 39 +++++++++-------------------- xbmc/cores/VideoRenderers/RenderManager.h | 2 -- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 5be41ab9cf..6e5f0cb5a8 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -349,11 +349,10 @@ void CXBMCRenderManager::FrameMove() if (m_presentstep == PRESENT_FRAME2) { - int idx = GetNextRender(); - if(idx >= 0) + if(!m_queued.empty()) { double timestamp = GetPresentTime(); - if(timestamp > m_presenttime + (m_Queue[idx].timestamp - m_presenttime) * 0.5) + if(timestamp > m_presenttime + (m_Queue[m_queued.front()].timestamp - m_presenttime) * 0.5) { m_presentstep = PRESENT_READY; m_presentevent.notifyAll(); @@ -405,7 +404,7 @@ void CXBMCRenderManager::FrameFinish() if(m_presentstep == PRESENT_IDLE) { - if(GetNextRender() >= 0) + if(!m_queued.empty()) m_presentstep = PRESENT_READY; } @@ -694,8 +693,11 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L CSingleLock lock2(m_presentlock); + if(m_free.empty()) + return; + if(source < 0) - source = GetNextDecode(); + source = m_free.front(); m_Queue[source].timestamp = timestamp; m_Queue[source].presentfield = sync; @@ -870,9 +872,9 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic) if (!m_pRenderer) return -1; - int index = GetNextDecode(); - if(index < 0) + if(m_free.empty()) return -1; + int index = m_free.front(); if(m_pRenderer->AddVideoPicture(&pic, index)) return 1; @@ -982,7 +984,7 @@ int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout) CSingleLock lock2(m_presentlock); XbmcThreads::EndTime endtime(timeout); - while(GetNextDecode() < 0) + while(m_free.empty()) { m_presentevent.wait(lock2, std::min(50, timeout)); if(endtime.IsTimePast() || bStop) @@ -994,34 +996,17 @@ int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout) } // make sure overlay buffer is released, this won't happen on AddOverlay - m_overlays.Release(GetNextDecode()); + m_overlays.Release(m_free.front()); // return buffer level return m_queued.size() + m_discard.size();; } -int CXBMCRenderManager::GetNextRender() -{ - if (m_queued.empty()) - return -1; - else - return m_queued.front(); -} - -int CXBMCRenderManager::GetNextDecode() -{ - if (m_free.empty()) - return -1; - else - return m_free.front(); -} - void CXBMCRenderManager::PrepareNextRender() { CSingleLock lock(m_presentlock); - int nxt = GetNextRender(); - if (nxt < 0) + if (m_queued.empty()) { CLog::Log(LOGERROR, "CRenderManager::PrepareNextRender - asked to prepare with nothing available"); m_presentstep = PRESENT_IDLE; diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h index 03c5ab9974..f693d8082c 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoRenderers/RenderManager.h @@ -185,8 +185,6 @@ protected: void PresentFields(bool clear, DWORD flags, DWORD alpha); void PresentBlend(bool clear, DWORD flags, DWORD alpha); - int GetNextRender(); - int GetNextDecode(); void PrepareNextRender(); EINTERLACEMETHOD AutoInterlaceMethodInternal(EINTERLACEMETHOD mInt); -- cgit v1.2.3 From b9fb6911879bc79213a8bd66db151bb3ad181586 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Fri, 14 Jun 2013 00:25:37 +0200 Subject: renderer: name present buffer structure to be able to reference it --- xbmc/cores/VideoRenderers/RenderManager.cpp | 7 ++++--- xbmc/cores/VideoRenderers/RenderManager.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 6e5f0cb5a8..179f753876 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -699,9 +699,10 @@ void CXBMCRenderManager::FlipPage(volatile bool& bStop, double timestamp /* = 0L if(source < 0) source = m_free.front(); - m_Queue[source].timestamp = timestamp; - m_Queue[source].presentfield = sync; - m_Queue[source].presentmethod = presentmethod; + SPresent& m = m_Queue[source]; + m.timestamp = timestamp; + m.presentfield = sync; + m.presentmethod = presentmethod; requeue(m_queued, m_free); /* signal to any waiters to check state */ diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h index f693d8082c..6dc2629b69 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoRenderers/RenderManager.h @@ -220,7 +220,7 @@ protected: int m_QueueSize; int m_QueueSkip; - struct + struct SPresent { double timestamp; EFIELDSYNC presentfield; -- cgit v1.2.3 From 999f40f093961e6bcf1852166165e8a45096cbaa Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Fri, 14 Jun 2013 00:29:39 +0200 Subject: renderer: store bypass format in rendermanager instead The present method will be overwritten on each flippage --- xbmc/cores/VideoRenderers/RenderManager.cpp | 5 ++--- xbmc/cores/VideoRenderers/RenderManager.h | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 179f753876..0a40f57300 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -272,8 +272,7 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi lock.Enter(); } lock2.Enter(); - if( format & RENDER_FMT_BYPASS ) - m_presentmethod = PRESENT_METHOD_BYPASS; + m_format = format; int processor = m_pRenderer->GetProcessorSize(); if(processor) @@ -312,7 +311,7 @@ bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsi bool CXBMCRenderManager::RendererHandlesPresent() const { - return IsConfigured() && m_presentmethod != PRESENT_METHOD_BYPASS; + return IsConfigured() && m_format != RENDER_FMT_BYPASS; } bool CXBMCRenderManager::IsConfigured() const diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h index 6dc2629b69..1be4e2f20c 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoRenderers/RenderManager.h @@ -211,7 +211,6 @@ protected: PRESENT_METHOD_BLEND, PRESENT_METHOD_WEAVE, PRESENT_METHOD_BOB, - PRESENT_METHOD_BYPASS, }; double m_displayLatency; @@ -231,6 +230,7 @@ protected: std::deque m_queued; std::deque m_discard; + ERenderFormat m_format; double m_presenttime; double m_presentcorr; double m_presenterr; -- cgit v1.2.3 From e1ecc4b2f14b7707ce799623ef91204aa247a312 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Fri, 14 Jun 2013 00:31:58 +0200 Subject: renderer: drop copies of variables, use queue data directly --- xbmc/cores/VideoRenderers/RenderManager.cpp | 35 ++++++++++++++++------------- xbmc/cores/VideoRenderers/RenderManager.h | 4 +--- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 0a40f57300..255f108762 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -97,12 +97,9 @@ CXBMCRenderManager::CXBMCRenderManager() m_pRenderer = NULL; m_bIsStarted = false; - m_presentfield = FS_NONE; - m_presenttime = 0; m_presentstep = PRESENT_IDLE; m_rendermethod = 0; m_presentsource = 0; - m_presentmethod = PRESENT_METHOD_SINGLE; m_bReconfigured = false; m_hasCaptures = false; m_displayLatency = 0.0f; @@ -112,6 +109,7 @@ CXBMCRenderManager::CXBMCRenderManager() m_errorindex = 0; m_QueueSize = 2; m_QueueSkip = 0; + m_format = RENDER_FMT_NONE; } CXBMCRenderManager::~CXBMCRenderManager() @@ -351,7 +349,9 @@ void CXBMCRenderManager::FrameMove() if(!m_queued.empty()) { double timestamp = GetPresentTime(); - if(timestamp > m_presenttime + (m_Queue[m_queued.front()].timestamp - m_presenttime) * 0.5) + SPresent& m = m_Queue[m_presentsource]; + SPresent& q = m_Queue[m_queued.front()]; + if(timestamp > m.timestamp + (q.timestamp - m.timestamp) * 0.5) { m_presentstep = PRESENT_READY; m_presentevent.notifyAll(); @@ -384,15 +384,17 @@ void CXBMCRenderManager::FrameMove() void CXBMCRenderManager::FrameFinish() { /* wait for this present to be valid */ + SPresent& m = m_Queue[m_presentsource]; + if(g_graphicsContext.IsFullScreenVideo()) - WaitPresentTime(m_presenttime); + WaitPresentTime(m.timestamp); { CSingleLock lock(m_presentlock); if(m_presentstep == PRESENT_FRAME) { - if( m_presentmethod == PRESENT_METHOD_BOB - || m_presentmethod == PRESENT_METHOD_WEAVE) + if( m.presentmethod == PRESENT_METHOD_BOB + || m.presentmethod == PRESENT_METHOD_WEAVE) m_presentstep = PRESENT_FRAME2; else m_presentstep = PRESENT_IDLE; @@ -760,11 +762,13 @@ void CXBMCRenderManager::Render(bool clear, DWORD flags, DWORD alpha) { CSharedLock lock(m_sharedSection); - if( m_presentmethod == PRESENT_METHOD_BOB ) + SPresent& m = m_Queue[m_presentsource]; + + if( m.presentmethod == PRESENT_METHOD_BOB ) PresentFields(clear, flags, alpha); - else if( m_presentmethod == PRESENT_METHOD_WEAVE ) + else if( m.presentmethod == PRESENT_METHOD_WEAVE ) PresentFields(clear, flags | RENDER_FLAG_WEAVE, alpha); - else if( m_presentmethod == PRESENT_METHOD_BLEND ) + else if( m.presentmethod == PRESENT_METHOD_BLEND ) PresentBlend(clear, flags, alpha); else PresentSingle(clear, flags, alpha); @@ -785,17 +789,18 @@ void CXBMCRenderManager::PresentSingle(bool clear, DWORD flags, DWORD alpha) void CXBMCRenderManager::PresentFields(bool clear, DWORD flags, DWORD alpha) { CSingleLock lock(g_graphicsContext); + SPresent& m = m_Queue[m_presentsource]; if(m_presentstep == PRESENT_FRAME) { - if( m_presentfield == FS_BOT) + if( m.presentfield == FS_BOT) m_pRenderer->RenderUpdate(clear, flags | RENDER_FLAG_BOT | RENDER_FLAG_FIELD0, alpha); else m_pRenderer->RenderUpdate(clear, flags | RENDER_FLAG_TOP | RENDER_FLAG_FIELD0, alpha); } else { - if( m_presentfield == FS_TOP) + if( m.presentfield == FS_TOP) m_pRenderer->RenderUpdate(clear, flags | RENDER_FLAG_BOT | RENDER_FLAG_FIELD1, alpha); else m_pRenderer->RenderUpdate(clear, flags | RENDER_FLAG_TOP | RENDER_FLAG_FIELD1, alpha); @@ -805,8 +810,9 @@ void CXBMCRenderManager::PresentFields(bool clear, DWORD flags, DWORD alpha) void CXBMCRenderManager::PresentBlend(bool clear, DWORD flags, DWORD alpha) { CSingleLock lock(g_graphicsContext); + SPresent& m = m_Queue[m_presentsource]; - if( m_presentfield == FS_BOT ) + if( m.presentfield == FS_BOT ) { m_pRenderer->RenderUpdate(clear, flags | RENDER_FLAG_BOT | RENDER_FLAG_NOOSD, alpha); m_pRenderer->RenderUpdate(false, flags | RENDER_FLAG_TOP, alpha / 2); @@ -1048,9 +1054,6 @@ void CXBMCRenderManager::PrepareNextRender() m_QueueSkip++; } - m_presenttime = m_Queue[idx].timestamp; - m_presentmethod = m_Queue[idx].presentmethod; - m_presentfield = m_Queue[idx].presentfield; m_presentstep = PRESENT_FLIP; m_discard.push_back(m_presentsource); m_presentsource = idx; diff --git a/xbmc/cores/VideoRenderers/RenderManager.h b/xbmc/cores/VideoRenderers/RenderManager.h index 1be4e2f20c..83dc50ac1c 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.h +++ b/xbmc/cores/VideoRenderers/RenderManager.h @@ -231,13 +231,11 @@ protected: std::deque m_discard; ERenderFormat m_format; - double m_presenttime; + double m_presentcorr; double m_presenterr; double m_errorbuff[ERRORBUFFSIZE]; int m_errorindex; - EFIELDSYNC m_presentfield; - EPRESENTMETHOD m_presentmethod; EPRESENTSTEP m_presentstep; int m_presentsource; XbmcThreads::ConditionVariable m_presentevent; -- cgit v1.2.3 From b263eefd78219d06d096a23ddee9f93c20253aa4 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Fri, 14 Jun 2013 16:56:41 +0200 Subject: renderer: grab presentlock in AddVideoPicture --- xbmc/cores/VideoRenderers/RenderManager.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/xbmc/cores/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoRenderers/RenderManager.cpp index 255f108762..bff4b3c76b 100644 --- a/xbmc/cores/VideoRenderers/RenderManager.cpp +++ b/xbmc/cores/VideoRenderers/RenderManager.cpp @@ -878,9 +878,13 @@ int CXBMCRenderManager::AddVideoPicture(DVDVideoPicture& pic) if (!m_pRenderer) return -1; - if(m_free.empty()) - return -1; - int index = m_free.front(); + int index; + { + CSingleLock lock(m_presentlock); + if (m_free.empty()) + return -1; + index = m_free.front(); + } if(m_pRenderer->AddVideoPicture(&pic, index)) return 1; -- cgit v1.2.3