khronosfws/openmax_al/src/common/xadynintmgmtitf.c
changeset 25 6f7ceef7b1d1
parent 12 5a06f39ad45b
child 33 5e8b14bae8c3
equal deleted inserted replaced
21:2ed61feeead6 25:6f7ceef7b1d1
     1 /*
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5  * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6  * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10  * Nokia Corporation - initial contribution.
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  *
    14 * Description: 
    14  * Description: Dynamic Management Interface Implementation
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <stdlib.h>
    18 #include <stdlib.h>
    19 #include <assert.h>
    19 #include <assert.h>
    20 
    20 
    21 #include "openmaxalwrapper.h"
    21 #include "openmaxalwrapper.h"
    24 
    24 
    25 /* XADIMItfImpl* GetImpl(XADIMItf self)
    25 /* XADIMItfImpl* GetImpl(XADIMItf self)
    26  * Description: Validate interface pointer and cast it to implementation pointer.
    26  * Description: Validate interface pointer and cast it to implementation pointer.
    27  */
    27  */
    28 static XADIMItfImpl* GetImpl(XADynamicInterfaceManagementItf self)
    28 static XADIMItfImpl* GetImpl(XADynamicInterfaceManagementItf self)
    29 {
    29     {
    30     if( self )
    30     if (self)
    31     {
    31         {
    32         XADIMItfImpl* impl = (XADIMItfImpl*)(*self);
    32         XADIMItfImpl* impl = (XADIMItfImpl*) (*self);
    33         if( impl && (impl == impl->self) )
    33         if (impl && (impl == impl->self))
    34         {
    34             {
    35             return impl;
    35             return impl;
    36         }
    36             }
    37     }
    37         }
    38     return NULL;
    38     return NULL;
    39 }
    39     }
    40 
    40 
    41 /**
    41 /**
    42  * Base Interface XADynamicInterfaceManagementItf implementation
    42  * Base Interface XADynamicInterfaceManagementItf implementation
    43  **/
    43  **/
    44 
    44 
    45 /* XAresult XADIMItfImpl_AddInterface
    45 /* XAresult XADIMItfImpl_AddInterface
    46  * Optionally asynchronous method for exposing an interface on an object.
    46  * Optionally asynchronous method for exposing an interface on an object.
    47  */
    47  */
    48 XAresult XADIMItfImpl_AddInterface(XADynamicInterfaceManagementItf self,
    48 XAresult XADIMItfImpl_AddInterface(XADynamicInterfaceManagementItf self,
    49                                    const XAInterfaceID iid,
    49         const XAInterfaceID iid, XAboolean async)
    50                                    XAboolean async)
    50     {
    51 {
       
    52     XADIMItfImpl* impl = GetImpl(self);
    51     XADIMItfImpl* impl = GetImpl(self);
    53     XAresult retval = XA_RESULT_SUCCESS;
    52     XAresult retval = XA_RESULT_SUCCESS;
    54     DEBUG_API("->XADIMItfImpl_AddInterface");
    53     DEBUG_API("->XADIMItfImpl_AddInterface");
    55     if( !impl )
    54     if (!impl)
    56     {
    55         {
    57         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    56         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_AddInterface");
    58         DEBUG_API("<-XADIMItfImpl_AddInterface");
       
    59         return XA_RESULT_PARAMETER_INVALID;
    57         return XA_RESULT_PARAMETER_INVALID;
    60     }
    58         }
    61 
    59 
    62     if( async )
    60     if (async)
    63     {
    61         {
    64         /* invoke asynchronously */
    62         /* invoke asynchronously */
    65         /* check if another async operation is processed */
    63         /* check if another async operation is processed */
    66         if(impl->asyncOngoing)
    64         if (impl->asyncOngoing)
    67         {
    65             {
    68             /* abort ongoing operation */
    66             /* abort ongoing operation */
    69             XAImpl_CancelThread(impl->asyncThr);
    67             XAImpl_CancelThread(impl->asyncThr);
    70         }
    68             }
    71         impl->asyncOngoing = XA_BOOLEAN_TRUE;
    69         impl->asyncOngoing = XA_BOOLEAN_TRUE;
    72         impl->asyncID = iid;
    70         impl->asyncID = iid;
    73         if(XAImpl_StartThread(impl->asyncThr, NULL,
    71         if (XAImpl_StartThread(impl->asyncThr, NULL,
    74                 &XADIMItfImpl_AsyncAddItf,(void*)(self)))
    72                 &XADIMItfImpl_AsyncAddItf, (void*) (self)))
    75         {
    73             {
    76             impl->asyncOngoing = XA_BOOLEAN_FALSE;
    74             impl->asyncOngoing = XA_BOOLEAN_FALSE;
    77             retval = XA_RESULT_RESOURCE_ERROR;
    75             retval = XA_RESULT_RESOURCE_ERROR;
    78         }
    76             }
    79         else
    77         else
    80         {
    78             {
    81             retval = XA_RESULT_SUCCESS;
    79             retval = XA_RESULT_SUCCESS;
    82         }
    80             }
    83     }
    81         }
    84     else
    82     else
    85     {
    83         {
    86         /* invoke synchronously */
    84         /* invoke synchronously */
    87         retval = XADIMItfImpl_DoAddItf(impl, iid);
    85         retval = XADIMItfImpl_DoAddItf(impl, iid);
    88     }
    86         }
    89 
    87 
    90     DEBUG_API_A1("<-XADIMItfImpl_AddInterface %lu", retval);
    88     DEBUG_API_A1("<-XADIMItfImpl_AddInterface %lu", retval);
    91     return retval;
    89     return retval;
    92 }
    90     }
    93 
    91 
    94 /* XAresult XADIMItfImpl_RemoveInterface
    92 /* XAresult XADIMItfImpl_RemoveInterface
    95  * Synchronous method for removing a dynamically exposed interface on an object.
    93  * Synchronous method for removing a dynamically exposed interface on an object.
    96  */
    94  */
    97 XAresult XADIMItfImpl_RemoveInterface(XADynamicInterfaceManagementItf self,
    95 XAresult XADIMItfImpl_RemoveInterface(XADynamicInterfaceManagementItf self,
    98                                           const XAInterfaceID iid)
    96         const XAInterfaceID iid)
    99 {
    97     {
   100     XADIMItfImpl* impl = GetImpl(self);
    98     XADIMItfImpl* impl = GetImpl(self);
   101     XAresult retval = XA_RESULT_SUCCESS;
    99     XAresult retval = XA_RESULT_SUCCESS;
   102     DEBUG_API("->XADIMItfImpl_RemoveInterface");
   100     DEBUG_API("->XADIMItfImpl_RemoveInterface");
   103 
   101 
   104     if( impl )
   102     if (impl)
   105     {
   103         {
   106         XAObjItfMapEntry *mapEntry = NULL;
   104         XAObjItfMapEntry *mapEntry = NULL;
   107         if(impl->parent)
   105         if (impl->parent)
   108         {
   106             {
   109             mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
   107             mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
   110         }
   108             }
   111         if( mapEntry && mapEntry->isDynamic )
   109         if (mapEntry && mapEntry->isDynamic)
   112         {
   110             {
   113             if( (mapEntry->pItf) )
   111             if ((mapEntry->pItf))
   114             {
   112                 {
   115                 if( impl->DoRemoveItfImpl )
   113                 if (impl->DoRemoveItfImpl)
   116                 {
   114                     {
   117                     retval = impl->DoRemoveItfImpl(impl->parent, mapEntry);
   115                     retval = impl->DoRemoveItfImpl(impl->parent, mapEntry);
   118                 }
   116                     }
   119                 else
   117                 else
   120                 {
   118                     {
   121                     DEBUG_ERR("XADIMItfImpl_RemoveInterface: Object has specified dynamic itfs but not implemented DoRemoveItfImpl!!!");
   119                     DEBUG_ERR("XADIMItfImpl_RemoveInterface: Object has specified dynamic itfs but not implemented DoRemoveItfImpl!!!");
   122                     retval = XA_RESULT_INTERNAL_ERROR;
   120                     retval = XA_RESULT_INTERNAL_ERROR;
   123                 }
   121                     }
   124             }
   122                 }
   125             else
   123             else
   126             {
   124                 {
   127                 DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not exposed");
   125                 DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not exposed");
   128                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   126                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   129             }
   127                 }
   130         }
   128             }
   131         else /*( mapEntry && mapEntry->isDynamic )*/
   129         else /*( mapEntry && mapEntry->isDynamic )*/
   132         {   /* interface is not supported for dynamic management */
   130             { /* interface is not supported for dynamic management */
   133             DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not supported");
   131             DEBUG_ERR("XADIMItfImpl_RemoveInterface interface not supported");
   134             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   132             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   135         }
   133             }
   136     }
   134         }
   137     else
   135     else
   138     {
   136         {
   139         retval = XA_RESULT_PARAMETER_INVALID;
   137         retval = XA_RESULT_PARAMETER_INVALID;
   140         DEBUG_ERR("XADIMItfImpl_RemoveInterface: INVALID args");
   138         DEBUG_ERR("XADIMItfImpl_RemoveInterface: INVALID args");
   141     }
   139         }
   142 
   140 
   143     DEBUG_API_A1("<-XADIMItfImpl_RemoveInterface %lu", retval);
   141     DEBUG_API_A1("<-XADIMItfImpl_RemoveInterface %lu", retval);
   144     return retval;
   142     return retval;
   145 }
   143     }
   146 
   144 
   147 /* XAresult XADIMItfImpl_ResumeInterface
   145 /* XAresult XADIMItfImpl_ResumeInterface
   148  * Optionally asynchronous method for resuming a dynamically exposed interface on the object.
   146  * Optionally asynchronous method for resuming a dynamically exposed interface on the object.
   149  */
   147  */
   150 XAresult XADIMItfImpl_ResumeInterface(XADynamicInterfaceManagementItf self,
   148 XAresult XADIMItfImpl_ResumeInterface(XADynamicInterfaceManagementItf self,
   151                                       const XAInterfaceID iid,
   149         const XAInterfaceID iid, XAboolean async)
   152                                       XAboolean async)
   150     {
   153 {
       
   154     XADIMItfImpl* impl = GetImpl(self);
   151     XADIMItfImpl* impl = GetImpl(self);
   155     XAresult retval = XA_RESULT_SUCCESS;
   152     XAresult retval = XA_RESULT_SUCCESS;
   156     DEBUG_API("->XADIMItfImpl_ResumeInterface");
   153     DEBUG_API("->XADIMItfImpl_ResumeInterface");
   157 
   154 
   158     if( !impl )
   155     if (!impl)
   159     {
   156         {
   160         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   157         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_ResumeInterface");
   161         DEBUG_API("<-XADIMItfImpl_ResumeInterface");
       
   162         return XA_RESULT_PARAMETER_INVALID;
   158         return XA_RESULT_PARAMETER_INVALID;
   163     }
   159         }
   164 
   160 
   165     if( async )
   161     if (async)
   166     {
   162         {
   167         /* invoke asynchronously */
   163         /* invoke asynchronously */
   168         /* check if another async operation is processed */
   164         /* check if another async operation is processed */
   169         if(impl->asyncOngoing)
   165         if (impl->asyncOngoing)
   170         {
   166             {
   171             /* abort ongoing operation */
   167             /* abort ongoing operation */
   172             XAImpl_CancelThread(impl->asyncThr);
   168             XAImpl_CancelThread(impl->asyncThr);
   173         }
   169             }
   174         impl->asyncOngoing = XA_BOOLEAN_TRUE;
   170         impl->asyncOngoing = XA_BOOLEAN_TRUE;
   175         impl->asyncID = iid;
   171         impl->asyncID = iid;
   176         if(XAImpl_StartThread(impl->asyncThr, NULL,
   172         if (XAImpl_StartThread(impl->asyncThr, NULL,
   177                 &XADIMItfImpl_AsyncResumeItf,(void*)(self)))
   173                 &XADIMItfImpl_AsyncResumeItf, (void*) (self)))
   178         {
   174             {
   179             impl->asyncOngoing = XA_BOOLEAN_FALSE;
   175             impl->asyncOngoing = XA_BOOLEAN_FALSE;
   180             retval = XA_RESULT_RESOURCE_ERROR;
   176             retval = XA_RESULT_RESOURCE_ERROR;
   181         }
   177             }
   182         else
   178         else
   183         {
   179             {
   184             retval = XA_RESULT_SUCCESS;
   180             retval = XA_RESULT_SUCCESS;
   185         }
   181             }
   186     }
   182         }
   187     else
   183     else
   188     {
   184         {
   189         /* invoke synchronously */
   185         /* invoke synchronously */
   190         retval = XADIMItfImpl_DoResumeItf(impl, iid);
   186         retval = XADIMItfImpl_DoResumeItf(impl, iid);
   191     }
   187         }
   192 
   188 
   193     DEBUG_API_A1("<-XADIMItfImpl_ResumeInterface %lu", retval);
   189     DEBUG_API_A1("<-XADIMItfImpl_ResumeInterface %lu", retval);
   194     return retval;
   190     return retval;
   195 }
   191     }
   196 
   192 
   197 /* XAresult XADIMItfImpl_RegisterCallback
   193 /* XAresult XADIMItfImpl_RegisterCallback
   198  * Registers a callback on the object
   194  * Registers a callback on the object
   199  */
   195  */
   200 XAresult XADIMItfImpl_RegisterCallback(XADynamicInterfaceManagementItf self,
   196 XAresult XADIMItfImpl_RegisterCallback(XADynamicInterfaceManagementItf self,
   201                                        xaDynamicInterfaceManagementCallback callback,
   197         xaDynamicInterfaceManagementCallback callback, void * pContext)
   202                                        void * pContext)
   198     {
   203 {
       
   204     XADIMItfImpl* impl = GetImpl(self);
   199     XADIMItfImpl* impl = GetImpl(self);
   205     DEBUG_API("->XADIMItfImpl_RegisterCallback");
   200     DEBUG_API("->XADIMItfImpl_RegisterCallback");
   206 
   201 
   207     if( !impl )
   202     if (!impl)
   208     {
   203         {
   209         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   204         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("<-XADIMItfImpl_RegisterCallback");
   210         DEBUG_API("<-XADIMItfImpl_RegisterCallback");
       
   211         return XA_RESULT_PARAMETER_INVALID;
   205         return XA_RESULT_PARAMETER_INVALID;
   212     }
   206         }
   213     impl->dimCb = callback;
   207     impl->dimCb = callback;
   214     impl->dimCbContext = pContext;
   208     impl->dimCbContext = pContext;
   215     impl->dimCbPtrToSelf = self;
   209     impl->dimCbPtrToSelf = self;
   216 
   210 
   217     DEBUG_API("<-XADIMItfImpl_RegisterCallback");
   211     DEBUG_API("<-XADIMItfImpl_RegisterCallback");
   218     return XA_RESULT_SUCCESS;
   212     return XA_RESULT_SUCCESS;
   219 }
   213     }
   220 
   214 
   221 /**
   215 /**
   222  * XADIMItfImpl -specific methods
   216  * XADIMItfImpl -specific methods
   223  **/
   217  **/
   224 
   218 
   225 /* XADIMItfImpl* XADIMItfImpl_Create()
   219 /* XADIMItfImpl* XADIMItfImpl_Create()
   226  * Description: Allocate and initialize DIMItfImpl
   220  * Description: Allocate and initialize DIMItfImpl
   227  */
   221  */
   228 XADIMItfImpl* XADIMItfImpl_Create()
   222 XADIMItfImpl* XADIMItfImpl_Create()
   229 {
   223     {
   230     XADIMItfImpl *self = (XADIMItfImpl*)calloc(1,sizeof(XADIMItfImpl));
   224     XADIMItfImpl *self = (XADIMItfImpl*) calloc(1, sizeof(XADIMItfImpl));
   231     DEBUG_API("->XADIMItfImpl_Create");
   225     DEBUG_API("->XADIMItfImpl_Create");
   232 
   226 
   233     if( self )
   227     if (self)
   234     {
   228         {
   235         /* init itf default implementation */
   229         /* init itf default implementation */
   236         self->itf.AddInterface = XADIMItfImpl_AddInterface;
   230         self->itf.AddInterface = XADIMItfImpl_AddInterface;
   237         self->itf.RemoveInterface = XADIMItfImpl_RemoveInterface;
   231         self->itf.RemoveInterface = XADIMItfImpl_RemoveInterface;
   238         self->itf.ResumeInterface = XADIMItfImpl_ResumeInterface;
   232         self->itf.ResumeInterface = XADIMItfImpl_ResumeInterface;
   239         self->itf.RegisterCallback = XADIMItfImpl_RegisterCallback;
   233         self->itf.RegisterCallback = XADIMItfImpl_RegisterCallback;
   241         /* init variables */
   235         /* init variables */
   242         self->asyncOngoing = XA_BOOLEAN_FALSE;
   236         self->asyncOngoing = XA_BOOLEAN_FALSE;
   243         self->dimCbPtrToSelf = NULL;
   237         self->dimCbPtrToSelf = NULL;
   244 
   238 
   245         self->self = self;
   239         self->self = self;
   246         if( XAImpl_CreateThreadHandle(&(self->asyncThr)) != XA_RESULT_SUCCESS )
   240         if (XAImpl_CreateThreadHandle(&(self->asyncThr)) != XA_RESULT_SUCCESS)
   247         {
   241             {
   248             free(self);
   242             free(self);
   249             self = NULL;
   243             self = NULL;
   250         }
   244             }
   251     }
   245         }DEBUG_API("<-XADIMItfImpl_Create");
   252     DEBUG_API("<-XADIMItfImpl_Create");
       
   253     return self;
   246     return self;
   254 }
   247     }
   255 
   248 
   256 /* void XADIMItfImpl_Free(XADIMItfImpl* self)
   249 /* void XADIMItfImpl_Free(XADIMItfImpl* self)
   257  * Description: Free all resources reserved at XADIMItfImpl_Create
   250  * Description: Free all resources reserved at XADIMItfImpl_Create
   258  */
   251  */
   259 void XADIMItfImpl_Free(XADIMItfImpl* self)
   252 void XADIMItfImpl_Free(XADIMItfImpl* self)
   260 {
   253     {
   261     DEBUG_API("->XADIMItfImpl_Free");
   254     DEBUG_API("->XADIMItfImpl_Free");
   262     assert(self==self->self);
   255     assert(self==self->self);
   263     XAImpl_DeleteThreadHandle(self->asyncThr);
   256     XAImpl_DeleteThreadHandle(self->asyncThr);
   264     free(self);
   257     free(self);
   265     DEBUG_API("<-XADIMItfImpl_Free");
   258     DEBUG_API("<-XADIMItfImpl_Free");
   266 }
   259     }
   267 
   260 
   268 /* void XADIMItfImpl_Init
   261 /* void XADIMItfImpl_Init
   269  * Description: Initialize DIM interface. Mandatory to call if dynamic
   262  * Description: Initialize DIM interface. Mandatory to call if dynamic
   270  * interfaces are supported by object.
   263  * interfaces are supported by object.
   271  */
   264  */
   272 void XADIMItfImpl_Init( XADIMItfImpl* self,
   265 void XADIMItfImpl_Init(XADIMItfImpl* self, XAObjectItf parent,
   273                            XAObjectItf parent,
   266         xaDoAddItfImpl doAdd, xaDoResumeItfImpl doResume,
   274                            xaDoAddItfImpl doAdd,
   267         xaDoRemoveItfImpl doRemove)
   275                            xaDoResumeItfImpl doResume,
   268     {
   276                            xaDoRemoveItfImpl doRemove)
       
   277 {
       
   278     DEBUG_API("->XADIMItfImpl_Init");
   269     DEBUG_API("->XADIMItfImpl_Init");
   279 
   270 
   280     assert(self==self->self && parent && doAdd && doResume && doRemove);
   271     assert(self==self->self && parent && doAdd && doResume && doRemove);
   281     self->parent = parent;
   272     self->parent = parent;
   282     self->DoAddItfImpl = doAdd;
   273     self->DoAddItfImpl = doAdd;
   283     self->DoResumeItfImpl = doResume;
   274     self->DoResumeItfImpl = doResume;
   284     self->DoRemoveItfImpl = doRemove;
   275     self->DoRemoveItfImpl = doRemove;
   285 
   276 
   286     DEBUG_API("<-XADIMItfImpl_Init");
   277     DEBUG_API("<-XADIMItfImpl_Init");
   287 }
   278     }
   288 
   279 
   289 /* void XADIMItfImpl_SendCbEvent
   280 /* void XADIMItfImpl_SendCbEvent
   290  * Description: Object can use this method to send resource events
   281  * Description: Object can use this method to send resource events
   291  */
   282  */
   292 void XADIMItfImpl_SendCbEvent( XADIMItfImpl* self,
   283 void XADIMItfImpl_SendCbEvent(XADIMItfImpl* self, XAuint32 event,
   293                                    XAuint32 event,
   284         XAresult result, const XAInterfaceID iid)
   294                                    XAresult result,
   285     {
   295                                    const XAInterfaceID iid )
       
   296 {
       
   297     DEBUG_API("->XADIMItfImpl_SendCbEvent");
   286     DEBUG_API("->XADIMItfImpl_SendCbEvent");
   298     if( self->dimCb )
   287     if (self->dimCb)
   299      {
   288         {
   300         self->dimCb((XADynamicInterfaceManagementItf)(self), self->dimCbContext,
   289         self->dimCb((XADynamicInterfaceManagementItf) (self),
   301                       event, result, iid);
   290                 self->dimCbContext, event, result, iid);
   302      }
   291         }DEBUG_API("<-XADIMItfImpl_SendCbEvent");
   303     DEBUG_API("<-XADIMItfImpl_SendCbEvent");
   292     }
   304 }
       
   305 
   293 
   306 /* void* XADIMItfImpl_AsyncAddItf
   294 /* void* XADIMItfImpl_AsyncAddItf
   307  * Description: Launch AddItf from async thread.
   295  * Description: Launch AddItf from async thread.
   308  */
   296  */
   309 void* XADIMItfImpl_AsyncAddItf(void* args)
   297 void* XADIMItfImpl_AsyncAddItf(void* args)
   310 {
   298     {
   311     XAresult retval = XA_RESULT_SUCCESS;
   299     XAresult retval = XA_RESULT_SUCCESS;
   312     XADIMItfImpl* impl = GetImpl(args);
   300     XADIMItfImpl* impl = GetImpl(args);
   313     DEBUG_API("->XADIMItfImpl_AsyncAddItf");
   301     DEBUG_API("->XADIMItfImpl_AsyncAddItf");
   314 
   302 
   315     if( impl )
   303     if (impl)
   316     {
   304         {
   317         retval = XADIMItfImpl_DoAddItf(impl, impl->asyncID);
   305         retval = XADIMItfImpl_DoAddItf(impl, impl->asyncID);
   318         if( impl->dimCb )
   306         if (impl->dimCb)
   319         {
   307             {
   320             impl->dimCb((XADynamicInterfaceManagementItf)(args), impl->dimCbContext,
   308             impl->dimCb((XADynamicInterfaceManagementItf) (args),
   321                          XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval, impl->asyncID);
   309                     impl->dimCbContext,
   322         }
   310                     XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval,
       
   311                     impl->asyncID);
       
   312             }
   323         impl->asyncOngoing = XA_BOOLEAN_FALSE;
   313         impl->asyncOngoing = XA_BOOLEAN_FALSE;
   324         XAImpl_ExitThread(impl->asyncThr);
   314         XAImpl_ExitThread(impl->asyncThr);
   325     }
   315         }
   326     else
   316     else
   327     {
   317         {
   328         DEBUG_ERR("XADIMItfImpl_AsyncAddItf: INVALID args");
   318         DEBUG_ERR("XADIMItfImpl_AsyncAddItf: INVALID args");
   329     }
   319         }
   330     
       
   331 
   320 
   332     DEBUG_API("<-XADIMItfImpl_AsyncAddItf");
   321     DEBUG_API("<-XADIMItfImpl_AsyncAddItf");
   333     return NULL;
   322     return NULL;
   334 }
   323     }
   335 
   324 
   336 /* XAresult XADIMItfImpl_DoAddItf
   325 /* XAresult XADIMItfImpl_DoAddItf
   337  * Description: Handle Itf dynamic addition and call object-specific parts.
   326  * Description: Handle Itf dynamic addition and call object-specific parts.
   338  *              Launched either from async thread or directly.
   327  *              Launched either from async thread or directly.
   339  */
   328  */
   340 XAresult XADIMItfImpl_DoAddItf(XADIMItfImpl* impl,
   329 XAresult XADIMItfImpl_DoAddItf(XADIMItfImpl* impl, const XAInterfaceID iid)
   341                                 const XAInterfaceID iid)
   330     {
   342 {
       
   343     XAresult retval = XA_RESULT_SUCCESS;
   331     XAresult retval = XA_RESULT_SUCCESS;
   344     DEBUG_API("->XADIMItfImpl_DoAddItf");
   332     DEBUG_API("->XADIMItfImpl_DoAddItf");
   345 
   333 
   346     if( impl )
   334     if (impl)
   347     {
   335         {
   348         XAObjItfMapEntry *mapEntry = NULL;
   336         XAObjItfMapEntry *mapEntry = NULL;
   349         if(impl->parent)
   337         if (impl->parent)
   350         {
   338             {
   351             mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
   339             mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
   352         }
   340             }
   353         if( mapEntry && mapEntry->isDynamic )
   341         if (mapEntry && mapEntry->isDynamic)
   354         {
   342             {
   355             if( !(mapEntry->pItf) )
   343             if (!(mapEntry->pItf))
   356             {
   344                 {
   357                 if( impl->DoAddItfImpl )
   345                 if (impl->DoAddItfImpl)
   358                 {
   346                     {
   359                     retval = impl->DoAddItfImpl(impl->parent, mapEntry);
   347                     retval = impl->DoAddItfImpl(impl->parent, mapEntry);
   360                 }
   348                     }
   361                 else
   349                 else
   362                 {
   350                     {
   363                     DEBUG_ERR("XADIMItfImpl_DoAddItf: Object has specified dynamic itfs but not implemented DoAddItfImpl!!!");
   351                     DEBUG_ERR("XADIMItfImpl_DoAddItf: Object has specified dynamic itfs but not implemented DoAddItfImpl!!!");
   364                     retval = XA_RESULT_INTERNAL_ERROR;
   352                     retval = XA_RESULT_INTERNAL_ERROR;
   365                 }
   353                     }
   366             }
   354                 }
   367             else
   355             else
   368             {
   356                 {
   369                 DEBUG_ERR("XADIMItfImpl_DoAddItf interface already exposed");
   357                 DEBUG_ERR("XADIMItfImpl_DoAddItf interface already exposed");
   370                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   358                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   371             }
   359                 }
   372         }
   360             }
   373         else /*( mapEntry && mapEntry->isDynamic )*/
   361         else /*( mapEntry && mapEntry->isDynamic )*/
   374         {   /* interface is not supported for dynamic management */
   362             { /* interface is not supported for dynamic management */
   375             DEBUG_ERR("XADIMItfImpl_DoAddItf interface not supported");
   363             DEBUG_ERR("XADIMItfImpl_DoAddItf interface not supported");
   376             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   364             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   377         }
   365             }
   378     }
   366         }
   379     else
   367     else
   380     {
   368         {
   381         retval = XA_RESULT_INTERNAL_ERROR;
   369         retval = XA_RESULT_INTERNAL_ERROR;
   382         DEBUG_ERR("XADIMItfImpl_DoAddItf: INVALID args");
   370         DEBUG_ERR("XADIMItfImpl_DoAddItf: INVALID args");
   383     }
   371         }
   384 
   372 
   385     DEBUG_API("<-XADIMItfImpl_DoAddItf");
   373     DEBUG_API("<-XADIMItfImpl_DoAddItf");
   386     return retval;
   374     return retval;
   387 }
   375     }
   388 
   376 
   389 /* void* XADIMItfImpl_AsyncResumeItf
   377 /* void* XADIMItfImpl_AsyncResumeItf
   390  * Description: Launch ResumeItf from async thread.
   378  * Description: Launch ResumeItf from async thread.
   391  */
   379  */
   392 void* XADIMItfImpl_AsyncResumeItf(void* args)
   380 void* XADIMItfImpl_AsyncResumeItf(void* args)
   393 {
   381     {
   394     XAresult retval = XA_RESULT_SUCCESS;
   382     XAresult retval = XA_RESULT_SUCCESS;
   395     XADIMItfImpl* impl = GetImpl(args);
   383     XADIMItfImpl* impl = GetImpl(args);
   396     DEBUG_API("->XADIMItfImpl_AsyncResumeItf");
   384     DEBUG_API("->XADIMItfImpl_AsyncResumeItf");
   397 
   385 
   398     if( impl )
   386     if (impl)
   399     {
   387         {
   400         retval = XADIMItfImpl_DoResumeItf(impl, impl->asyncID);
   388         retval = XADIMItfImpl_DoResumeItf(impl, impl->asyncID);
   401         if( impl->dimCb )
   389         if (impl->dimCb)
   402         {
   390             {
   403             impl->dimCb((XADynamicInterfaceManagementItf)(args), impl->dimCbContext,
   391             impl->dimCb((XADynamicInterfaceManagementItf) (args),
   404                          XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval, impl->asyncID);
   392                     impl->dimCbContext,
   405         }
   393                     XA_DYNAMIC_ITF_EVENT_ASYNC_TERMINATION, retval,
       
   394                     impl->asyncID);
       
   395             }
   406         impl->asyncOngoing = XA_BOOLEAN_FALSE;
   396         impl->asyncOngoing = XA_BOOLEAN_FALSE;
   407         XAImpl_ExitThread(impl->asyncThr);
   397         XAImpl_ExitThread(impl->asyncThr);
   408     }
   398         }
   409     else
   399     else
   410     {
   400         {
   411         DEBUG_ERR("XADIMItfImpl_AsyncResumeItf: INVALID args");
   401         DEBUG_ERR("XADIMItfImpl_AsyncResumeItf: INVALID args");
   412     }
   402         }
   413     
       
   414 
   403 
   415     DEBUG_API("<-XADIMItfImpl_AsyncResumeItf");
   404     DEBUG_API("<-XADIMItfImpl_AsyncResumeItf");
   416     return NULL;
   405     return NULL;
   417 }
   406     }
   418 
   407 
   419 /* void XADIMItfImpl_DoResumeItf
   408 /* void XADIMItfImpl_DoResumeItf
   420  * Description: Handle Itf dynamic resuming and call object-specific parts.
   409  * Description: Handle Itf dynamic resuming and call object-specific parts.
   421  *              Launched either from async thread or directly.
   410  *              Launched either from async thread or directly.
   422  */
   411  */
   423 XAresult XADIMItfImpl_DoResumeItf(XADIMItfImpl* impl,
   412 XAresult XADIMItfImpl_DoResumeItf(XADIMItfImpl* impl, const XAInterfaceID iid)
   424                                 const XAInterfaceID iid)
   413     {
   425 {
       
   426     XAresult retval = XA_RESULT_SUCCESS;
   414     XAresult retval = XA_RESULT_SUCCESS;
   427     DEBUG_API("->XADIMItfImpl_DoResumeItf");
   415     DEBUG_API("->XADIMItfImpl_DoResumeItf");
   428 
   416 
   429     if( impl )
   417     if (impl)
   430     {
   418         {
   431         XAObjItfMapEntry *mapEntry = XAObjectItfImpl_GetItfEntry(impl->parent, iid);
   419         XAObjItfMapEntry *mapEntry = XAObjectItfImpl_GetItfEntry(
   432         if( mapEntry && mapEntry->isDynamic )
   420                 impl->parent, iid);
   433         {
   421         if (mapEntry && mapEntry->isDynamic)
   434             if( (!mapEntry->pItf) )
   422             {
   435             {
   423             if ((!mapEntry->pItf))
   436                 if( impl->DoResumeItfImpl )
   424                 {
   437                 {
   425                 if (impl->DoResumeItfImpl)
       
   426                     {
   438                     retval = impl->DoResumeItfImpl(impl->parent, mapEntry);
   427                     retval = impl->DoResumeItfImpl(impl->parent, mapEntry);
   439                 }
   428                     }
   440                 else
   429                 else
   441                 {
   430                     {
   442                     DEBUG_ERR("XADIMItfImpl_DoResumeItf: Object has specified dynamic itfs but not implemented DoResumeItfImpl!!!");
   431                     DEBUG_ERR("XADIMItfImpl_DoResumeItf: Object has specified dynamic itfs but not implemented DoResumeItfImpl!!!");
   443                     retval = XA_RESULT_INTERNAL_ERROR;
   432                     retval = XA_RESULT_INTERNAL_ERROR;
   444                 }
   433                     }
   445             }
   434                 }
   446             else
   435             else
   447             {
   436                 {
   448                 DEBUG_ERR("XADIMItfImpl_DoResumeItf interface already exposed");
   437                 DEBUG_ERR("XADIMItfImpl_DoResumeItf interface already exposed");
   449                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   438                 retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   450             }
   439                 }
   451         }
   440             }
   452         else /*( mapEntry && mapEntry->isDynamic )*/
   441         else /*( mapEntry && mapEntry->isDynamic )*/
   453         {   /* interface is not supported for dynamic management */
   442             { /* interface is not supported for dynamic management */
   454             DEBUG_ERR("XADIMItfImpl_DoResumeItf interface not supported");
   443             DEBUG_ERR("XADIMItfImpl_DoResumeItf interface not supported");
   455             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   444             retval = XA_RESULT_FEATURE_UNSUPPORTED;
   456         }
   445             }
   457     }
   446         }
   458     else
   447     else
   459     {
   448         {
   460         retval = XA_RESULT_INTERNAL_ERROR;
   449         retval = XA_RESULT_INTERNAL_ERROR;
   461         DEBUG_ERR("XADIMItfImpl_DoResumeItf: INVALID args");
   450         DEBUG_ERR("XADIMItfImpl_DoResumeItf: INVALID args");
   462     }
   451         }
   463 
   452 
   464     DEBUG_API("<-XADIMItfImpl_DoResumeItf");
   453     DEBUG_API("<-XADIMItfImpl_DoResumeItf");
   465     return retval;
   454     return retval;
   466 }
   455     }
   467 
   456