c2db4b0a4987ae17fd7eea73f306e7716327fff0
[profile/ivi/genivi/genivi-audio-manager.git] / PluginRoutingInterfaceAsync / src / RoutingReceiverAsyncShadow.cpp
1 /**
2 * Copyright (C) 2011, BMW AG
3 *
4 * GeniviAudioMananger AudioManagerDaemon
5 *
6 * \file RoutingReceiverAsyncShadow.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 "RoutingReceiverAsyncShadow.h"
26 #include "DltContext.h"
27 #include <assert.h>
28 #include <sys/socket.h>
29 #include <sys/ioctl.h>
30 #include <string.h>
31 #include <netdb.h>
32 #include <fcntl.h>
33 #include <sys/un.h>
34 #include <errno.h>
35
36 using namespace am;
37
38 pthread_mutex_t RoutingReceiverAsyncShadow::mMutex = PTHREAD_MUTEX_INITIALIZER;
39
40
41 RoutingReceiverAsyncShadow::RoutingReceiverAsyncShadow()
42         :asyncMsgReceive(this, &RoutingReceiverAsyncShadow::asyncMsgReceiver),
43          asyncDispatch(this, &RoutingReceiverAsyncShadow::asyncDispatcher),
44          asyncCheck(this, &RoutingReceiverAsyncShadow::asyncChecker),
45          mSocketHandler(),
46          mRoutingReceiveInterface(),
47          mHandle(),
48          mPipe()
49 {
50
51 }
52
53 RoutingReceiverAsyncShadow::~RoutingReceiverAsyncShadow()
54 {
55 }
56
57 void RoutingReceiverAsyncShadow::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
58 {
59         assert(mPipe[0]!=0);
60         //put the data in the queue:
61         a_connect_s temp;
62         temp.handle = handle;
63         temp.connectionID = connectionID;
64         temp.error = error;
65         //then we make a message out of it:
66         msg_s msg;
67         msg.msgID = MSG_ACKCONNECT;
68         msg.parameters.connect = temp;
69         //here we share data !
70         pthread_mutex_lock(&mMutex);
71         mQueue.push(msg);
72         pthread_mutex_unlock(&mMutex);
73
74         //ok, fire the signal that data needs to be received !
75         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
76         {
77                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackConnect write failed, error code:"),DLT_STRING(strerror(errno)));
78         }
79 }
80
81 void RoutingReceiverAsyncShadow::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
82 {
83         assert(mPipe[0]!=0);
84         //put the data in the queue:
85         a_connect_s temp;
86         temp.handle = handle;
87         temp.connectionID = connectionID;
88         temp.error = error;
89         //then we make a message out of it:
90         msg_s msg;
91         msg.msgID = MSG_ACKDISCONNECT;
92         msg.parameters.connect = temp;
93         //here we share data !
94         pthread_mutex_lock(&mMutex);
95         mQueue.push(msg);
96         pthread_mutex_unlock(&mMutex);
97
98         //ok, fire the signal that data needs to be received !
99         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
100         {
101                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackDisconnect write failed, error code:"),DLT_STRING(strerror(errno)));
102         }
103 }
104
105 void RoutingReceiverAsyncShadow::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
106 {
107         assert(mPipe[0]!=0);
108         //put the data in the queue:
109         a_volume_s temp;
110         temp.handle = handle;
111         temp.volume = volume;
112         temp.error = error;
113         //then we make a message out of it:
114         msg_s msg;
115         msg.msgID = MSG_ACKSETSINKVOLUMECHANGE;
116         msg.parameters.volume = temp;
117         //here we share data !
118         pthread_mutex_lock(&mMutex);
119         mQueue.push(msg);
120         pthread_mutex_unlock(&mMutex);
121
122         //ok, fire the signal that data needs to be received !
123         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
124         {
125                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSinkVolumeChange write failed, error code:"),DLT_STRING(strerror(errno)));
126         }
127 }
128
129 void RoutingReceiverAsyncShadow::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
130 {
131         assert(mPipe[0]!=0);
132         //put the data in the queue:
133         a_volume_s temp;
134         temp.handle = handle;
135         temp.volume = volume;
136         temp.error = error;
137         //then we make a message out of it:
138         msg_s msg;
139         msg.msgID = MSG_ACKSETSOURCEVOLUMECHANGE;
140         msg.parameters.volume = temp;
141         //here we share data !
142         pthread_mutex_lock(&mMutex);
143         mQueue.push(msg);
144         pthread_mutex_unlock(&mMutex);
145
146         //ok, fire the signal that data needs to be received !
147         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
148         {
149                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceVolumeChange write failed, error code:"),DLT_STRING(strerror(errno)));
150         }
151 }
152
153 void RoutingReceiverAsyncShadow::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
154 {
155         assert(mPipe[0]!=0);
156         //put the data in the queue:
157         a_handle_s temp;
158         temp.handle = handle;
159         temp.error = error;
160         //then we make a message out of it:
161         msg_s msg;
162         msg.msgID = MSG_ACKSETSOURCESTATE;
163         msg.parameters.handle = temp;
164         //here we share data !
165         pthread_mutex_lock(&mMutex);
166         mQueue.push(msg);
167         pthread_mutex_unlock(&mMutex);
168
169         //ok, fire the signal that data needs to be received !
170         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
171         {
172                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceState write failed, error code:"),DLT_STRING(strerror(errno)));
173         }
174 }
175
176 void RoutingReceiverAsyncShadow::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
177 {
178         assert(mPipe[0]!=0);
179         //put the data in the queue:
180         a_handle_s temp;
181         temp.handle = handle;
182         temp.error = error;
183         //then we make a message out of it:
184         msg_s msg;
185         msg.msgID = MSG_ACKSETSINKSOUNDPROPERTY;
186         msg.parameters.handle = temp;
187         //here we share data !
188         pthread_mutex_lock(&mMutex);
189         mQueue.push(msg);
190         pthread_mutex_unlock(&mMutex);
191
192         //ok, fire the signal that data needs to be received !
193         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
194         {
195                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSinkSoundProperty write failed, error code:"),DLT_STRING(strerror(errno)));
196         }
197 }
198
199 void RoutingReceiverAsyncShadow::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
200 {
201         assert(mPipe[0]!=0);
202         //put the data in the queue:
203         a_handle_s temp;
204         temp.handle = handle;
205         temp.error = error;
206         //then we make a message out of it:
207         msg_s msg;
208         msg.msgID = MSG_ACKSETSOURCESOUNDPROPERTY;
209         msg.parameters.handle = temp;
210         //here we share data !
211         pthread_mutex_lock(&mMutex);
212         mQueue.push(msg);
213         pthread_mutex_unlock(&mMutex);
214
215         //ok, fire the signal that data needs to be received !
216         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
217         {
218                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceSoundProperty write failed, error code:"),DLT_STRING(strerror(errno)));
219         }
220 }
221
222 void RoutingReceiverAsyncShadow::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
223 {
224         assert(mPipe[0]!=0);
225         //put the data in the queue:
226         a_crossfading_s temp;
227         temp.handle = handle;
228         temp.hotSink=hotSink;
229         temp.error = error;
230         //then we make a message out of it:
231         msg_s msg;
232         msg.msgID = MSG_ACKCROSSFADING;
233         msg.parameters.crossfading = temp;
234         //here we share data !
235         pthread_mutex_lock(&mMutex);
236         mQueue.push(msg);
237         pthread_mutex_unlock(&mMutex);
238
239         //ok, fire the signal that data needs to be received !
240         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
241         {
242                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackCrossFading write failed, error code:"),DLT_STRING(strerror(errno)));
243         }
244 }
245
246 void RoutingReceiverAsyncShadow::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
247 {
248         assert(mPipe[0]!=0);
249         //put the data in the queue:
250         a_sourceVolumeTick_s temp;
251         temp.sourceID=sourceID;
252         temp.handle = handle;
253         temp.volume = volume;
254         //then we make a message out of it:
255         msg_s msg;
256         msg.msgID = MSG_ACKSOURCEVOLUMETICK;
257         msg.parameters.sourceVolumeTick = temp;
258         //here we share data !
259         pthread_mutex_lock(&mMutex);
260         mQueue.push(msg);
261         pthread_mutex_unlock(&mMutex);
262
263         //ok, fire the signal that data needs to be received !
264         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
265         {
266                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSourceVolumeTick write failed, error code:"),DLT_STRING(strerror(errno)));
267         }
268 }
269
270 void RoutingReceiverAsyncShadow::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
271 {
272         assert(mPipe[0]!=0);
273         //put the data in the queue:
274         a_sinkVolumeTick_s temp;
275         temp.sinkID=sinkID;
276         temp.handle = handle;
277         temp.volume = volume;
278         //then we make a message out of it:
279         msg_s msg;
280         msg.msgID = MSG_ACKSINKVOLUMETICK;
281         msg.parameters.sinkVolumeTick = temp;
282         //here we share data !
283         pthread_mutex_lock(&mMutex);
284         mQueue.push(msg);
285         pthread_mutex_unlock(&mMutex);
286
287         //ok, fire the signal that data needs to be received !
288         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
289         {
290                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSinkVolumeTick write failed, error code:"),DLT_STRING(strerror(errno)));
291         }
292 }
293
294 void RoutingReceiverAsyncShadow::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
295 {
296         assert(mPipe[0]!=0);
297         //put the data in the queue:
298         a_interruptStatusChange_s temp;
299         temp.sourceID=sourceID;
300         temp.interruptState = interruptState;
301
302         //then we make a message out of it:
303         msg_s msg;
304         msg.msgID = MSG_HOOKINTERRUPTSTATUSCHANGE;
305         msg.parameters.interruptStatusChange = temp;
306         //here we share data !
307         pthread_mutex_lock(&mMutex);
308         mQueue.push(msg);
309         pthread_mutex_unlock(&mMutex);
310
311         //ok, fire the signal that data needs to be received !
312         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
313         {
314                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookInterruptStatusChange write failed, error code:"),DLT_STRING(strerror(errno)));
315         }
316 }
317
318 void RoutingReceiverAsyncShadow::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
319 {
320         assert(mPipe[0]!=0);
321         //put the data in the queue:
322         a_sinkAvailability_s temp;
323         temp.sinkID=sinkID;
324         temp.availability = availability;
325
326         //then we make a message out of it:
327         msg_s msg;
328         msg.msgID = MSG_HOOKSINKAVAILABLITYSTATUSCHANGE;
329         msg.parameters.sinkAvailability = temp;
330         //here we share data !
331         pthread_mutex_lock(&mMutex);
332         mQueue.push(msg);
333         pthread_mutex_unlock(&mMutex);
334
335         //ok, fire the signal that data needs to be received !
336         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
337         {
338                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookSinkAvailablityStatusChange write failed, error code:"),DLT_STRING(strerror(errno)));
339         }
340 }
341
342 void RoutingReceiverAsyncShadow::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
343 {
344         assert(mPipe[0]!=0);
345         //put the data in the queue:
346         a_sourceAvailability_s temp;
347         temp.sourceID=sourceID;
348         temp.availability = availability;
349
350         //then we make a message out of it:
351         msg_s msg;
352         msg.msgID = MSG_HOOKSOURCEAVAILABLITYSTATUSCHANGE;
353         msg.parameters.sourceAvailability = temp;
354         //here we share data !
355         pthread_mutex_lock(&mMutex);
356         mQueue.push(msg);
357         pthread_mutex_unlock(&mMutex);
358
359         //ok, fire the signal that data needs to be received !
360         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
361         {
362                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookSourceAvailablityStatusChange write failed, error code:"),DLT_STRING(strerror(errno)));
363         }
364 }
365
366 void RoutingReceiverAsyncShadow::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
367 {
368         assert(mPipe[0]!=0);
369         //put the data in the queue:
370         a_hookDomainStateChange_s temp;
371         temp.domainID=domainID;
372         temp.state = domainState;
373
374         //then we make a message out of it:
375         msg_s msg;
376         msg.msgID = MSG_HOOKDOMAINSTATECHANGE;
377         msg.parameters.domainStateChange = temp;
378         //here we share data !
379         pthread_mutex_lock(&mMutex);
380         mQueue.push(msg);
381         pthread_mutex_unlock(&mMutex);
382
383         //ok, fire the signal that data needs to be received !
384         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
385         {
386                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookDomainStateChange write failed, error code:"),DLT_STRING(strerror(errno)));
387         }
388 }
389
390 void RoutingReceiverAsyncShadow::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
391 {
392         assert(mPipe[0]!=0);
393         //put the data in the queue:
394         a_timingInfoChanged_s temp;
395         temp.connectionID=connectionID;
396         temp.delay = delay;
397
398         //then we make a message out of it:
399         msg_s msg;
400         msg.msgID = MSG_HOOKTIMINGINFORMATIONCHANGED;
401         msg.parameters.timingInfoChange = temp;
402         //here we share data !
403         pthread_mutex_lock(&mMutex);
404         mQueue.push(msg);
405         pthread_mutex_unlock(&mMutex);
406
407         //ok, fire the signal that data needs to be received !
408         if (write(mPipe[1], &msg.msgID, sizeof (msgID_e))==-1)
409         {
410                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookTimingInformationChanged write failed, error code:"),DLT_STRING(strerror(errno)));
411         }
412 }
413
414 void RoutingReceiverAsyncShadow::asyncMsgReceiver(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
415 {
416         (void)handle;
417         (void)userData;
418         //it is no really important what to read here, we will read the queue later...
419         char buffer[10];
420         if(read(pollfd.fd, buffer, 10)==-1)
421         {
422                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::asyncMsgReceiver could not read!"));
423         }
424 }
425
426 bool RoutingReceiverAsyncShadow::asyncDispatcher(const sh_pollHandle_t handle, void *userData)
427 {
428         (void)handle;
429         (void)userData;
430         msg_s msg;
431
432         //ok, let's receive, first lock
433         pthread_mutex_lock(&mMutex);
434         msg = mQueue.front();
435         mQueue.pop();
436         pthread_mutex_unlock(&mMutex);
437
438         //check for the message:
439         switch (msg.msgID){
440                 case MSG_ACKCONNECT:
441                         mRoutingReceiveInterface->ackConnect(msg.parameters.connect.handle, msg.parameters.connect.connectionID, msg.parameters.connect.error);
442                         break;
443                 case MSG_ACKDISCONNECT:
444                         mRoutingReceiveInterface->ackDisconnect(msg.parameters.connect.handle, msg.parameters.connect.connectionID, msg.parameters.connect.error);
445                         break;
446                 case MSG_ACKSETSINKVOLUMECHANGE:
447                         mRoutingReceiveInterface->ackSetSinkVolumeChange(msg.parameters.volume.handle, msg.parameters.volume.volume,msg.parameters.volume.error);
448                         break;
449                 case MSG_ACKSETSOURCEVOLUMECHANGE:
450                         mRoutingReceiveInterface->ackSetSourceVolumeChange(msg.parameters.volume.handle,msg.parameters.volume.volume,msg.parameters.volume.error);
451                         break;
452                 case MSG_ACKSETSOURCESTATE:
453                         mRoutingReceiveInterface->ackSetSourceState(msg.parameters.handle.handle,msg.parameters.handle.error);
454                         break;
455                 case MSG_ACKSETSINKSOUNDPROPERTY:
456                         mRoutingReceiveInterface->ackSetSinkSoundProperty(msg.parameters.handle.handle,msg.parameters.handle.error);
457                         break;
458                 case MSG_ACKSETSOURCESOUNDPROPERTY:
459                         mRoutingReceiveInterface->ackSetSourceSoundProperty(msg.parameters.handle.handle,msg.parameters.handle.error);
460                         break;
461                 case MSG_ACKCROSSFADING:
462                         mRoutingReceiveInterface->ackCrossFading(msg.parameters.crossfading.handle,msg.parameters.crossfading.hotSink,msg.parameters.crossfading.error);
463                         break;
464                 case MSG_ACKSOURCEVOLUMETICK:
465                         mRoutingReceiveInterface->ackSourceVolumeTick(msg.parameters.sourceVolumeTick.handle,msg.parameters.sourceVolumeTick.sourceID,msg.parameters.sourceVolumeTick.volume);
466                         break;
467                 case MSG_ACKSINKVOLUMETICK:
468                         mRoutingReceiveInterface->ackSinkVolumeTick(msg.parameters.sinkVolumeTick.handle,msg.parameters.sinkVolumeTick.sinkID,msg.parameters.sinkVolumeTick.volume);
469                         break;
470                 case MSG_HOOKINTERRUPTSTATUSCHANGE:
471                         mRoutingReceiveInterface->hookInterruptStatusChange(msg.parameters.interruptStatusChange.sourceID,msg.parameters.interruptStatusChange.interruptState);
472                         break;
473                 case MSG_HOOKSINKAVAILABLITYSTATUSCHANGE:
474                         mRoutingReceiveInterface->hookSinkAvailablityStatusChange(msg.parameters.sinkAvailability.sinkID,msg.parameters.sinkAvailability.availability);
475                         break;
476                 case MSG_HOOKSOURCEAVAILABLITYSTATUSCHANGE:
477                         mRoutingReceiveInterface->hookSourceAvailablityStatusChange(msg.parameters.sourceAvailability.sourceID,msg.parameters.sourceAvailability.availability);
478                         break;
479                 case MSG_HOOKDOMAINSTATECHANGE:
480                         mRoutingReceiveInterface->hookDomainStateChange(msg.parameters.domainStateChange.domainID,msg.parameters.domainStateChange.state);
481                         break;
482                 case MSG_HOOKTIMINGINFORMATIONCHANGED:
483                         mRoutingReceiveInterface->hookTimingInformationChanged(msg.parameters.timingInfoChange.connectionID,msg.parameters.timingInfoChange.delay);
484                         break;
485                 default:
486                         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::asyncDispatcher unknown message was received:"),DLT_INT(msg.msgID));
487                         break;
488         }
489
490         bool retVal=false;
491         pthread_mutex_lock(&mMutex);
492         if(mQueue.size() > 0) retVal=true;
493         pthread_mutex_unlock(&mMutex);
494
495         return (retVal);
496 }
497
498 bool RoutingReceiverAsyncShadow::asyncChecker(const sh_pollHandle_t handle, void *userData)
499 {
500         (void)handle;
501         (void)userData;
502         bool returnVal=false;
503         pthread_mutex_lock(&mMutex);
504         if(mQueue.size() > 0) returnVal=true;
505         pthread_mutex_unlock(&mMutex);
506         return (returnVal);
507 }
508
509 am_Error_e RoutingReceiverAsyncShadow::setRoutingInterface(RoutingReceiveInterface *receiveInterface)
510 {
511         assert(receiveInterface!=0);
512         mRoutingReceiveInterface=receiveInterface;
513         mRoutingReceiveInterface->getSocketHandler(mSocketHandler);
514         if(pipe(mPipe)==-1)
515         {
516                 DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::setRoutingInterface could not create pipe!:"));
517                 return (E_UNKNOWN);
518         }
519
520         short event = 0;
521         event |=POLLIN;
522         mSocketHandler->addFDPoll(mPipe[0],event,NULL,&asyncMsgReceive,&asyncCheck,&asyncDispatch,NULL,mHandle);
523         return (E_OK);
524 }