Skip to content

Commit

Permalink
Merge pull request xbmc#18343 from AlwinEsch/change-screensaver
Browse files Browse the repository at this point in the history
[addons][screensaver] cleanup API, improve "C" interface, not use void* direct as value
  • Loading branch information
AlwinEsch authored Aug 30, 2020
2 parents d5e05d8 + e6be9b9 commit a3d5f73
Show file tree
Hide file tree
Showing 5 changed files with 507 additions and 413 deletions.
41 changes: 24 additions & 17 deletions xbmc/addons/ScreenSaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,21 @@ CScreenSaver::CScreenSaver(const AddonInfoPtr& addonInfo)
m_presets = CSpecialProtocol::TranslatePath(Path());
m_profile = CSpecialProtocol::TranslatePath(Profile());

m_struct = {{0}};
m_struct.props.x = 0;
m_struct.props.y = 0;
m_struct.props.device = CServiceBroker::GetWinSystem()->GetHWContext();
m_struct.props.width = CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth();
m_struct.props.height = CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight();
m_struct.props.pixelRatio = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().fPixelRatio;
m_struct.props.name = m_name.c_str();
m_struct.props.presets = m_presets.c_str();
m_struct.props.profile = m_profile.c_str();
m_struct.props = new AddonProps_Screensaver();
m_struct.props->x = 0;
m_struct.props->y = 0;
m_struct.props->device = CServiceBroker::GetWinSystem()->GetHWContext();
m_struct.props->width = CServiceBroker::GetWinSystem()->GetGfxContext().GetWidth();
m_struct.props->height = CServiceBroker::GetWinSystem()->GetGfxContext().GetHeight();
m_struct.props->pixelRatio = CServiceBroker::GetWinSystem()->GetGfxContext().GetResInfo().fPixelRatio;
m_struct.props->name = m_name.c_str();
m_struct.props->presets = m_presets.c_str();
m_struct.props->profile = m_profile.c_str();

m_struct.toKodi.kodiInstance = this;
m_struct.toKodi = new AddonToKodiFuncTable_Screensaver();
m_struct.toKodi->kodiInstance = this;

m_struct.toAddon = new KodiToAddonFuncTable_Screensaver();

/* Open the class "kodi::addon::CInstanceScreensaver" on add-on side */
if (CreateInstance(&m_struct) != ADDON_STATUS_OK)
Expand All @@ -45,25 +48,29 @@ CScreenSaver::~CScreenSaver()
{
/* Destroy the class "kodi::addon::CInstanceScreensaver" on add-on side */
DestroyInstance();

delete m_struct.toAddon;
delete m_struct.toKodi;
delete m_struct.props;
}

bool CScreenSaver::Start()
{
if (m_struct.toAddon.Start)
return m_struct.toAddon.Start(&m_struct);
if (m_struct.toAddon->Start)
return m_struct.toAddon->Start(&m_struct);
return false;
}

void CScreenSaver::Stop()
{
if (m_struct.toAddon.Stop)
m_struct.toAddon.Stop(&m_struct);
if (m_struct.toAddon->Stop)
m_struct.toAddon->Stop(&m_struct);
}

void CScreenSaver::Render()
{
if (m_struct.toAddon.Render)
m_struct.toAddon.Render(&m_struct);
if (m_struct.toAddon->Render)
m_struct.toAddon->Render(&m_struct);
}

} /* namespace ADDON */
Loading

0 comments on commit a3d5f73

Please sign in to comment.