khronosfws/openmax_al/src/common/xadynamicsourceitf.c
branchRCL_3
changeset 45 095bea5f582e
equal deleted inserted replaced
41:a36789189b53 45:095bea5f582e
       
     1 /*
       
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: Dynamic Source Interface Implementation
       
    15  *
       
    16  */
       
    17 
       
    18 #include <stdio.h>
       
    19 #include <stdlib.h>
       
    20 #include <assert.h>
       
    21 #include "xadynamicsourceitf.h"
       
    22 
       
    23 #include "xadynamicsourceitfadaptationmmf.h"
       
    24 
       
    25 /*****************************************************************************
       
    26  * Base interface XADynamicSourceItf implementation
       
    27  *****************************************************************************/
       
    28 
       
    29 /* XAResult XADynamicSourceItfImpl_SetSource
       
    30  * Description: Sets the data source for the object.
       
    31  */
       
    32 XAresult XADynamicSourceItfImpl_SetSource(XADynamicSourceItf self,
       
    33         XADataSource *pDataSource)
       
    34     {
       
    35     XAresult res = XA_RESULT_SUCCESS;
       
    36     XADynamicSourceItfImpl* impl = (XADynamicSourceItfImpl*) (*self);
       
    37     DEBUG_API("->XADynamicSourceItfImpl_SetSource");
       
    38     /* check casting */
       
    39     if (!impl || impl != impl->self || !pDataSource)
       
    40         {
       
    41         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    42         DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    43         return XA_RESULT_PARAMETER_INVALID;
       
    44         }
       
    45 
       
    46     if (!impl->adaptCtx)
       
    47         {
       
    48         DEBUG_ERR("Adaptation not ready!!");
       
    49         DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
    50         DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    51         res = XA_RESULT_INTERNAL_ERROR;
       
    52         }
       
    53     else
       
    54         {
       
    55         res = XACommon_CheckDataSource(pDataSource, NULL);
       
    56         if (res == XA_RESULT_SUCCESS)
       
    57             {
       
    58             if (impl->adaptCtx->fwtype == FWMgrFWMMF)
       
    59                 {
       
    60                 res = XADynamicSourceItfAdaptMMF_SetSource(
       
    61                         (XAAdaptationMMFCtx*) impl->adaptCtx, pDataSource);
       
    62                 }
       
    63             }
       
    64         }
       
    65 
       
    66     DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    67     return res;
       
    68     }
       
    69 
       
    70 /*****************************************************************************
       
    71  * XADynamicSourceItfImpl -specific methods
       
    72  *****************************************************************************/
       
    73 
       
    74 /* XADynamicSourceItfImpl* XADynamicSourceItfImpl_Create()
       
    75  * Description: Allocate and initialize DynamicSourceItfImpl
       
    76  */
       
    77 XADynamicSourceItfImpl* XADynamicSourceItfImpl_Create(
       
    78         XAAdaptationBaseCtx *adaptCtx)
       
    79     {
       
    80     XADynamicSourceItfImpl* self = (XADynamicSourceItfImpl*) calloc(1,
       
    81             sizeof(XADynamicSourceItfImpl));
       
    82 
       
    83     DEBUG_API("->XADynamicSourceItfImpl_Create");
       
    84     if (self)
       
    85         {
       
    86         /* init itf default implementation */
       
    87         self->itf.SetSource = XADynamicSourceItfImpl_SetSource;
       
    88         /* init variables */
       
    89         self->adaptCtx = adaptCtx;
       
    90         self->self = self;
       
    91         }
       
    92     DEBUG_API("<-XADynamicSourceItfImpl_Create");
       
    93     return self;
       
    94     }
       
    95 
       
    96 /* void XADynamicSourceItfImpl_Free(XADynamicSourceItfImpl* self)
       
    97  * Description: Free all resources reserved at XADynamicSourceItfImpl_Create
       
    98  */
       
    99 void XADynamicSourceItfImpl_Free(XADynamicSourceItfImpl* self)
       
   100     {
       
   101     DEBUG_API("->XADynamicSourceItfImpl_Free");
       
   102     assert( self==self->self );
       
   103     free(self);
       
   104     DEBUG_API("<-XADynamicSourceItfImpl_Free");
       
   105     }
       
   106