* formatting all the source code with eclipse source code style
[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 RoutingReceiverAsyncShadow::RoutingReceiverAsyncShadow():
41 asyncMsgReceive(this, &RoutingReceiverAsyncShadow::asyncMsgReceiver), //
42 asyncDispatch(this, &RoutingReceiverAsyncShadow::asyncDispatcher),//
43 asyncCheck(this, &RoutingReceiverAsyncShadow::asyncChecker), //
44 mSocketHandler(), //
45 mRoutingReceiveInterface(),//
46 mHandle (),//
47 mPipe()
48 {
49
50 }
51
52 RoutingReceiverAsyncShadow::~RoutingReceiverAsyncShadow()
53 {
54 }
55
56 void RoutingReceiverAsyncShadow::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
57 {
58     assert(mPipe[0]!=0);
59     //put the data in the queue:
60     a_connect_s temp;
61     temp.handle = handle;
62     temp.connectionID = connectionID;
63     temp.error = error;
64     //then we make a message out of it:
65     msg_s msg;
66     msg.msgID = MSG_ACKCONNECT;
67     msg.parameters.connect = temp;
68     //here we share data !
69     pthread_mutex_lock(&mMutex);
70     mQueue.push(msg);
71     pthread_mutex_unlock(&mMutex);
72
73     //ok, fire the signal that data needs to be received !
74     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
75     {
76         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackConnect write failed, error code:"), DLT_STRING(strerror(errno)));
77     }
78 }
79
80 void RoutingReceiverAsyncShadow::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
81 {
82     assert(mPipe[0]!=0);
83     //put the data in the queue:
84     a_connect_s temp;
85     temp.handle = handle;
86     temp.connectionID = connectionID;
87     temp.error = error;
88     //then we make a message out of it:
89     msg_s msg;
90     msg.msgID = MSG_ACKDISCONNECT;
91     msg.parameters.connect = temp;
92     //here we share data !
93     pthread_mutex_lock(&mMutex);
94     mQueue.push(msg);
95     pthread_mutex_unlock(&mMutex);
96
97     //ok, fire the signal that data needs to be received !
98     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
99     {
100         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackDisconnect write failed, error code:"), DLT_STRING(strerror(errno)));
101     }
102 }
103
104 void RoutingReceiverAsyncShadow::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
105 {
106     assert(mPipe[0]!=0);
107     //put the data in the queue:
108     a_volume_s temp;
109     temp.handle = handle;
110     temp.volume = volume;
111     temp.error = error;
112     //then we make a message out of it:
113     msg_s msg;
114     msg.msgID = MSG_ACKSETSINKVOLUMECHANGE;
115     msg.parameters.volume = temp;
116     //here we share data !
117     pthread_mutex_lock(&mMutex);
118     mQueue.push(msg);
119     pthread_mutex_unlock(&mMutex);
120
121     //ok, fire the signal that data needs to be received !
122     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
123     {
124         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSinkVolumeChange write failed, error code:"), DLT_STRING(strerror(errno)));
125     }
126 }
127
128 void RoutingReceiverAsyncShadow::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
129 {
130     assert(mPipe[0]!=0);
131     //put the data in the queue:
132     a_volume_s temp;
133     temp.handle = handle;
134     temp.volume = volume;
135     temp.error = error;
136     //then we make a message out of it:
137     msg_s msg;
138     msg.msgID = MSG_ACKSETSOURCEVOLUMECHANGE;
139     msg.parameters.volume = temp;
140     //here we share data !
141     pthread_mutex_lock(&mMutex);
142     mQueue.push(msg);
143     pthread_mutex_unlock(&mMutex);
144
145     //ok, fire the signal that data needs to be received !
146     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
147     {
148         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceVolumeChange write failed, error code:"), DLT_STRING(strerror(errno)));
149     }
150 }
151
152 void RoutingReceiverAsyncShadow::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
153 {
154     assert(mPipe[0]!=0);
155     //put the data in the queue:
156     a_handle_s temp;
157     temp.handle = handle;
158     temp.error = error;
159     //then we make a message out of it:
160     msg_s msg;
161     msg.msgID = MSG_ACKSETSOURCESTATE;
162     msg.parameters.handle = temp;
163     //here we share data !
164     pthread_mutex_lock(&mMutex);
165     mQueue.push(msg);
166     pthread_mutex_unlock(&mMutex);
167
168     //ok, fire the signal that data needs to be received !
169     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
170     {
171         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceState write failed, error code:"), DLT_STRING(strerror(errno)));
172     }
173 }
174
175 void RoutingReceiverAsyncShadow::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
176 {
177     assert(mPipe[0]!=0);
178     //put the data in the queue:
179     a_handle_s temp;
180     temp.handle = handle;
181     temp.error = error;
182     //then we make a message out of it:
183     msg_s msg;
184     msg.msgID = MSG_ACKSETSINKSOUNDPROPERTY;
185     msg.parameters.handle = temp;
186     //here we share data !
187     pthread_mutex_lock(&mMutex);
188     mQueue.push(msg);
189     pthread_mutex_unlock(&mMutex);
190
191     //ok, fire the signal that data needs to be received !
192     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
193     {
194         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSinkSoundProperty write failed, error code:"), DLT_STRING(strerror(errno)));
195     }
196 }
197
198 void RoutingReceiverAsyncShadow::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
199 {
200     assert(mPipe[0]!=0);
201     //put the data in the queue:
202     a_handle_s temp;
203     temp.handle = handle;
204     temp.error = error;
205     //then we make a message out of it:
206     msg_s msg;
207     msg.msgID = MSG_ACKSETSOURCESOUNDPROPERTY;
208     msg.parameters.handle = temp;
209     //here we share data !
210     pthread_mutex_lock(&mMutex);
211     mQueue.push(msg);
212     pthread_mutex_unlock(&mMutex);
213
214     //ok, fire the signal that data needs to be received !
215     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
216     {
217         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSetSourceSoundProperty write failed, error code:"), DLT_STRING(strerror(errno)));
218     }
219 }
220
221 void RoutingReceiverAsyncShadow::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
222 {
223     assert(mPipe[0]!=0);
224     //put the data in the queue:
225     a_crossfading_s temp;
226     temp.handle = handle;
227     temp.hotSink = hotSink;
228     temp.error = error;
229     //then we make a message out of it:
230     msg_s msg;
231     msg.msgID = MSG_ACKCROSSFADING;
232     msg.parameters.crossfading = temp;
233     //here we share data !
234     pthread_mutex_lock(&mMutex);
235     mQueue.push(msg);
236     pthread_mutex_unlock(&mMutex);
237
238     //ok, fire the signal that data needs to be received !
239     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
240     {
241         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackCrossFading write failed, error code:"), DLT_STRING(strerror(errno)));
242     }
243 }
244
245 void RoutingReceiverAsyncShadow::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
246 {
247     assert(mPipe[0]!=0);
248     //put the data in the queue:
249     a_sourceVolumeTick_s temp;
250     temp.sourceID = sourceID;
251     temp.handle = handle;
252     temp.volume = volume;
253     //then we make a message out of it:
254     msg_s msg;
255     msg.msgID = MSG_ACKSOURCEVOLUMETICK;
256     msg.parameters.sourceVolumeTick = temp;
257     //here we share data !
258     pthread_mutex_lock(&mMutex);
259     mQueue.push(msg);
260     pthread_mutex_unlock(&mMutex);
261
262     //ok, fire the signal that data needs to be received !
263     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
264     {
265         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSourceVolumeTick write failed, error code:"), DLT_STRING(strerror(errno)));
266     }
267 }
268
269 void RoutingReceiverAsyncShadow::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
270 {
271     assert(mPipe[0]!=0);
272     //put the data in the queue:
273     a_sinkVolumeTick_s temp;
274     temp.sinkID = sinkID;
275     temp.handle = handle;
276     temp.volume = volume;
277     //then we make a message out of it:
278     msg_s msg;
279     msg.msgID = MSG_ACKSINKVOLUMETICK;
280     msg.parameters.sinkVolumeTick = temp;
281     //here we share data !
282     pthread_mutex_lock(&mMutex);
283     mQueue.push(msg);
284     pthread_mutex_unlock(&mMutex);
285
286     //ok, fire the signal that data needs to be received !
287     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
288     {
289         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::ackSinkVolumeTick write failed, error code:"), DLT_STRING(strerror(errno)));
290     }
291 }
292
293 void RoutingReceiverAsyncShadow::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
294 {
295     assert(mPipe[0]!=0);
296     //put the data in the queue:
297     a_interruptStatusChange_s temp;
298     temp.sourceID = sourceID;
299     temp.interruptState = interruptState;
300
301     //then we make a message out of it:
302     msg_s msg;
303     msg.msgID = MSG_HOOKINTERRUPTSTATUSCHANGE;
304     msg.parameters.interruptStatusChange = temp;
305     //here we share data !
306     pthread_mutex_lock(&mMutex);
307     mQueue.push(msg);
308     pthread_mutex_unlock(&mMutex);
309
310     //ok, fire the signal that data needs to be received !
311     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
312     {
313         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookInterruptStatusChange write failed, error code:"), DLT_STRING(strerror(errno)));
314     }
315 }
316
317 void RoutingReceiverAsyncShadow::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
318 {
319     assert(mPipe[0]!=0);
320     //put the data in the queue:
321     a_sinkAvailability_s temp;
322     temp.sinkID = sinkID;
323     temp.availability = availability;
324
325     //then we make a message out of it:
326     msg_s msg;
327     msg.msgID = MSG_HOOKSINKAVAILABLITYSTATUSCHANGE;
328     msg.parameters.sinkAvailability = temp;
329     //here we share data !
330     pthread_mutex_lock(&mMutex);
331     mQueue.push(msg);
332     pthread_mutex_unlock(&mMutex);
333
334     //ok, fire the signal that data needs to be received !
335     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
336     {
337         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookSinkAvailablityStatusChange write failed, error code:"), DLT_STRING(strerror(errno)));
338     }
339 }
340
341 void RoutingReceiverAsyncShadow::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
342 {
343     assert(mPipe[0]!=0);
344     //put the data in the queue:
345     a_sourceAvailability_s temp;
346     temp.sourceID = sourceID;
347     temp.availability = availability;
348
349     //then we make a message out of it:
350     msg_s msg;
351     msg.msgID = MSG_HOOKSOURCEAVAILABLITYSTATUSCHANGE;
352     msg.parameters.sourceAvailability = temp;
353     //here we share data !
354     pthread_mutex_lock(&mMutex);
355     mQueue.push(msg);
356     pthread_mutex_unlock(&mMutex);
357
358     //ok, fire the signal that data needs to be received !
359     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
360     {
361         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookSourceAvailablityStatusChange write failed, error code:"), DLT_STRING(strerror(errno)));
362     }
363 }
364
365 void RoutingReceiverAsyncShadow::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
366 {
367     assert(mPipe[0]!=0);
368     //put the data in the queue:
369     a_hookDomainStateChange_s temp;
370     temp.domainID = domainID;
371     temp.state = domainState;
372
373     //then we make a message out of it:
374     msg_s msg;
375     msg.msgID = MSG_HOOKDOMAINSTATECHANGE;
376     msg.parameters.domainStateChange = temp;
377     //here we share data !
378     pthread_mutex_lock(&mMutex);
379     mQueue.push(msg);
380     pthread_mutex_unlock(&mMutex);
381
382     //ok, fire the signal that data needs to be received !
383     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
384     {
385         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookDomainStateChange write failed, error code:"), DLT_STRING(strerror(errno)));
386     }
387 }
388
389 void RoutingReceiverAsyncShadow::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
390 {
391     assert(mPipe[0]!=0);
392     //put the data in the queue:
393     a_timingInfoChanged_s temp;
394     temp.connectionID = connectionID;
395     temp.delay = delay;
396
397     //then we make a message out of it:
398     msg_s msg;
399     msg.msgID = MSG_HOOKTIMINGINFORMATIONCHANGED;
400     msg.parameters.timingInfoChange = temp;
401     //here we share data !
402     pthread_mutex_lock(&mMutex);
403     mQueue.push(msg);
404     pthread_mutex_unlock(&mMutex);
405
406     //ok, fire the signal that data needs to be received !
407     if (write(mPipe[1], &msg.msgID, sizeof(msgID_e)) == -1)
408     {
409         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::hookTimingInformationChanged write failed, error code:"), DLT_STRING(strerror(errno)));
410     }
411 }
412
413 void RoutingReceiverAsyncShadow::asyncMsgReceiver(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
414 {
415     (void) handle;
416     (void) userData;
417     //it is no really important what to read here, we will read the queue later...
418     char buffer[10];
419     if (read(pollfd.fd, buffer, 10) == -1)
420     {
421         DLT_LOG(PluginRoutingAsync, DLT_LOG_ERROR, DLT_STRING("RoutingReceiverAsyncShadow::asyncMsgReceiver could not read!"));
422     }
423 }
424
425 bool RoutingReceiverAsyncShadow::asyncDispatcher(const sh_pollHandle_t handle, void *userData)
426 {
427     (void) handle;
428     (void) userData;
429     msg_s msg;
430
431     //ok, let's receive, first lock
432     pthread_mutex_lock(&mMutex);
433     msg = mQueue.front();
434     mQueue.pop();
435     pthread_mutex_unlock(&mMutex);
436
437     //check for the message:
438     switch (msg.msgID)
439     {
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 }