khronosfws/openmax_al/src/common/xaobjectitf.c
changeset 25 6f7ceef7b1d1
parent 19 4a629bc82c5e
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: Object Interface Implementation
    15 *
    15  *
    16 */
    16  */
    17 
    17 
    18 #include <stdio.h>
    18 #include <stdio.h>
    19 #include <stdlib.h>
    19 #include <stdlib.h>
    20 #include <assert.h>
    20 #include <assert.h>
    21 
    21 
    23 
    23 
    24 /**
    24 /**
    25  * Base interface XAObjectItf implementation
    25  * Base interface XAObjectItf implementation
    26  */
    26  */
    27 XAresult XAObjectItfImpl_Realize(XAObjectItf self, XAboolean async)
    27 XAresult XAObjectItfImpl_Realize(XAObjectItf self, XAboolean async)
    28 {
    28     {
    29     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
    29     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
    30     XAresult retval = XA_RESULT_SUCCESS;
    30     XAresult retval = XA_RESULT_SUCCESS;
    31 
    31 
    32     DEBUG_API("->XAObjectItfImpl_Realize");
    32     DEBUG_API("->XAObjectItfImpl_Realize");
    33     if( !pObjImp || pObjImp != pObjImp->self)
    33     if (!pObjImp || pObjImp != pObjImp->self)
    34     {
    34         {
    35         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    35         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    36         DEBUG_API("<-XAObjectItfImpl_Realize");
    36         DEBUG_API("<-XAObjectItfImpl_Realize");
    37         /* invalid parameter */
    37         /* invalid parameter */
    38         return XA_RESULT_PARAMETER_INVALID;
    38         return XA_RESULT_PARAMETER_INVALID;
    39     }
    39         }
    40 
    40 
    41     if( async )
    41     if (async)
    42     {
    42         {
    43         /* invoke asynchronously */
    43         /* invoke asynchronously */
    44         if( !pObjImp->callBack )
    44         if (!pObjImp->callBack)
    45         {
    45             {
    46             retval = XA_RESULT_PARAMETER_INVALID;
    46             retval = XA_RESULT_PARAMETER_INVALID;
    47         }
    47             }
    48         else
    48         else
    49         {
    49             {
    50             /* check if another async operation is processed */
    50             /* check if another async operation is processed */
    51             if(pObjImp->asyncOngoing)
    51             if (pObjImp->asyncOngoing)
    52             {
    52                 {
    53                 /* abort ongoing operation */
    53                 /* abort ongoing operation */
    54                 XAImpl_CancelThread(pObjImp->asyncThr);
    54                 XAImpl_CancelThread(pObjImp->asyncThr);
    55             }
    55                 }
    56             pObjImp->asyncOngoing = XA_BOOLEAN_TRUE;
    56             pObjImp->asyncOngoing = XA_BOOLEAN_TRUE;
    57             if(XAImpl_StartThread(pObjImp->asyncThr, NULL,
    57             if (XAImpl_StartThread(pObjImp->asyncThr, NULL,
    58                     XAObjectItfImpl_AsyncRealize,(void*)(self)))
    58                     XAObjectItfImpl_AsyncRealize, (void*) (self)))
    59             {
    59                 {
    60                 pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
    60                 pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
    61                 retval = XA_RESULT_RESOURCE_ERROR;
    61                 retval = XA_RESULT_RESOURCE_ERROR;
    62             }
    62                 }
    63             else
    63             else
    64             {
    64                 {
    65                 retval = XA_RESULT_SUCCESS;
    65                 retval = XA_RESULT_SUCCESS;
    66             }
    66                 }
    67         }
    67             }
    68     }
    68         }
    69     else
    69     else
    70     {
    70         {
    71         /* Check if the object is in unrealized state */
    71         /* Check if the object is in unrealized state */
    72         if(pObjImp->state != XA_OBJECT_STATE_UNREALIZED)
    72         if (pObjImp->state != XA_OBJECT_STATE_UNREALIZED)
    73         {
    73             {
    74             DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
    74             DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
    75             DEBUG_API("<-XAObjectItfImpl_Realize");
    75             DEBUG_API("<-XAObjectItfImpl_Realize");
    76             return XA_RESULT_PRECONDITIONS_VIOLATED;
    76             return XA_RESULT_PRECONDITIONS_VIOLATED;
    77         }
    77             }
    78         /* invoke synchronously */
    78         /* invoke synchronously */
    79         if( pObjImp->DoRealizeImpl )
    79         if (pObjImp->DoRealizeImpl)
    80         {
    80             {
    81             retval = pObjImp->DoRealizeImpl(self);
    81             retval = pObjImp->DoRealizeImpl(self);
    82         }
    82             }
    83     }
    83         }DEBUG_API("<-XAObjectItfImpl_Realize");
    84     DEBUG_API("<-XAObjectItfImpl_Realize");
       
    85     return retval;
    84     return retval;
    86 }
    85     }
    87 
    86 
    88 XAresult XAObjectItfImpl_Resume(XAObjectItf self, XAboolean async)
    87 XAresult XAObjectItfImpl_Resume(XAObjectItf self, XAboolean async)
    89 {
    88     {
    90     XAresult retval = XA_RESULT_SUCCESS;
    89     XAresult retval = XA_RESULT_SUCCESS;
    91     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
    90     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
    92     DEBUG_API("->XAObjectItfImpl_Resume");
    91     DEBUG_API("->XAObjectItfImpl_Resume");
    93 
    92 
    94     if( !pObjImp || pObjImp != pObjImp->self )
    93     if (!pObjImp || pObjImp != pObjImp->self)
    95     {
    94         {
    96         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    95         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
    97         DEBUG_API("<-XAObjectItfImpl_Resume");
    96         DEBUG_API("<-XAObjectItfImpl_Resume");
    98         /* invalid parameter */
    97         /* invalid parameter */
    99         return XA_RESULT_PARAMETER_INVALID;
    98         return XA_RESULT_PARAMETER_INVALID;
   100     }
    99         }
   101     if( async )
   100     if (async)
   102     {
   101         {
   103         /* invoke asynchronously */
   102         /* invoke asynchronously */
   104         if( !pObjImp->callBack )
   103         if (!pObjImp->callBack)
   105         {
   104             {
   106             retval = XA_RESULT_PARAMETER_INVALID;
   105             retval = XA_RESULT_PARAMETER_INVALID;
   107         }
   106             }
   108         else
   107         else
   109         {
   108             {
   110             /* check if another async operation is processed */
   109             /* check if another async operation is processed */
   111             if(pObjImp->asyncOngoing)
   110             if (pObjImp->asyncOngoing)
   112             {
   111                 {
   113                 /* abort ongoing operation */
   112                 /* abort ongoing operation */
   114                 XAImpl_CancelThread(pObjImp->asyncThr);
   113                 XAImpl_CancelThread(pObjImp->asyncThr);
   115             }
   114                 }
   116             pObjImp->asyncOngoing = XA_BOOLEAN_TRUE;
   115             pObjImp->asyncOngoing = XA_BOOLEAN_TRUE;
   117             if(XAImpl_StartThread(pObjImp->asyncThr, NULL,
   116             if (XAImpl_StartThread(pObjImp->asyncThr, NULL,
   118                     XAObjectItfImpl_AsyncResume,(void*)(self)))
   117                     XAObjectItfImpl_AsyncResume, (void*) (self)))
   119             {
   118                 {
   120                 pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   119                 pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   121                 retval = XA_RESULT_RESOURCE_ERROR;
   120                 retval = XA_RESULT_RESOURCE_ERROR;
   122             }
   121                 }
   123             else
   122             else
   124             {
   123                 {
   125                 retval = XA_RESULT_SUCCESS;
   124                 retval = XA_RESULT_SUCCESS;
   126             }
   125                 }
   127         }
   126             }
   128     }
   127         }
   129     else
   128     else
   130     {
   129         {
   131         /* invoke synchronously */
   130         /* invoke synchronously */
   132         if( pObjImp->DoResumeImpl )
   131         if (pObjImp->DoResumeImpl)
   133         {
   132             {
   134             retval = pObjImp->DoResumeImpl(self);
   133             retval = pObjImp->DoResumeImpl(self);
   135         }
   134             }
   136     }
   135         }DEBUG_API("<-XAObjectItfImpl_Resume");
   137     DEBUG_API("<-XAObjectItfImpl_Resume");
       
   138     return retval;
   136     return retval;
   139 }
   137     }
   140 
   138 
   141 XAresult XAObjectItfImpl_GetState(XAObjectItf self, XAuint32 *pState)
   139 XAresult XAObjectItfImpl_GetState(XAObjectItf self, XAuint32 *pState)
   142 {
   140     {
   143     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   141     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   144     DEBUG_API("->XAObjectItfImpl_GetState");
   142     DEBUG_API("->XAObjectItfImpl_GetState");
   145     if( !pObjImp || pObjImp != pObjImp->self || !pState )
   143     if (!pObjImp || pObjImp != pObjImp->self || !pState)
   146     {
   144         {
   147         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   145         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   148         DEBUG_API("<-XAObjectItfImpl_GetState");
   146         DEBUG_API("<-XAObjectItfImpl_GetState");
   149         /* invalid parameter */
   147         /* invalid parameter */
   150         return XA_RESULT_PARAMETER_INVALID;
   148         return XA_RESULT_PARAMETER_INVALID;
   151     }
   149         }
   152     *pState = pObjImp->state;
   150     *pState = pObjImp->state;
   153 
   151 
   154     DEBUG_API("<-XAObjectItfImpl_GetState");
   152     DEBUG_API("<-XAObjectItfImpl_GetState");
   155     return XA_RESULT_SUCCESS;
   153     return XA_RESULT_SUCCESS;
   156 }
   154     }
   157 
   155 
   158 XAresult XAObjectItfImpl_GetInterface(XAObjectItf self, const XAInterfaceID iid,
   156 XAresult XAObjectItfImpl_GetInterface(XAObjectItf self,
   159                                        void *pInterface)
   157         const XAInterfaceID iid, void *pInterface)
   160 {
   158     {
   161     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   159     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   162     XAObjItfMapEntry *mapEntry = NULL;
   160     XAObjItfMapEntry *mapEntry = NULL;
   163     DEBUG_API("->XAObjectItfImpl_GetInterface");
   161     DEBUG_API("->XAObjectItfImpl_GetInterface");
   164 
   162 
   165     if( !pObjImp || pObjImp != pObjImp->self || !pInterface || !iid )
   163     if (!pObjImp || pObjImp != pObjImp->self || !pInterface || !iid)
   166     {
   164         {
   167         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   165         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   168         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   166         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   169         /* invalid parameter */
   167         /* invalid parameter */
   170         return XA_RESULT_PARAMETER_INVALID;
   168         return XA_RESULT_PARAMETER_INVALID;
   171     }
   169         }
   172 
   170 
   173     if(pObjImp->state != XA_OBJECT_STATE_REALIZED)
   171     if (pObjImp->state != XA_OBJECT_STATE_REALIZED)
   174     {
   172         {
   175         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   173         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
   176         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   174         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   177         /*state is not correct */
   175         /*state is not correct */
   178         return XA_RESULT_PRECONDITIONS_VIOLATED;
   176         return XA_RESULT_PRECONDITIONS_VIOLATED;
   179     }
   177         }
   180 
   178 
   181     mapEntry = XAObjectItfImpl_GetItfEntry(self, iid);
   179     mapEntry = XAObjectItfImpl_GetItfEntry(self, iid);
   182     if( mapEntry && mapEntry->pItf )
   180     if (mapEntry && mapEntry->pItf)
   183     {
   181         {
   184         *(void**)pInterface = &(mapEntry->pItf);
   182         *(void**) pInterface = &(mapEntry->pItf);
   185         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   183         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   186         return XA_RESULT_SUCCESS;
   184         return XA_RESULT_SUCCESS;
   187     }
   185         }
   188     else
   186     else
   189     {
   187         {
   190         DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
   188         DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
   191         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   189         DEBUG_API("<-XAObjectItfImpl_GetInterface");
   192         return XA_RESULT_FEATURE_UNSUPPORTED;
   190         return XA_RESULT_FEATURE_UNSUPPORTED;
   193     }
   191         }
   194 }
   192     }
   195 
       
   196 
   193 
   197 XAresult XAObjectItfImpl_RegisterCallback(XAObjectItf self,
   194 XAresult XAObjectItfImpl_RegisterCallback(XAObjectItf self,
   198                                        xaObjectCallback callback,
   195         xaObjectCallback callback, void *pContext)
   199                                        void *pContext)
   196     {
   200 {
   197     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   201     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
       
   202     DEBUG_API("->XAObjectItfImpl_RegisterCallback");
   198     DEBUG_API("->XAObjectItfImpl_RegisterCallback");
   203 
   199 
   204     if( !pObjImp || pObjImp != pObjImp->self )
   200     if (!pObjImp || pObjImp != pObjImp->self)
   205     {
   201         {
   206         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   202         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   207         DEBUG_API("<-XAObjectItfImpl_RegisterCallback");
   203         DEBUG_API("<-XAObjectItfImpl_RegisterCallback");
   208         /* invalid parameter */
   204         /* invalid parameter */
   209         return XA_RESULT_PARAMETER_INVALID;
   205         return XA_RESULT_PARAMETER_INVALID;
   210     }
   206         }
   211     pObjImp->callBack = callback;
   207     pObjImp->callBack = callback;
   212     pObjImp->context = pContext;
   208     pObjImp->context = pContext;
   213     pObjImp->cbPtrToSelf = self;
   209     pObjImp->cbPtrToSelf = self;
   214 
   210 
   215     DEBUG_API("<-XAObjectItfImpl_RegisterCallback");
   211     DEBUG_API("<-XAObjectItfImpl_RegisterCallback");
   216     return XA_RESULT_SUCCESS;
   212     return XA_RESULT_SUCCESS;
   217 }
   213     }
   218 
   214 
   219 void XAObjectItfImpl_AbortAsyncOperation(XAObjectItf self)
   215 void XAObjectItfImpl_AbortAsyncOperation(XAObjectItf self)
   220 {
   216     {
   221     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   217     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   222     DEBUG_API("->XAObjectItfImpl_AbortAsyncOperation");
   218     DEBUG_API("->XAObjectItfImpl_AbortAsyncOperation");
   223 
   219 
   224     if( pObjImp &&
   220     if (pObjImp && (pObjImp == pObjImp->self) && pObjImp->callBack
   225        (pObjImp == pObjImp->self) &&
   221             && pObjImp->asyncOngoing)
   226         pObjImp->callBack &&
   222         {
   227         pObjImp->asyncOngoing )
       
   228     {
       
   229         /* abort ongoing operation */
   223         /* abort ongoing operation */
   230         XAImpl_CancelThread(pObjImp->asyncThr);
   224         XAImpl_CancelThread(pObjImp->asyncThr);
   231     }
   225         }
   232 
   226 
   233     DEBUG_API("<-XAObjectItfImpl_AbortAsyncOperation");
   227     DEBUG_API("<-XAObjectItfImpl_AbortAsyncOperation");
   234 }
   228     }
   235 
   229 
   236 void XAObjectItfImpl_Destroy(XAObjectItf self)
   230 void XAObjectItfImpl_Destroy(XAObjectItf self)
   237 {
   231     {
   238     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   232     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   239     DEBUG_API("->XAObjectItfImpl_Destroy");
   233     DEBUG_API("->XAObjectItfImpl_Destroy");
   240 
   234 
   241     if( pObjImp && pObjImp == pObjImp->self )
   235     if (pObjImp && pObjImp == pObjImp->self)
   242     {
   236         {
   243         if( pObjImp->asyncOngoing )
   237         if (pObjImp->asyncOngoing)
   244         {
   238             {
   245             /* abort ongoing operation */
   239             /* abort ongoing operation */
   246             XAImpl_CancelThread(pObjImp->asyncThr);
   240             XAImpl_CancelThread(pObjImp->asyncThr);
   247         }
   241             }
   248         /* free object specific resources */
   242         /* free object specific resources */
   249         if( pObjImp->FreeResourcesImpl )
   243         if (pObjImp->FreeResourcesImpl)
   250         {
   244             {
   251             pObjImp->FreeResourcesImpl(self);
   245             pObjImp->FreeResourcesImpl(self);
   252         }
   246             }
   253         free(pObjImp->interfaceMap);
   247         free(pObjImp->interfaceMap);
   254         XAImpl_DeleteThreadHandle(pObjImp->asyncThr);
   248         XAImpl_DeleteThreadHandle(pObjImp->asyncThr);
   255         free(pObjImp);
   249         free(pObjImp);
   256     }
   250         }
   257 
   251 
   258     DEBUG_API("<-XAObjectItfImpl_Destroy");
   252     DEBUG_API("<-XAObjectItfImpl_Destroy");
   259 }
   253     }
   260 
   254 
   261 XAresult XAObjectItfImpl_SetPriority(XAObjectItf self, XAint32 priority,
   255 XAresult XAObjectItfImpl_SetPriority(XAObjectItf self, XAint32 priority,
   262                                   XAboolean preemptable)
   256         XAboolean preemptable)
   263 {
   257     {
   264     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   258     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   265     DEBUG_API("->XAObjectItfImpl_SetPriority");
   259     DEBUG_API("->XAObjectItfImpl_SetPriority");
   266 
   260 
   267     if( !pObjImp || pObjImp != pObjImp->self )
   261     if (!pObjImp || pObjImp != pObjImp->self)
   268     {
   262         {
   269         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   263         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   270         DEBUG_API("<-XAObjectItfImpl_SetPriority");
   264         DEBUG_API("<-XAObjectItfImpl_SetPriority");
   271         /* invalid parameter */
   265         /* invalid parameter */
   272         return XA_RESULT_PARAMETER_INVALID;
   266         return XA_RESULT_PARAMETER_INVALID;
   273     }
   267         }
   274     pObjImp->priority = priority;
   268     pObjImp->priority = priority;
   275     pObjImp->preemptable = preemptable;
   269     pObjImp->preemptable = preemptable;
   276 
   270 
   277     DEBUG_API("<-XAObjectItfImpl_SetPriority");
   271     DEBUG_API("<-XAObjectItfImpl_SetPriority");
   278     return XA_RESULT_SUCCESS;
   272     return XA_RESULT_SUCCESS;
   279 }
   273     }
   280 
   274 
   281 XAresult XAObjectItfImpl_GetPriority(XAObjectItf self, XAint32 *pPriority,
   275 XAresult XAObjectItfImpl_GetPriority(XAObjectItf self, XAint32 *pPriority,
   282                                   XAboolean *pPreemptable)
   276         XAboolean *pPreemptable)
   283 {
   277     {
   284     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   278     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   285     DEBUG_API("->XAObjectItfImpl_GetPriority");
   279     DEBUG_API("->XAObjectItfImpl_GetPriority");
   286 
   280 
   287     if( !pObjImp || pObjImp != pObjImp->self )
   281     if (!pObjImp || pObjImp != pObjImp->self)
   288     {
   282         {
   289         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   283         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   290         DEBUG_API("<-XAObjectItfImpl_GetPriority");
   284         DEBUG_API("<-XAObjectItfImpl_GetPriority");
   291         /* invalid parameter */
   285         /* invalid parameter */
   292         return XA_RESULT_PARAMETER_INVALID;
   286         return XA_RESULT_PARAMETER_INVALID;
   293     }
   287         }
   294     *pPriority = pObjImp->priority;
   288     *pPriority = pObjImp->priority;
   295     *pPreemptable = pObjImp->preemptable;
   289     *pPreemptable = pObjImp->preemptable;
   296 
   290 
   297     DEBUG_API("<-XAObjectItfImpl_GetPriority");
   291     DEBUG_API("<-XAObjectItfImpl_GetPriority");
   298     return XA_RESULT_SUCCESS;
   292     return XA_RESULT_SUCCESS;
   299 }
   293     }
   300 
   294 
   301 XAresult XAObjectItfImpl_SetLossOfControlInterfaces(XAObjectItf self,
   295 XAresult XAObjectItfImpl_SetLossOfControlInterfaces(XAObjectItf self,
   302                                               XAint16 numInterfaces,
   296         XAint16 numInterfaces, XAInterfaceID *pInterfaceIDs,
   303                                               XAInterfaceID *pInterfaceIDs,
   297         XAboolean enabled)
   304                                               XAboolean enabled)
   298     {
   305 {
   299     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   306     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
       
   307     XAint32 itfIndex = 0;
   300     XAint32 itfIndex = 0;
   308     XAObjItfMapEntry *mapEntry = NULL;
   301     XAObjItfMapEntry *mapEntry = NULL;
   309     DEBUG_API("->XAObjectItfImpl_SetLossOfControlInterfaces");
   302     DEBUG_API("->XAObjectItfImpl_SetLossOfControlInterfaces");
   310 
   303 
   311     if( !pObjImp || pObjImp != pObjImp->self || !pInterfaceIDs )
   304     if (!pObjImp || pObjImp != pObjImp->self || !pInterfaceIDs)
   312     {
   305         {
   313         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   306         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   314         DEBUG_API("<-XAObjectItfImpl_SetLossOfControlInterfaces");
   307         DEBUG_API("<-XAObjectItfImpl_SetLossOfControlInterfaces");
   315         /* invalid parameter */
   308         /* invalid parameter */
   316         return XA_RESULT_PARAMETER_INVALID;
   309         return XA_RESULT_PARAMETER_INVALID;
   317     }
   310         }
   318     if( pInterfaceIDs )
   311     if (pInterfaceIDs)
   319     {
   312         {
   320         for(itfIndex = 0; itfIndex < numInterfaces; itfIndex++)
   313         for (itfIndex = 0; itfIndex < numInterfaces; itfIndex++)
   321         {
   314             {
   322             mapEntry = XAObjectItfImpl_GetItfEntry(self, pInterfaceIDs[itfIndex]);
   315             mapEntry = XAObjectItfImpl_GetItfEntry(self,
   323             if( mapEntry )
   316                     pInterfaceIDs[itfIndex]);
   324             {
   317             if (mapEntry)
       
   318                 {
   325                 mapEntry->locEnabled = enabled;
   319                 mapEntry->locEnabled = enabled;
   326             }
   320                 }
   327         }
   321             }
   328     }
   322         }
   329 
   323 
   330     DEBUG_API("<-XAObjectItfImpl_SetLossOfControlInterfaces");
   324     DEBUG_API("<-XAObjectItfImpl_SetLossOfControlInterfaces");
   331     return XA_RESULT_SUCCESS;
   325     return XA_RESULT_SUCCESS;
   332 }
   326     }
   333 
   327 
   334 /**
   328 /**
   335  * XAObjectItfImpl -specific methods
   329  * XAObjectItfImpl -specific methods
   336  **/
   330  **/
   337 
   331 
   338 /*
   332 /*
   339  * Allocate and init new object itf instance
   333  * Allocate and init new object itf instance
   340  */
   334  */
   341 XAresult XAObjectItfImpl_Init(XAObjectItfImpl* self,
   335 XAresult XAObjectItfImpl_Init(XAObjectItfImpl* self, XAuint32 itfCount,
   342                               XAuint32 itfCount,
   336         const XAInterfaceID** itfIIDs, xaDoRealizeImpl doRealizeImpl,
   343                               const XAInterfaceID** itfIIDs,
   337         xaDoResumeImpl doResumeImpl, xaFreeResourcesImpl freeResourcesImpl)
   344                               xaDoRealizeImpl doRealizeImpl,
   338     {
   345                               xaDoResumeImpl doResumeImpl,
       
   346                               xaFreeResourcesImpl freeResourcesImpl)
       
   347 {
       
   348     XAuint32 i = 0;
   339     XAuint32 i = 0;
   349     DEBUG_API("->XAObjectItfImpl_Init");
   340     DEBUG_API("->XAObjectItfImpl_Init");
   350 
   341 
   351     assert( self && itfIIDs && doRealizeImpl && doResumeImpl && freeResourcesImpl );
   342     assert( self && itfIIDs && doRealizeImpl && doResumeImpl && freeResourcesImpl );
   352 
   343 
   353     self->interfaceMap =
   344     self->interfaceMap = (XAObjItfMapEntry*) calloc(itfCount,
   354        (XAObjItfMapEntry*)calloc(itfCount, sizeof(XAObjItfMapEntry));
   345             sizeof(XAObjItfMapEntry));
   355     if( !self->interfaceMap )
   346     if (!self->interfaceMap)
   356     {
   347         {
   357         free(self);
   348         free(self);
   358         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   349         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   359         DEBUG_API("<-XAObjectItfImpl_Init");
   350         DEBUG_API("<-XAObjectItfImpl_Init");
   360         return XA_RESULT_MEMORY_FAILURE;
   351         return XA_RESULT_MEMORY_FAILURE;
   361     }
   352         }
   362     if( XAImpl_CreateThreadHandle(&(self->asyncThr)) != XA_RESULT_SUCCESS )
   353     if (XAImpl_CreateThreadHandle(&(self->asyncThr)) != XA_RESULT_SUCCESS)
   363     {
   354         {
   364         free(self);
   355         free(self);
   365         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   356         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   366         DEBUG_API("<-XAObjectItfImpl_Init");
   357         DEBUG_API("<-XAObjectItfImpl_Init");
   367         return XA_RESULT_MEMORY_FAILURE;
   358         return XA_RESULT_MEMORY_FAILURE;
   368     }
   359         }
   369     for(i=0;i<itfCount;i++)
   360     for (i = 0; i < itfCount; i++)
   370     {
   361         {
   371         self->interfaceMap[i].mapIdx = i;
   362         self->interfaceMap[i].mapIdx = i;
   372         self->interfaceMap[i].iid = *(itfIIDs[i]);
   363         self->interfaceMap[i].iid = *(itfIIDs[i]);
   373         self->interfaceMap[i].pItf = NULL;
   364         self->interfaceMap[i].pItf = NULL;
   374         self->interfaceMap[i].locEnabled = XA_BOOLEAN_FALSE;
   365         self->interfaceMap[i].locEnabled = XA_BOOLEAN_FALSE;
   375         self->interfaceMap[i].required = XA_BOOLEAN_FALSE;
   366         self->interfaceMap[i].required = XA_BOOLEAN_FALSE;
   376         self->interfaceMap[i].isDynamic = XA_BOOLEAN_FALSE;
   367         self->interfaceMap[i].isDynamic = XA_BOOLEAN_FALSE;
   377     }
   368         }
   378     self->interfaceMap[0].pItf = self;
   369     self->interfaceMap[0].pItf = self;
   379     self->interfaceMap[0].required = XA_BOOLEAN_TRUE;
   370     self->interfaceMap[0].required = XA_BOOLEAN_TRUE;
   380 
   371 
   381     self->interfaceCount = itfCount;
   372     self->interfaceCount = itfCount;
   382     self->priority = XA_PRIORITY_NORMAL;
   373     self->priority = XA_PRIORITY_NORMAL;
   399     self->itf.RegisterCallback = XAObjectItfImpl_RegisterCallback;
   390     self->itf.RegisterCallback = XAObjectItfImpl_RegisterCallback;
   400     self->itf.AbortAsyncOperation = XAObjectItfImpl_AbortAsyncOperation;
   391     self->itf.AbortAsyncOperation = XAObjectItfImpl_AbortAsyncOperation;
   401     self->itf.Destroy = XAObjectItfImpl_Destroy;
   392     self->itf.Destroy = XAObjectItfImpl_Destroy;
   402     self->itf.SetPriority = XAObjectItfImpl_SetPriority;
   393     self->itf.SetPriority = XAObjectItfImpl_SetPriority;
   403     self->itf.GetPriority = XAObjectItfImpl_GetPriority;
   394     self->itf.GetPriority = XAObjectItfImpl_GetPriority;
   404     self->itf.SetLossOfControlInterfaces  = XAObjectItfImpl_SetLossOfControlInterfaces;
   395     self->itf.SetLossOfControlInterfaces
       
   396             = XAObjectItfImpl_SetLossOfControlInterfaces;
   405     self->self = self;
   397     self->self = self;
   406 
   398 
   407     DEBUG_API("<-XAObjectItfImpl_Init");
   399     DEBUG_API("<-XAObjectItfImpl_Init");
   408     return XA_RESULT_SUCCESS;
   400     return XA_RESULT_SUCCESS;
   409 }
   401     }
   410 
   402 
   411 /*
   403 /*
   412  * Asynchronous invocation of Realize
   404  * Asynchronous invocation of Realize
   413  */
   405  */
   414 void* XAObjectItfImpl_AsyncRealize(void* args)
   406 void* XAObjectItfImpl_AsyncRealize(void* args)
   415 {
   407     {
   416     XAresult retval = XA_RESULT_SUCCESS;
   408     XAresult retval = XA_RESULT_SUCCESS;
   417     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*(XAObjectItf)(args));
   409     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*(XAObjectItf) (args));
   418     DEBUG_API("->XAObjectItfImpl_AsyncRealize");
   410     DEBUG_API("->XAObjectItfImpl_AsyncRealize");
   419 
   411 
   420     if( pObjImp && pObjImp == pObjImp->self)
   412     if (pObjImp && pObjImp == pObjImp->self)
   421     {
   413         {
   422         /* Check if the object is in unrealized state */
   414         /* Check if the object is in unrealized state */
   423         if(pObjImp->state != XA_OBJECT_STATE_UNREALIZED)
   415         if (pObjImp->state != XA_OBJECT_STATE_UNREALIZED)
   424         {
   416             {
   425             retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   417             retval = XA_RESULT_PRECONDITIONS_VIOLATED;
   426         }
   418             }
   427         else if( pObjImp->DoRealizeImpl )
   419         else if (pObjImp->DoRealizeImpl)
   428         {
   420             {
   429             retval = pObjImp->DoRealizeImpl((XAObjectItf)(args));
   421             retval = pObjImp->DoRealizeImpl((XAObjectItf) (args));
   430         }
   422             }
   431         if( pObjImp->callBack )
   423         if (pObjImp->callBack)
   432         {
   424             {
   433             pObjImp->callBack(pObjImp->cbPtrToSelf, pObjImp->context,
   425             pObjImp->callBack(pObjImp->cbPtrToSelf, pObjImp->context,
   434                               XA_OBJECT_EVENT_ASYNC_TERMINATION,
   426                     XA_OBJECT_EVENT_ASYNC_TERMINATION, retval,
   435                               retval, pObjImp->state, NULL);
   427                     pObjImp->state, NULL);
   436         }
   428             }
   437         pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   429         pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   438         XAImpl_ExitThread(pObjImp->asyncThr);
   430         XAImpl_ExitThread(pObjImp->asyncThr);
   439     }
   431         }
   440     else
   432     else
   441     {
   433         {
   442         DEBUG_API("XAObjectItfImpl_AsyncRealize: INVALID args");
   434         DEBUG_API("XAObjectItfImpl_AsyncRealize: INVALID args");
   443     }
   435         }
   444     
       
   445 
   436 
   446     DEBUG_API("<-XAObjectItfImpl_AsyncRealize");
   437     DEBUG_API("<-XAObjectItfImpl_AsyncRealize");
   447     return NULL;
   438     return NULL;
   448 }
   439     }
   449 
       
   450 
   440 
   451 /*
   441 /*
   452  * Asynchronous invocation of Resume
   442  * Asynchronous invocation of Resume
   453  */
   443  */
   454 void* XAObjectItfImpl_AsyncResume(void* args)
   444 void* XAObjectItfImpl_AsyncResume(void* args)
   455 {
   445     {
   456     XAresult retval = XA_RESULT_SUCCESS;
   446     XAresult retval = XA_RESULT_SUCCESS;
   457     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*(XAObjectItf)(args));
   447     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*(XAObjectItf) (args));
   458     DEBUG_API("->XAObjectItfImpl_AsyncResume");
   448     DEBUG_API("->XAObjectItfImpl_AsyncResume");
   459 
   449 
   460     if( pObjImp && pObjImp == pObjImp->self )
   450     if (pObjImp && pObjImp == pObjImp->self)
   461     {
   451         {
   462         if( pObjImp->DoResumeImpl )
   452         if (pObjImp->DoResumeImpl)
   463         {
   453             {
   464             retval = pObjImp->DoResumeImpl((XAObjectItf)(args));
   454             retval = pObjImp->DoResumeImpl((XAObjectItf) (args));
   465         }
   455             }
   466         if( pObjImp->callBack )
   456         if (pObjImp->callBack)
   467         {
   457             {
   468             pObjImp->callBack(pObjImp->cbPtrToSelf, pObjImp->context,
   458             pObjImp->callBack(pObjImp->cbPtrToSelf, pObjImp->context,
   469                               XA_OBJECT_EVENT_ASYNC_TERMINATION,
   459                     XA_OBJECT_EVENT_ASYNC_TERMINATION, retval,
   470                               retval, pObjImp->state, NULL);
   460                     pObjImp->state, NULL);
   471         }
   461             }
   472         pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   462         pObjImp->asyncOngoing = XA_BOOLEAN_FALSE;
   473         XAImpl_ExitThread(pObjImp->asyncThr);
   463         XAImpl_ExitThread(pObjImp->asyncThr);
   474     }
   464         }
   475     else
   465     else
   476     {
   466         {
   477         DEBUG_API("XAObjectItfImpl_AsyncResume: INVALID args");
   467         DEBUG_API("XAObjectItfImpl_AsyncResume: INVALID args");
   478     }
   468         }
   479     
       
   480 
   469 
   481     DEBUG_API("<-XAObjectItfImpl_AsyncResume");
   470     DEBUG_API("<-XAObjectItfImpl_AsyncResume");
   482     return NULL;
   471     return NULL;
   483 }
   472     }
   484 
   473 
   485 XAObjItfMapEntry* XAObjectItfImpl_GetItfEntry(const XAObjectItf self,
   474 XAObjItfMapEntry* XAObjectItfImpl_GetItfEntry(const XAObjectItf self,
   486                                               const XAInterfaceID iid)
   475         const XAInterfaceID iid)
   487 {
   476     {
   488     XAuint32 mapIndex = 0;
   477     XAuint32 mapIndex = 0;
   489     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*)(*self);
   478     XAObjectItfImpl* pObjImp = (XAObjectItfImpl*) (*self);
   490     DEBUG_API("->XAObjectItfImpl_GetItfEntry");
   479     DEBUG_API("->XAObjectItfImpl_GetItfEntry");
   491 
   480 
   492     if( pObjImp &&
   481     if (pObjImp && (pObjImp == pObjImp->self) && pObjImp->interfaceMap && iid)
   493        (pObjImp == pObjImp->self) &&
   482         {
   494         pObjImp->interfaceMap &&
       
   495         iid )
       
   496     {
       
   497         /* Check interface */
   483         /* Check interface */
   498         for(mapIndex = 0; mapIndex < pObjImp->interfaceCount; mapIndex++)
   484         for (mapIndex = 0; mapIndex < pObjImp->interfaceCount; mapIndex++)
   499         {
   485             {
   500             if(XACommon_EqualIIds(pObjImp->interfaceMap[mapIndex].iid, iid))
   486             if (XACommon_EqualIIds(pObjImp->interfaceMap[mapIndex].iid, iid))
   501             {
   487                 {
   502                 DEBUG_API("<-XAObjectItfImpl_GetItfEntry");
   488                 DEBUG_API("<-XAObjectItfImpl_GetItfEntry");
   503                 return &(pObjImp->interfaceMap[mapIndex]);
   489                 return &(pObjImp->interfaceMap[mapIndex]);
   504             }
   490                 }
   505         }
   491             }
   506     }
   492         }
   507 
   493 
   508     DEBUG_API("<-XAObjectItfImpl_GetItfEntry");
   494     DEBUG_API("<-XAObjectItfImpl_GetItfEntry");
   509     return NULL;
   495     return NULL;
   510 }
   496     }
   511 
   497