Skip to content

Commit 5c073c6

Browse files
template changes
1 parent d61701e commit 5c073c6

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

AVInput/AVInput.cpp

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
**/
1919

2020
#include "AVInput.h"
21-
//#include "dsMgr.h"
21+
2222
#include "hdmiIn.hpp"
2323
#include "compositeIn.hpp"
24-
#include "manager.hpp"
2524

2625
#include "UtilsJsonRpc.h"
2726
#include "UtilsIarm.h"
28-
#include "host.hpp"
2927

3028
#include "exception.hpp"
3129
#include <vector>
@@ -129,29 +127,6 @@ AVInput::~AVInput()
129127
const string AVInput::Initialize(PluginHost::IShell * /* service */)
130128
{
131129
AVInput::_instance = this;
132-
InitializeDeviceManager();
133-
134-
return (string());
135-
}
136-
137-
void AVInput::Deinitialize(PluginHost::IShell * /* service */)
138-
{
139-
140-
device::Host::getInstance().UnRegister(m_HdmiInEventsNotification);
141-
device::Host::getInstance().UnRegister(m_CompositeInEventsNotification);
142-
_registeredDsEventHandlers = false;
143-
DeInitializeDeviceManager();
144-
145-
AVInput::_instance = nullptr;
146-
}
147-
148-
string AVInput::Information() const
149-
{
150-
return (string());
151-
}
152-
153-
void AVInput::InitializeDeviceManager()
154-
{
155130
try
156131
{
157132
device::Manager::Initialize();
@@ -161,13 +136,18 @@ void AVInput::InitializeDeviceManager()
161136
catch(...)
162137
{
163138
LOGINFO("device::Manager::Initialize failed");
139+
LOG_DEVICE_EXCEPTION0();
164140
}
165-
141+
142+
return (string());
166143
}
167144

168-
void AVInput::DeInitializeDeviceManager()
145+
void AVInput::Deinitialize(PluginHost::IShell * /* service */)
169146
{
170147

148+
device::Host::getInstance().UnRegister(baseInterface<device::Host::IHdmiInEvents>());
149+
device::Host::getInstance().UnRegister(baseInterface<device::Host::ICompositeInEvents>());
150+
_registeredDsEventHandlers = false;
171151
try
172152
{
173153
device::Manager::DeInitialize();
@@ -177,6 +157,14 @@ void AVInput::DeInitializeDeviceManager()
177157
{
178158
LOGINFO("device::Manager::DeInitialize failed");
179159
}
160+
DeInitializeDeviceManager();
161+
162+
AVInput::_instance = nullptr;
163+
}
164+
165+
string AVInput::Information() const
166+
{
167+
return (string());
180168
}
181169

182170
void AVInput::RegisterAll()
@@ -1749,8 +1737,8 @@ void AVInput::registerDsEventHandlers()
17491737
if(!_registeredDsEventHandlers)
17501738
{
17511739
_registeredDsEventHandlers = true;
1752-
device::Host::getInstance().Register(m_HdmiInEventsNotification);
1753-
device::Host::getInstance().Register(m_CompositeInEventsNotification);
1740+
device::Host::getInstance().Register(baseInterface<device::Host::IHdmiInEvents>());
1741+
device::Host::getInstance().Register(baseInterface<device::Host::ICompositeInEvents>());
17541742
}
17551743
}
17561744

AVInput/AVInput.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424

2525
#include "dsTypes.h"
2626
#include "host.hpp"
27+
#include "manager.hpp"
28+
#include "dsRpc.h"
29+
2730

2831
#define DEFAULT_PRIM_VOL_LEVEL 25
2932
#define MAX_PRIM_VOL_LEVEL 100
@@ -49,6 +52,13 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC,
4952
INTERFACE_ENTRY(PluginHost::IDispatcher)
5053
END_INTERFACE_MAP
5154

55+
template <typename T>
56+
T* baseInterface()
57+
{
58+
static_assert(std::is_base_of<T, DisplaySettings>(), "base type mismatch");
59+
return static_cast<T*>(this);
60+
}
61+
5262
int m_primVolume;
5363
int m_inputVolume; //Player Volume
5464

@@ -61,9 +71,7 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC,
6171
virtual string Information() const override;
6272

6373
protected:
64-
void InitializeDeviceManager();
65-
void DeInitializeDeviceManager();
66-
74+
6775
void RegisterAll();
6876
void UnregisterAll();
6977

@@ -131,9 +139,6 @@ class AVInput: public PluginHost::IPlugin, public PluginHost::JSONRPC,
131139

132140
private:
133141

134-
device::Host::IHdmiInEvents *m_HdmiInEventsNotification;
135-
device::Host::ICompositeInEvents *m_CompositeInEventsNotification;
136-
137142
bool _registeredDsEventHandlers;
138143

139144
public:

0 commit comments

Comments
 (0)