[SCM] kodi-pvr-vdr-vnsi/master: client, VNSIAdmin: use CLockObject for exception-safe locks
tiber-guest at users.alioth.debian.org
tiber-guest at users.alioth.debian.org
Sun Feb 28 15:46:51 UTC 2016
The following commit has been merged in the master branch:
commit 22d65663a2af9377d7802d6b38573502ee85adfc
Author: Max Kellermann <max at duempel.org>
Date: Sat Nov 21 23:38:06 2015 +0100
client, VNSIAdmin: use CLockObject for exception-safe locks
diff --git a/src/VNSIAdmin.cpp b/src/VNSIAdmin.cpp
index 362a23c..d5b5887 100644
--- a/src/VNSIAdmin.cpp
+++ b/src/VNSIAdmin.cpp
@@ -135,6 +135,7 @@ CVisGUIShader *vis_shader = NULL;
using namespace ADDON;
+using namespace PLATFORM;
class cOSDTexture
@@ -1206,25 +1207,23 @@ bool cVNSIAdmin::Create(int x, int y, int w, int h, void* device)
void cVNSIAdmin::Render()
{
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
{
m_osdRender->Render();
m_osdRender->FreeResources();
}
m_bIsOsdDirty = false;
- m_osdMutex.Unlock();
}
void cVNSIAdmin::Stop()
{
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
{
delete m_osdRender;
m_osdRender = NULL;
}
- m_osdMutex.Unlock();
}
bool cVNSIAdmin::Dirty()
@@ -1311,47 +1310,44 @@ bool cVNSIAdmin::OnResponsePacket(cResponsePacket* resp)
{
data = resp->getUserData();
len = resp->getUserDataLength();
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
m_osdRender->AddTexture(wnd, color, x0, y0, x1, y1, data[0]);
- m_osdMutex.Unlock();
}
else if (resp->getOpCodeID() == VNSI_OSD_SETPALETTE)
{
data = resp->getUserData();
len = resp->getUserDataLength();
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
m_osdRender->SetPalette(wnd, x0, (uint32_t*)data);
- m_osdMutex.Unlock();
}
else if (resp->getOpCodeID() == VNSI_OSD_SETBLOCK)
{
data = resp->getUserData();
len = resp->getUserDataLength();
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
{
m_osdRender->SetBlock(wnd, x0, y0, x1, y1, color, data, len);
m_bIsOsdDirty = true;
}
- m_osdMutex.Unlock();
}
else if (resp->getOpCodeID() == VNSI_OSD_CLEAR)
{
- m_osdMutex.Lock();
+ const CLockObject lock(m_osdMutex);
if (m_osdRender)
m_osdRender->Clear(wnd);
m_bIsOsdDirty = true;
- m_osdMutex.Unlock();
}
else if (resp->getOpCodeID() == VNSI_OSD_CLOSE)
{
- m_osdMutex.Lock();
- if (m_osdRender)
- m_osdRender->DisposeTexture(wnd);
- m_bIsOsdDirty = true;
- m_osdMutex.Unlock();
+ {
+ const CLockObject lock(m_osdMutex);
+ if (m_osdRender)
+ m_osdRender->DisposeTexture(wnd);
+ m_bIsOsdDirty = true;
+ }
m_window->SetFocusId(CONTROL_MENU);
}
else if (resp->getOpCodeID() == VNSI_OSD_MOVEWINDOW)
diff --git a/src/VNSIData.cpp b/src/VNSIData.cpp
index 6e78d23..ca2366c 100644
--- a/src/VNSIData.cpp
+++ b/src/VNSIData.cpp
@@ -31,20 +31,16 @@ using namespace PLATFORM;
cVNSIData::SMessage &
cVNSIData::Queue::Enqueue(uint32_t serial)
{
- m_mutex.Lock();
- SMessage &message(m_queue[serial]);
- m_mutex.Unlock();
- return message;
+ const CLockObject lock(m_mutex);
+ return m_queue[serial];
}
std::unique_ptr<cResponsePacket>
cVNSIData::Queue::Dequeue(uint32_t serial, SMessage &message)
{
- m_mutex.Lock();
+ const CLockObject lock(m_mutex);
auto vresp = std::move(message.pkt);
m_queue.erase(serial);
- m_mutex.Unlock();
-
return vresp;
}
diff --git a/src/client.cpp b/src/client.cpp
index 4063ee6..4ade613 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -34,6 +34,7 @@
using namespace std;
using namespace ADDON;
+using namespace PLATFORM;
ADDON_STATUS m_CurStatus = ADDON_STATUS_UNKNOWN;
@@ -794,12 +795,11 @@ DemuxPacket* DemuxRead(void)
return NULL;
}
- TimeshiftMutex.Lock();
+ const CLockObject lock(TimeshiftMutex);
IsTimeshift = VNSIDemuxer->IsTimeshift();
TimeshiftStartTime = VNSIDemuxer->GetBufferTimeStart();
TimeshiftEndTime = VNSIDemuxer->GetBufferTimeEnd();
TimeshiftPlayTime = VNSIDemuxer->GetPlayingTime();
- TimeshiftMutex.Unlock();
return pkt;
}
@@ -869,9 +869,8 @@ time_t GetPlayingTime()
time_t time = 0;
if (VNSIDemuxer)
{
- TimeshiftMutex.Lock();
+ const CLockObject lock(TimeshiftMutex);
time = TimeshiftPlayTime;
- TimeshiftMutex.Unlock();
}
return time;
}
@@ -881,9 +880,8 @@ time_t GetBufferTimeStart()
time_t time = 0;
if (VNSIDemuxer)
{
- TimeshiftMutex.Lock();
+ const CLockObject lock(TimeshiftMutex);
time = TimeshiftStartTime;
- TimeshiftMutex.Unlock();
}
return time;
}
@@ -893,9 +891,8 @@ time_t GetBufferTimeEnd()
time_t time = 0;
if (VNSIDemuxer)
{
- TimeshiftMutex.Lock();
+ const CLockObject lock(TimeshiftMutex);
time = TimeshiftEndTime;
- TimeshiftMutex.Unlock();
}
return time;
}
@@ -905,9 +902,8 @@ bool IsTimeshifting()
bool ret = false;
if (VNSIDemuxer)
{
- TimeshiftMutex.Lock();
+ const CLockObject lock(TimeshiftMutex);
ret = IsTimeshift;
- TimeshiftMutex.Unlock();
}
return ret;
}
--
kodi-pvr-vdr-vnsi packaging
More information about the pkg-multimedia-commits
mailing list