|
@@ -18,22 +18,22 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
#include "InProcessConfigPreconditions.h"
|
|
21
|
-
#include <interfaces/json/
|
|
21
|
+
#include <interfaces/json/JVolumeControl.h>
|
|
22
22
|
|
|
23
23
|
namespace Thunder {
|
|
24
24
|
namespace Plugin {
|
|
25
25
|
|
|
26
26
|
namespace {
|
|
27
27
|
|
|
28
|
-
static Metadata<InProcessConfigPreconditions>metadata(
|
|
28
|
+
static Metadata<InProcessConfigPreconditions> metadata(
|
|
29
29
|
// Version
|
|
30
30
|
1, 0, 0,
|
|
31
31
|
// Preconditions
|
|
32
|
-
{ subsystem::GRAPHICS },
|
|
32
|
+
{ subsystem::GRAPHICS , subsystem::NOT_GRAPHICS , subsystem::TIME },
|
|
33
33
|
// Terminations
|
|
34
|
-
{
|
|
34
|
+
{},
|
|
35
35
|
// Controls
|
|
36
|
-
{
|
|
36
|
+
{}
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -44,32 +44,72 @@ namespace Plugin {
|
|
|
44
44
|
Config config;
|
|
45
45
|
config.FromString(service->ConfigLine());
|
|
46
46
|
TRACE(Trace::Information, (_T("This is just an example: [%s]"), config.Example.Value().c_str()));
|
|
47
|
-
Exchange::
|
|
47
|
+
Exchange::JVolumeControl::Register(*this, this);
|
|
48
48
|
return (message);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
void InProcessConfigPreconditions::Deinitialize(VARIABLE_IS_NOT_USED PluginHost::IShell* service) {
|
|
52
|
-
Exchange::
|
|
52
|
+
Exchange::JVolumeControl::Unregister(*this);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
string InProcessConfigPreconditions::Information() const {
|
|
56
56
|
return (string());
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
void InProcessConfigPreconditions::Register(Exchange::IVolumeControl::INotification* notification) {
|
|
60
|
+
ASSERT(notification != nullptr);
|
|
61
|
+
|
|
62
|
+
_adminLock.Lock();
|
|
63
|
+
auto item = std::find(_volumecontrolNotification.begin(), _volumecontrolNotification.end(), notification);
|
|
64
|
+
ASSERT(item == _volumecontrolNotification.end());
|
|
65
|
+
|
|
66
|
+
if (item == _volumecontrolNotification.end()) {
|
|
67
|
+
notification->AddRef();
|
|
68
|
+
_volumecontrolNotification.push_back(notification);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_adminLock.Unlock();
|
|
61
72
|
}
|
|
62
|
-
|
|
73
|
+
void InProcessConfigPreconditions::Unregister(const Exchange::IVolumeControl::INotification* notification) {
|
|
74
|
+
ASSERT(notification != nullptr);
|
|
75
|
+
|
|
76
|
+
_adminLock.Lock();
|
|
77
|
+
auto item = std::find(_volumecontrolNotification.begin(), _volumecontrolNotification.end(), notification);
|
|
78
|
+
ASSERT(item != _volumecontrolNotification.end());
|
|
79
|
+
|
|
80
|
+
if (item != _volumecontrolNotification.end()) {
|
|
81
|
+
_volumecontrolNotification.erase(item);
|
|
82
|
+
notification->Release();
|
|
83
|
+
}
|
|
84
|
+
_adminLock.Unlock();
|
|
85
|
+
}
|
|
86
|
+
uint32_t InProcessConfigPreconditions::Muted(const bool /* muted */) {
|
|
63
87
|
return Core::ERROR_NONE;
|
|
64
88
|
}
|
|
65
|
-
|
|
89
|
+
uint32_t InProcessConfigPreconditions::Muted(bool& /* muted */ /* @out */) const {
|
|
66
90
|
return Core::ERROR_NONE;
|
|
67
91
|
}
|
|
68
|
-
|
|
92
|
+
uint32_t InProcessConfigPreconditions::Volume(const uint8_t /* volume */) {
|
|
69
93
|
return Core::ERROR_NONE;
|
|
70
94
|
}
|
|
71
|
-
|
|
95
|
+
uint32_t InProcessConfigPreconditions::Volume(uint8_t& /* volume */ /* @out */) const {
|
|
72
96
|
return Core::ERROR_NONE;
|
|
73
97
|
}
|
|
98
|
+
|
|
99
|
+
void InProcessConfigPreconditions::NotifyVolume(const uint8_t volume) const {
|
|
100
|
+
_adminLock.Lock();
|
|
101
|
+
for (auto* notification : _volumecontrolNotification) {
|
|
102
|
+
notification->Volume(volume);
|
|
103
|
+
}
|
|
104
|
+
_adminLock.Unlock();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
void InProcessConfigPreconditions::NotifyMuted(const bool muted) const {
|
|
108
|
+
_adminLock.Lock();
|
|
109
|
+
for (auto* notification : _volumecontrolNotification) {
|
|
110
|
+
notification->Muted(muted);
|
|
111
|
+
}
|
|
112
|
+
_adminLock.Unlock();
|
|
113
|
+
}
|
|
74
114
|
} // Plugin
|
|
75
115
|
} // Thunder
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
#pragma once
|
|
21
21
|
|
|
22
22
|
#include "Module.h"
|
|
23
|
-
#include <interfaces/
|
|
23
|
+
#include <interfaces/IVolumeControl.h>
|
|
24
24
|
|
|
25
25
|
namespace Thunder {
|
|
26
26
|
namespace Plugin {
|
|
27
27
|
|
|
28
|
-
class InProcessConfigPreconditions : public PluginHost::IPlugin, public PluginHost::JSONRPC, public Exchange::
|
|
28
|
+
class InProcessConfigPreconditions : public PluginHost::IPlugin, public PluginHost::JSONRPC, public Exchange::IVolumeControl {
|
|
29
29
|
public:
|
|
30
30
|
InProcessConfigPreconditions(const InProcessConfigPreconditions&) = delete;
|
|
31
31
|
InProcessConfigPreconditions& operator=(const InProcessConfigPreconditions&) = delete;
|
|
@@ -35,27 +35,28 @@ namespace Plugin {
|
|
|
35
35
|
InProcessConfigPreconditions()
|
|
36
36
|
: PluginHost::IPlugin()
|
|
37
37
|
, PluginHost::JSONRPC()
|
|
38
|
-
, Exchange::
|
|
38
|
+
, Exchange::IVolumeControl()
|
|
39
39
|
, _adminLock()
|
|
40
|
-
,
|
|
40
|
+
, _volumecontrolNotification()
|
|
41
41
|
{
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
~InProcessConfigPreconditions() override = default;
|
|
45
|
-
|
|
45
|
+
private:
|
|
46
|
+
class PluginConfig : public Core::JSON::Container {
|
|
46
47
|
public:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
PluginConfig(const PluginConfig&) = delete;
|
|
49
|
+
PluginConfig& operator=(const PluginConfig&) = delete;
|
|
50
|
+
PluginConfig(PluginConfig&&) = delete;
|
|
51
|
+
PluginConfig& operator=(PluginConfig&&) = delete;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
PluginConfig()
|
|
53
54
|
: Core::JSON::Container()
|
|
54
55
|
, Example()
|
|
55
56
|
{
|
|
56
57
|
Add(_T("example"), &Example);
|
|
57
58
|
}
|
|
58
|
-
~
|
|
59
|
+
~PluginConfig() override = default;
|
|
59
60
|
public:
|
|
60
61
|
Core::JSON::String Example;
|
|
61
62
|
};
|
|
@@ -65,29 +66,34 @@ namespace Plugin {
|
|
|
65
66
|
void Deinitialize(PluginHost::IShell* service) override;
|
|
66
67
|
string Information() const override;
|
|
67
68
|
|
|
68
|
-
//
|
|
69
|
+
// IVolumeControl methods
|
|
70
|
+
|
|
71
|
+
void Register(Exchange::IVolumeControl::INotification* const /* sink */) override;
|
|
69
72
|
|
|
70
|
-
|
|
73
|
+
void Unregister(const Exchange::IVolumeControl::INotification* const /* sink */) override;
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
uint32_t Muted(const bool /* muted */) override;
|
|
73
76
|
|
|
74
|
-
|
|
77
|
+
uint32_t Muted(bool& /* muted */ /* @out */) const override;
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
uint32_t Volume(const uint8_t /* volume */) override;
|
|
77
80
|
|
|
78
|
-
|
|
81
|
+
uint32_t Volume(uint8_t& /* volume */ /* @out */) const override;
|
|
79
82
|
|
|
80
83
|
BEGIN_INTERFACE_MAP(InProcessConfigPreconditions)
|
|
81
84
|
INTERFACE_ENTRY(PluginHost::IPlugin)
|
|
82
85
|
INTERFACE_ENTRY(PluginHost::IDispatcher)
|
|
83
|
-
INTERFACE_ENTRY(Exchange::
|
|
86
|
+
INTERFACE_ENTRY(Exchange::IVolumeControl)
|
|
84
87
|
END_INTERFACE_MAP
|
|
85
88
|
|
|
86
89
|
private:
|
|
87
|
-
using
|
|
90
|
+
using VolumeControlNotificationContainer = std::vector<Exchange::IVolumeControl::INotification*>;
|
|
91
|
+
|
|
92
|
+
void NotifyVolume(const uint8_t /* volume */) const;
|
|
93
|
+
void NotifyMuted(const bool /* muted */) const;
|
|
88
94
|
|
|
89
95
|
mutable Core::CriticalSection _adminLock;
|
|
90
|
-
|
|
96
|
+
VolumeControlNotificationContainer _volumecontrolNotification;
|
|
91
97
|
};
|
|
92
98
|
} // Plugin
|
|
93
99
|
} // Thunder
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
"interface": {
|
|
29
|
-
"$cppref": "{cppinterfacedir}/
|
|
29
|
+
"$cppref": "{cppinterfacedir}/IVolumeControl.h"
|
|
30
30
|
}
|
|
31
31
|
}
|