3371fb2c0f50506fa0c1d9dd6a6f237a8fafb083
[profile/ivi/genivi/genivi-audio-manager.git] / AudioManagerDaemon / src / ControlSender.cpp
1 /**
2 * Copyright (C) 2011, BMW AG
3 *
4 * GeniviAudioMananger AudioManagerDaemon
5 *
6 * \file ControlSender.cpp
7 *
8 * \date 20-Oct-2011 3:42:04 PM
9 * \author Christian Mueller (christian.ei.mueller@bmw.de)
10 *
11 * \section License
12 * GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
13 * Copyright (C) 2011, BMW AG Christian Mueller  Christian.ei.mueller@bmw.de
14 *
15 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
17 * You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
18 * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
19 * Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
20 * As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
21 * Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
22 *
23 */
24
25 #include "ControlSender.h"
26 #include <assert.h>
27 #include <dlt/dlt.h>
28 #include <fstream>
29 #include "PluginTemplate.h"
30
31 DLT_IMPORT_CONTEXT(AudioManager)
32
33 using namespace am;
34
35 #define REQUIRED_MIN_INTERFACE_VERSION 1
36
37 ControlSender::ControlSender(std::string controlPluginFile)
38         :mlibHandle(NULL),
39          mController(NULL)
40 {
41         std::ifstream isfile(controlPluginFile.c_str());
42         if (!isfile)
43         {
44                 DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: Controller plugin not found:"),DLT_STRING(controlPluginFile.c_str()));
45         }
46         else if (!controlPluginFile.empty())
47         {
48                 ControlSendInterface* (*createFunc)();
49                 createFunc = getCreateFunction<ControlSendInterface*()>(controlPluginFile,mlibHandle);
50                 assert(createFunc!=NULL);
51                 mController = createFunc();
52
53         //check libversion
54         assert(REQUIRED_MIN_INTERFACE_VERSION<=mController->getInterfaceVersion());
55         }
56         else
57         {
58                 DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("ControlSender::ControlSender: No controller loaded !"));
59         }
60 }
61
62 ControlSender::~ControlSender()
63 {
64         if (mlibHandle) dlclose(mlibHandle);
65 }
66
67 void ControlSender::hookAllPluginsLoaded()
68 {
69         mController->hookAllPluginsLoaded();
70 }
71
72
73
74 am_Error_e ControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
75 {
76         return mController->hookUserConnectionRequest(sourceID,sinkID,mainConnectionID);
77 }
78
79
80
81 am_Error_e ControlSender::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID)
82 {
83         return mController->hookUserDisconnectionRequest(connectionID);
84 }
85
86
87
88 am_Error_e ControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
89 {
90         return mController->hookUserSetMainSinkSoundProperty(sinkID,soundProperty);
91 }
92
93
94
95 am_Error_e ControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
96 {
97         return mController->hookUserSetMainSourceSoundProperty(sourceID,soundProperty);
98 }
99
100
101
102 am_Error_e ControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
103 {
104         return mController->hookUserSetSystemProperty(property);
105 }
106
107
108
109 am_Error_e ControlSender::hookUserVolumeChange(const am_sinkID_t sinkID, const am_mainVolume_t newVolume)
110 {
111         return mController->hookUserVolumeChange(sinkID,newVolume);
112 }
113
114
115
116 am_Error_e ControlSender::hookUserVolumeStep(const am_sinkID_t sinkID, const int16_t increment)
117 {
118         return mController->hookUserVolumeStep(sinkID,increment);
119 }
120
121
122
123 am_Error_e ControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
124 {
125         return mController->hookUserSetSinkMuteState(sinkID,muteState);
126 }
127
128
129
130 am_Error_e ControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
131 {
132         return mController->hookSystemRegisterDomain(domainData,domainID);
133 }
134
135
136
137 am_Error_e ControlSender::hookSystemDeregisterDomain(const am_domainID_t domainID)
138 {
139         return mController->hookSystemDeregisterDomain(domainID);
140 }
141
142
143
144 void ControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t domainID)
145 {
146         return mController->hookSystemDomainRegistrationComplete(domainID);
147 }
148
149
150
151 am_Error_e ControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
152 {
153         return mController->hookSystemRegisterSink(sinkData,sinkID);
154 }
155
156
157
158 am_Error_e ControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
159 {
160         return mController->hookSystemDeregisterSink(sinkID);
161 }
162
163
164
165 am_Error_e ControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
166 {
167         return mController->hookSystemRegisterSource(sourceData,sourceID);
168 }
169
170
171
172 am_Error_e ControlSender::hookSystemDeregisterSource(const am_sourceID_t sourceID)
173 {
174         return mController->hookSystemDeregisterSource(sourceID);
175 }
176
177
178
179 am_Error_e ControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
180 {
181         return mController->hookSystemRegisterGateway(gatewayData,gatewayID);
182 }
183
184
185
186 am_Error_e ControlSender::hookSystemDeregisterGateway(const am_gatewayID_t gatewayID)
187 {
188         return mController->hookSystemDeregisterGateway(gatewayID);
189 }
190
191
192
193 am_Error_e ControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
194 {
195         return mController->hookSystemRegisterCrossfader(crossfaderData,crossfaderID);
196 }
197
198
199
200 am_Error_e ControlSender::hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID)
201 {
202         return mController->hookSystemDeregisterCrossfader(crossfaderID);
203 }
204
205
206
207 void ControlSender::hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
208 {
209         return mController->hookSystemSinkVolumeTick(handle,sinkID,volume);
210 }
211
212
213
214 void ControlSender::hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
215 {
216         return mController->hookSystemSourceVolumeTick(handle,sourceID,volume);
217 }
218
219
220
221 void ControlSender::hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
222 {
223         return mController->hookSystemInterruptStateChange(sourceID,interruptState);
224 }
225
226
227
228 void ControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
229 {
230         return mController->hookSystemSinkAvailablityStateChange(sinkID,availability);
231 }
232
233
234
235 void ControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
236 {
237         return mController->hookSystemSourceAvailablityStateChange(sourceID,availability);
238 }
239
240
241
242 void ControlSender::hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state)
243 {
244         return mController->hookSystemDomainStateChange(domainID,state);
245 }
246
247
248
249 void ControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
250 {
251         return mController->hookSystemReceiveEarlyData(data);
252 }
253
254
255
256 void ControlSender::hookSystemSpeedChange(const am_speed_t speed)
257 {
258         return mController->hookSystemSpeedChange(speed);
259 }
260
261
262
263 void ControlSender::hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time)
264 {
265         return mController->hookSystemTimingInformationChanged(mainConnectionID,time);
266 }
267
268
269
270 void ControlSender::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID)
271 {
272         return mController->cbAckConnect(handle,errorID);
273 }
274
275
276
277 void ControlSender::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID)
278 {
279         return mController->cbAckDisconnect(handle,errorID);
280 }
281
282
283
284 void ControlSender::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error)
285 {
286         return mController->cbAckCrossFade(handle,hostsink,error);
287 }
288
289
290
291 void ControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
292 {
293         return mController->cbAckSetSinkVolumeChange(handle,volume,error);
294 }
295
296
297
298 void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
299 {
300         return mController->cbAckSetSourceVolumeChange(handle,volume,error);
301 }
302
303
304
305 void ControlSender::cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error)
306 {
307         return mController->cbAckSetSourceState(handle,error);
308 }
309
310
311
312 void ControlSender::cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
313 {
314         return mController->cbAckSetSourceSoundProperty(handle,error);
315 }
316
317
318
319 am_Error_e ControlSender::startupController(ControlReceiveInterface *controlreceiveinterface)
320 {
321         return mController->startupController(controlreceiveinterface);
322 }
323
324 am_Error_e ControlSender::stopController()
325 {
326         return mController->stopController();
327 }
328
329 void ControlSender::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
330 {
331         return mController->cbAckSetSinkSoundProperty(handle,error);
332 }
333
334 void ControlSender::cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
335 {
336         return mController->cbAckSetSinkSoundProperties(handle,error);
337 }
338
339 void ControlSender::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
340 {
341         return mController->cbAckSetSourceSoundProperties(handle,error);
342 }
343
344 uint16_t ControlSender::getInterfaceVersion() const
345 {
346         return ControlSendVersion;
347 }
348
349
350
351
352