-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDolbyOutput.cpp
More file actions
109 lines (85 loc) · 3.5 KB
/
DolbyOutput.cpp
File metadata and controls
109 lines (85 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "../../Module.h"
#include "Dolby.h"
namespace Thunder
{
namespace Plugin
{
class DolbyOutputImplementation : public Exchange::Dolby::IOutput
{
public:
uint32_t Register(Exchange::Dolby::IOutput::INotification* notification) override
{
ASSERT(notification != nullptr);
_adminLock.Lock();
std::list<Exchange::Dolby::IOutput::INotification*>::iterator index(std::find(_observers.begin(), _observers.end(), notification));
// Make sure a sink is not registered multiple times.
ASSERT(index == _observers.end());
if (index == _observers.end()) {
_observers.push_back(notification);
notification->AddRef();
}
_adminLock.Unlock();
return (Core::ERROR_NONE);
}
uint32_t Unregister(const Exchange::Dolby::IOutput::INotification* notification) override
{
ASSERT(notification != nullptr);
_adminLock.Lock();
std::list<Exchange::Dolby::IOutput::INotification*>::iterator index(std::find(_observers.begin(), _observers.end(), notification));
// Make sure you do not unregister something you did not register !!!
ASSERT(index != _observers.end());
if (index != _observers.end()) {
(*index)->Release();
_observers.erase(index);
}
_adminLock.Unlock();
return (Core::ERROR_NONE);
}
uint32_t AtmosMetadata(bool& supported) const override
{
return (Core::ERROR_UNAVAILABLE);
}
uint32_t SoundMode(Exchange::Dolby::IOutput::SoundModes& mode) const override
{
return (Core::ERROR_UNAVAILABLE);
}
uint32_t EnableAtmosOutput(const bool& enable) override
{
return (Core::ERROR_UNAVAILABLE);
}
uint32_t Mode(const Exchange::Dolby::IOutput::Type& mode) override
{
return set_audio_output_type(mode);
}
uint32_t Mode(Exchange::Dolby::IOutput::Type& mode) const override
{
return get_audio_output_type(&mode);
}
BEGIN_INTERFACE_MAP(DolbyOutputImplementation)
INTERFACE_ENTRY(Exchange::Dolby::IOutput)
END_INTERFACE_MAP
private:
std::list<Exchange::Dolby::IOutput::INotification*> _observers;
mutable Core::CriticalSection _adminLock;
};
SERVICE_REGISTRATION(DolbyOutputImplementation, 1, 0)
} // namespace Plugin
} // namespace Thunder