khronosfws/openmax_al/src/adptcommon/xacapabilitiesmgr.c
changeset 53 eabc8c503852
parent 33 5e8b14bae8c3
equal deleted inserted replaced
48:a493a607b5bf 53:eabc8c503852
    17  */
    17  */
    18 
    18 
    19 #include "xacapabilitiesmgr.h"
    19 #include "xacapabilitiesmgr.h"
    20 #include "xammfcapabilitiesmgr.h"
    20 #include "xammfcapabilitiesmgr.h"
    21 #include "xagstcapabilitiesmgr.h"
    21 #include "xagstcapabilitiesmgr.h"
       
    22 #include "xaadptbasectx.h"
    22 #include <stdio.h>
    23 #include <stdio.h>
    23 #include <string.h>
    24 #include <string.h>
    24 
    25 
    25 static XAresult XACapabilitiesMgr_GetAudioInputDeviceCapabilities(
    26 static XAresult XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities(
       
    27         XACapabilities **ppNode);
       
    28 static XAresult XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities(
       
    29         XACapabilities **ppNode);
       
    30 static XAresult XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities(
    26         XACapabilities **ppNode);
    31         XACapabilities **ppNode);
    27 static XAresult XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(
    32 static XAresult XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(
    28         XACapabilities **ppNode);
    33         XACapabilities **ppNode);
    29 
    34 
    30 /* XAresult XAGSTCapabilitiesMgr_UpdateAudioIOCapabilitieList
    35 /* XAresult XAGSTCapabilitiesMgr_UpdateAudioIOCapabilitieList
    31  * Description: Update the capabilities list supported by GStreamer framework.
    36  * Description: Update the capabilities list supported by the engine.
    32  */
    37  */
    33 XAresult XACapabilitiesMgr_UpdateAudioIOCapabilitieList(
    38 XAresult XACapabilitiesMgr_UpdateAudioIOCapabilitieList(
    34         FrameworkMap *frameworkMap, XACapabilities **ppListHead)
    39         FrameworkMap *frameworkMap, XACapabilities **ppListHead)
    35 
    40 
    36     {
    41     {
    37     XAresult res = XA_RESULT_SUCCESS;
    42     XAresult res = XA_RESULT_SUCCESS;
    38     XACapabilities *lastNode;
    43     XACapabilities *lastNode = NULL;
    39     XACapabilities *firstNode;
    44     XACapabilities *firstNode = NULL;
    40     XACapabilities *newNode = NULL;
    45     XACapabilities *newNode = NULL;
    41 
    46 
       
    47     DEBUG_API("->XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
       
    48 
    42     if (!frameworkMap || !ppListHead)
    49     if (!frameworkMap || !ppListHead)
    43         {
    50         {
    44         res = XA_RESULT_PARAMETER_INVALID;
    51         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    52         DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
       
    53         return XA_RESULT_PARAMETER_INVALID;
       
    54         }
       
    55 
       
    56     res = XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities(&newNode);
       
    57     if (res != XA_RESULT_SUCCESS)
       
    58         {
       
    59         XACapabilitiesMgr_DeleteCapabilitieList(&firstNode);
       
    60         DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
    45         return res;
    61         return res;
    46         }
    62         }
    47 
    63 
    48     lastNode = *ppListHead;
    64     if (!firstNode)
    49     firstNode = *ppListHead;
    65         {
    50 
    66         firstNode = newNode;
    51     DEBUG_API("->XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
    67         lastNode = newNode;
    52 
    68         }
    53     /* traverse and point to the last node in the list */
    69     
    54     while (lastNode && lastNode->next)
    70     res = XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities(&newNode);
    55         {
       
    56         lastNode = lastNode->next;
       
    57         }
       
    58 
       
    59     /* If no input devices are supported, the function returns
       
    60      * XA_RESULT_SUCCESS and newNode will be NULL*/
       
    61     newNode = NULL;
       
    62     res = XACapabilitiesMgr_GetAudioInputDeviceCapabilities(&newNode);
       
    63     if (res != XA_RESULT_SUCCESS)
    71     if (res != XA_RESULT_SUCCESS)
    64         {
    72         {
       
    73         XACapabilitiesMgr_DeleteCapabilitieList(&firstNode);
       
    74         DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
    65         return res;
    75         return res;
    66         }
    76         }
    67 
    77 
    68     if (lastNode)
    78     if (!firstNode)
       
    79         {
       
    80         firstNode = newNode;
       
    81         lastNode = newNode;
       
    82         }
       
    83     else
    69         {
    84         {
    70         lastNode->next = newNode;
    85         lastNode->next = newNode;
    71         }
       
    72     if (newNode)
       
    73         { /* if a new node is created move lastNode to the new item */
       
    74         if (!firstNode)
       
    75             firstNode = newNode;
       
    76         lastNode = newNode;
    86         lastNode = newNode;
    77         }
    87         }
    78 
    88     
    79     /* If no input devices are supported, the function returns
    89     res = XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities(&newNode);
    80      * XA_RESULT_SUCCESS and newNode will be NULL*/
    90     if (res != XA_RESULT_SUCCESS)
    81     newNode = NULL;
    91         {
       
    92         XACapabilitiesMgr_DeleteCapabilitieList(&firstNode);
       
    93         DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
       
    94         return res;
       
    95         }
       
    96 
       
    97     if (!firstNode)
       
    98         {
       
    99         firstNode = newNode;
       
   100         lastNode = newNode;
       
   101         }
       
   102     else
       
   103         {
       
   104         lastNode->next = newNode;
       
   105         lastNode = newNode;
       
   106         }
       
   107 
    82     res = XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(&newNode);
   108     res = XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(&newNode);
    83     if (res != XA_RESULT_SUCCESS)
   109     if (res != XA_RESULT_SUCCESS)
    84         {
   110         {
       
   111         XACapabilitiesMgr_DeleteCapabilitieList(&firstNode);
       
   112         DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
    85         return res;
   113         return res;
    86         }
   114         }
    87 
   115 
    88     if (lastNode)
   116     if (!firstNode)
       
   117         {
       
   118         firstNode = newNode;
       
   119         lastNode = newNode;
       
   120         }
       
   121     else
    89         {
   122         {
    90         lastNode->next = newNode;
   123         lastNode->next = newNode;
    91         }
       
    92     if (newNode)
       
    93         { /* if a new node is created move lastNode to the new item */
       
    94         if (!firstNode)
       
    95             firstNode = newNode;
       
    96         lastNode = newNode;
   124         lastNode = newNode;
    97         }
   125         }
    98     /* if empty list, then append first node as the head */
   126 
    99     if (!(*ppListHead))
   127     /* if we have some iodevice capabilities in the list */
   100         {
   128     if (firstNode)
   101         *ppListHead = firstNode;
   129         {
       
   130         /* if empty list, then append first node as the head */
       
   131         if (!(*ppListHead))
       
   132             {
       
   133             *ppListHead = firstNode;
       
   134             }
       
   135         else /* traverse to the last item in the list and link firstNode to it */
       
   136             {
       
   137             lastNode = *ppListHead;
       
   138             while(lastNode->next)
       
   139                 {
       
   140                 lastNode = lastNode->next;
       
   141                 }
       
   142             lastNode->next = firstNode;
       
   143             }
   102         }
   144         }
   103     DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
   145     DEBUG_API("<-XACapabilitiesMgr_UpdateAudioIOCapabilitieList");
   104     return res;
   146     return res;
   105     }
   147     }
   106 
   148 
   107 XAresult XACapabilitiesMgr_CreateCapabilitieList(FrameworkMap* frameworkMap,
   149 XAresult XACapabilitiesMgr_CreateCapabilitieList(FrameworkMap* frameworkMap,
   108         XACapabilities** ppListHead)
   150         XACapabilities** ppListHead)
   109     {
   151     {
   110     XACapabilities* list = NULL;
   152     XACapabilities* list = NULL;
   111     XAresult res = XA_RESULT_SUCCESS;
   153     XAresult res = XA_RESULT_SUCCESS;
   112     if (!ppListHead)
   154 
   113         {
   155     DEBUG_API("->XACapabilitiesMgr_CreateCapabilitieList");
   114         res = XA_RESULT_PARAMETER_INVALID;
   156     if (!frameworkMap || !ppListHead)
   115         return res;
   157         {
       
   158         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   159         DEBUG_API("<-XACapabilitiesMgr_CreateCapabilitieList");
       
   160         return XA_RESULT_PARAMETER_INVALID;
   116         }
   161         }
   117 
   162 
   118     *ppListHead = NULL;
   163     *ppListHead = NULL;
   119 
   164 
   120     res = XACapabilitiesMgr_UpdateAudioIOCapabilitieList(frameworkMap, &list);
   165     res = XACapabilitiesMgr_UpdateAudioIOCapabilitieList(frameworkMap, &list);
   121     if (res != XA_RESULT_SUCCESS)
   166     if (res != XA_RESULT_SUCCESS)
   122         {
   167         {
   123         XACapabilitiesMgr_DeleteCapabilitieList(&list);
   168         XACapabilitiesMgr_DeleteCapabilitieList(&list);
       
   169         DEBUG_API("<-XACapabilitiesMgr_CreateCapabilitieList");
   124         return res;
   170         return res;
   125         }
   171         }
   126 
   172 
   127     res = XAGSTCapabilitiesMgr_UpdateCapabilitieList(frameworkMap, &list);
   173     res = XAGSTCapabilitiesMgr_UpdateCapabilitieList(frameworkMap, &list);
   128     if (res != XA_RESULT_SUCCESS)
   174     if (res != XA_RESULT_SUCCESS)
   129         {
   175         {
   130         XACapabilitiesMgr_DeleteCapabilitieList(&list);
   176         XACapabilitiesMgr_DeleteCapabilitieList(&list);
       
   177         DEBUG_API("<-XACapabilitiesMgr_CreateCapabilitieList");
   131         return res;
   178         return res;
   132         }
   179         }
   133 
   180 
   134     res = XAMMFCapabilitiesMgr_UpdateCapabilitieList(frameworkMap, &list);
   181     res = XAMMFCapabilitiesMgr_UpdateCapabilitieList(frameworkMap, &list);
   135     if (res != XA_RESULT_SUCCESS)
   182     if (res != XA_RESULT_SUCCESS)
   136         {
   183         {
   137         XACapabilitiesMgr_DeleteCapabilitieList(&list);
   184         XACapabilitiesMgr_DeleteCapabilitieList(&list);
       
   185         DEBUG_API("<-XACapabilitiesMgr_CreateCapabilitieList");
   138         return res;
   186         return res;
   139         }
   187         }
   140 
   188 
   141     *ppListHead = list;
   189     *ppListHead = list;
       
   190     DEBUG_API("<-XACapabilitiesMgr_CreateCapabilitieList");
   142     return res;
   191     return res;
   143     }
   192     }
   144 
   193 
   145 XAresult XACapabilitiesMgr_DeleteCapabilitieList(XACapabilities** ppListHead)
   194 XAresult XACapabilitiesMgr_DeleteCapabilitieList(XACapabilities** ppListHead)
   146     {
   195     {
   147     XACapabilities* currNode = NULL;
   196     XACapabilities* currNode = NULL;
   148     XACapabilities* nextNode = NULL;
   197     XACapabilities* nextNode = NULL;
   149     XAresult res = XA_RESULT_SUCCESS;
   198     XAresult res = XA_RESULT_SUCCESS;
   150 
   199 
       
   200     DEBUG_API("->XACapabilitiesMgr_DeleteCapabilitieList");
   151     if (!ppListHead)
   201     if (!ppListHead)
   152         {
   202         {
   153         res = XA_RESULT_PARAMETER_INVALID;
   203         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   154         return res;
   204         DEBUG_API("<-XACapabilitiesMgr_DeleteCapabilitieList");
       
   205         return XA_RESULT_PARAMETER_INVALID;
   155         }
   206         }
   156 
   207 
   157     currNode = *ppListHead;
   208     currNode = *ppListHead;
   158     while (currNode)
   209     while (currNode)
   159         {
   210         {
   190                 {
   241                 {
   191                 free(entries[i].pSampleRatesSupported);
   242                 free(entries[i].pSampleRatesSupported);
   192                 free(entries[i].pBitratesSupported);
   243                 free(entries[i].pBitratesSupported);
   193                 }
   244                 }
   194             free(entries);
   245             free(entries);
   195 
       
   196             }
   246             }
   197 
   247 
   198         if (currNode->adaptId)
   248         if (currNode->adaptId)
   199             {
   249             {
   200             free(currNode->adaptId);
   250             free(currNode->adaptId);
   204         free(currNode);
   254         free(currNode);
   205         currNode = nextNode;
   255         currNode = nextNode;
   206         }
   256         }
   207 
   257 
   208     *ppListHead = NULL;
   258     *ppListHead = NULL;
       
   259 
       
   260     DEBUG_API("<-XACapabilitiesMgr_DeleteCapabilitieList");
   209     return res;
   261     return res;
   210     }
   262     }
   211 
   263 
   212 /* XAresult XACapabilitiesMgr_GetCapsCount
   264 /* XAresult XACapabilitiesMgr_GetCapsCount
   213  * Description: Count capabilities of certain type. Filter is specified by
   265  * Description: Count capabilities of certain type. Filter is specified by
   220     XACapabilities* currNode = pListHead;
   272     XACapabilities* currNode = pListHead;
   221 
   273 
   222     DEBUG_API("->XACapabilitiesMgr_GetCapsCount");
   274     DEBUG_API("->XACapabilitiesMgr_GetCapsCount");
   223     if (!currNode || !count)
   275     if (!currNode || !count)
   224         {
   276         {
   225         res = XA_RESULT_PARAMETER_INVALID;
   277         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   226         return res;
   278         DEBUG_API("<-XACapabilitiesMgr_GetCapsCount");
       
   279         return XA_RESULT_PARAMETER_INVALID;
   227         }
   280         }
   228 
   281 
   229     (*count) = 0;
   282     (*count) = 0;
   230     while (currNode)
   283     while (currNode)
   231         {
   284         {
   252 
   305 
   253     DEBUG_API("->XACapabilitiesMgr_GetCapsById");
   306     DEBUG_API("->XACapabilitiesMgr_GetCapsById");
   254 
   307 
   255     if (!currNode)
   308     if (!currNode)
   256         {
   309         {
   257         res = XA_RESULT_PARAMETER_INVALID;
   310         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   258         return res;
   311         DEBUG_API("<-XACapabilitiesMgr_GetCapsById");
       
   312         return XA_RESULT_PARAMETER_INVALID;
   259         }
   313         }
   260 
   314 
   261     while (currNode)
   315     while (currNode)
   262         {
   316         {
   263         if (((currNode->capsType & filter) == filter) && (maxId
   317         if (((currNode->capsType & filter) == filter) && (maxId
   270         currNode = currNode->next;
   324         currNode = currNode->next;
   271         }
   325         }
   272 
   326 
   273     if (!found)
   327     if (!found)
   274         {
   328         {
   275         res = XA_RESULT_FEATURE_UNSUPPORTED;
   329         DEBUG_ERR("XA_RESULT_FEATURE_UNSUPPORTED");
   276         return res;
   330         DEBUG_API("<-XACapabilitiesMgr_GetCapsById");
       
   331         return XA_RESULT_FEATURE_UNSUPPORTED;
   277         }
   332         }
   278 
   333 
   279     DEBUG_API("<-XACapabilitiesMgr_GetCapsById");
   334     DEBUG_API("<-XACapabilitiesMgr_GetCapsById");
   280     return res;
   335     return res;
   281     }
   336     }
   293 
   348 
   294     DEBUG_API("->XACapabilitiesMgr_GetCapsByIdx");
   349     DEBUG_API("->XACapabilitiesMgr_GetCapsByIdx");
   295 
   350 
   296     if (!currNode)
   351     if (!currNode)
   297         {
   352         {
   298         res = XA_RESULT_PARAMETER_INVALID;
   353         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   299         return res;
   354         DEBUG_API("<-XACapabilitiesMgr_GetCapsByIdx");
       
   355         return XA_RESULT_PARAMETER_INVALID;
   300         }
   356         }
   301 
   357 
   302     while (currNode)
   358     while (currNode)
   303         {
   359         {
   304         if ((currNode->capsType & filter) == filter)
   360         if ((currNode->capsType & filter) == filter)
   313         currNode = currNode->next;
   369         currNode = currNode->next;
   314         }
   370         }
   315 
   371 
   316     if (!found)
   372     if (!found)
   317         {
   373         {
   318         res = XA_RESULT_PARAMETER_INVALID;
   374         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   319         return res;
   375         DEBUG_API("<-XACapabilitiesMgr_GetCapsByIdx");
       
   376         return XA_RESULT_PARAMETER_INVALID;
   320         }
   377         }
   321 
   378 
   322     DEBUG_API("<-XACapabilitiesMgr_GetCapsByIdx");
   379     DEBUG_API("<-XACapabilitiesMgr_GetCapsByIdx");
   323     return res;
   380     return res;
   324     }
   381     }
   334 
   391 
   335     DEBUG_API("->XACapabilitiesMgr_QueryColorFormats");
   392     DEBUG_API("->XACapabilitiesMgr_QueryColorFormats");
   336 
   393 
   337     if (!pIndex)
   394     if (!pIndex)
   338         {
   395         {
   339         DEBUG_ERR("illegal NULL parameter");
   396         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   340         res = XA_RESULT_PARAMETER_INVALID;
   397         DEBUG_API("<-XACapabilitiesMgr_QueryColorFormats");
   341         return res;
   398         return XA_RESULT_PARAMETER_INVALID;
   342         }
   399         }
   343 
   400 
   344     res = XACapabilitiesMgr_GetCapsById(pListHead,
   401     res = XACapabilitiesMgr_GetCapsById(pListHead,
   345             (XACapsType) ((XACapsType) (XACAP_ENCODER | XACAP_IMAGE)),
   402             (XACapsType) ((XACapsType) (XACAP_ENCODER | XACAP_IMAGE)),
   346             XA_IMAGECODEC_RAW, &temp);
   403             XA_IMAGECODEC_RAW, &temp);
   352             }
   409             }
   353         else
   410         else
   354             { /* query color format */
   411             { /* query color format */
   355             if (*pIndex >= 1) /* one used by camera context */
   412             if (*pIndex >= 1) /* one used by camera context */
   356                 {
   413                 {
   357                 DEBUG_ERR("index parameter invalid");
   414                 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   358                 res = XA_RESULT_PARAMETER_INVALID;
   415                 res = XA_RESULT_PARAMETER_INVALID;
   359                 }
   416                 }
   360             else
   417             else
   361                 { /* internal format used by pipeline, look camera context for details  */
   418                 { /* internal format used by pipeline, look camera context for details  */
   362                 *pColorFormats = XA_COLORFORMAT_YUV420PLANAR;
   419                 *pColorFormats = XA_COLORFORMAT_YUV420PLANAR;
   371     DEBUG_API("<-XACapabilitiesMgr_QueryColorFormats");
   428     DEBUG_API("<-XACapabilitiesMgr_QueryColorFormats");
   372     return res;
   429     return res;
   373     }
   430     }
   374 
   431 
   375 /* Add AudioInputDeviceCaps */
   432 /* Add AudioInputDeviceCaps */
   376 XAresult XACapabilitiesMgr_GetAudioInputDeviceCapabilities(
   433 XAresult XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities(
   377         XACapabilities** ppNode)
   434         XACapabilities** ppNode)
   378     {
   435     {
   379     XAresult res = XA_RESULT_SUCCESS;
   436     XAresult res = XA_RESULT_SUCCESS;
   380     XACapabilities *newNode = NULL;
   437     XACapabilities *newNode = NULL;
   381     XAAudioInputDescriptor *entries = NULL;
   438     XAAudioInputDescriptor *entries = NULL;
   382     XAchar micDeviceName[] = "Default Mic";
   439     XAchar inpDeviceName[] = "Default Mic";
   383     int strLen = 0;
   440     int strLen = 0;
   384 
   441 
       
   442     DEBUG_API("->XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
   385     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
   443     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
   386     if (!newNode)
   444     if (!newNode)
   387         {
   445         {
   388         res = XA_RESULT_MEMORY_FAILURE;
   446         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   389         return res;
   447         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
       
   448         return XA_RESULT_MEMORY_FAILURE;
   390         }
   449         }
   391 
   450 
   392     newNode->capsType = AUD_I;
   451     newNode->capsType = AUD_I;
   393     newNode->xaid = 0xAD7E5001;
   452     newNode->xaid = XA_ADAPTID_DEVSOUNDSRC_MIC;
   394     newNode->noOfEntries = 1;
   453     newNode->noOfEntries = 1;
   395 
   454 
   396     /* Allocate array */
   455     /* Allocate array */
   397     entries = (XAAudioInputDescriptor*) calloc(1,
   456     entries = (XAAudioInputDescriptor*) calloc(1,
   398             sizeof(XAAudioInputDescriptor));
   457             sizeof(XAAudioInputDescriptor));
   399     if (!entries)
   458     if (!entries)
   400         {
   459         {
   401         res = XA_RESULT_MEMORY_FAILURE;
   460         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   402         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   461         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   403         return res;
   462         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
       
   463         return XA_RESULT_MEMORY_FAILURE;
   404         }
   464         }
   405 
   465 
   406     newNode->pEntry = (void*) entries;
   466     newNode->pEntry = (void*) entries;
   407 
   467 
   408     strLen = strlen((char*) micDeviceName);
   468     strLen = strlen((char*) inpDeviceName);
   409     entries->deviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
   469     entries->deviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
   410     if (!entries->deviceName)
   470     if (!entries->deviceName)
   411         {
   471         {
   412         res = XA_RESULT_MEMORY_FAILURE;
   472         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   413         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   473         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   414         return res;
   474         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
   415         }
   475         return XA_RESULT_MEMORY_FAILURE;
   416 
   476         }
   417     strncpy((char*) entries->deviceName, (char*) micDeviceName, strLen);
   477 
       
   478     strncpy((char*) entries->deviceName, (char*) inpDeviceName, strLen);
   418     entries->deviceName[strLen] = '\0'; /*Null terminate it*/
   479     entries->deviceName[strLen] = '\0'; /*Null terminate it*/
   419     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
   480     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
   420     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
   481     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
   421     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
   482     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
   422     entries->isForTelephony = XA_BOOLEAN_FALSE;
   483     entries->isForTelephony = XA_BOOLEAN_FALSE;
   423     entries->minSampleRate = 8000000; /* milliHz */
   484     entries->minSampleRate = 8000000; /* milliHz */
   424     entries->maxSampleRate = 96000000; /* milliHz */
   485     entries->maxSampleRate = 48000000; /* milliHz */
   425     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
   486     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
   426     entries->numOfSamplingRatesSupported = 12;
   487     entries->numOfSamplingRatesSupported = 5;
   427     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
   488     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
   428             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
   489             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
   429     if (!entries->samplingRatesSupported)
   490     if (!entries->samplingRatesSupported)
   430         {
   491         {
   431         res = XA_RESULT_MEMORY_FAILURE;
   492         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   432         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   493         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   433         return res;
   494         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
       
   495         return XA_RESULT_MEMORY_FAILURE;
   434         }
   496         }
   435     /* entries in milliHz */
   497     /* entries in milliHz */
   436     entries->samplingRatesSupported[0] = 8000000;
   498     entries->samplingRatesSupported[0] = 8000000;
   437     entries->samplingRatesSupported[1] = 11025000;
   499     entries->samplingRatesSupported[1] = 16000000;
   438     entries->samplingRatesSupported[2] = 12000000;
   500     entries->samplingRatesSupported[2] = 24000000;
   439     entries->samplingRatesSupported[3] = 16000000;
   501     entries->samplingRatesSupported[3] = 32000000;
   440     entries->samplingRatesSupported[4] = 22050000;
   502     entries->samplingRatesSupported[4] = 48000000;
   441     entries->samplingRatesSupported[5] = 24000000;
       
   442     entries->samplingRatesSupported[6] = 32000000;
       
   443     entries->samplingRatesSupported[7] = 44100000;
       
   444     entries->samplingRatesSupported[8] = 48000000;
       
   445     entries->samplingRatesSupported[9] = 64000000;
       
   446     entries->samplingRatesSupported[10] = 88200000;
       
   447     entries->samplingRatesSupported[11] = 96000000;
       
   448     entries->maxChannels = 2;
   503     entries->maxChannels = 2;
   449 
   504 
   450     newNode->pEntry = (void*) entries;
   505     newNode->pEntry = (void*) entries;
   451 
   506 
   452     *ppNode = newNode;
   507     *ppNode = newNode;
       
   508     DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceMicCapabilities");
       
   509     return res;
       
   510     }
       
   511 
       
   512 /* Add AudioInputDeviceCaps */
       
   513 XAresult XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities(
       
   514         XACapabilities** ppNode)
       
   515     {
       
   516     XAresult res = XA_RESULT_SUCCESS;
       
   517     XACapabilities *newNode = NULL;
       
   518     XAAudioInputDescriptor *entries = NULL;
       
   519     XAchar inpDeviceName[] = "FMRadio Recvr";
       
   520     int strLen = 0;
       
   521 
       
   522     DEBUG_API("->XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   523     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
       
   524     if (!newNode)
       
   525         {
       
   526         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   527         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   528         return XA_RESULT_MEMORY_FAILURE;
       
   529         }
       
   530 
       
   531     newNode->capsType = AUD_I;
       
   532     newNode->xaid = XA_ADAPTID_DEVSOUNDSRC_FMRX;
       
   533     newNode->noOfEntries = 1;
       
   534 
       
   535     /* Allocate array */
       
   536     entries = (XAAudioInputDescriptor*) calloc(1,
       
   537             sizeof(XAAudioInputDescriptor));
       
   538     if (!entries)
       
   539         {
       
   540         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   541         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   542         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   543         return XA_RESULT_MEMORY_FAILURE;
       
   544         }
       
   545 
       
   546     newNode->pEntry = (void*) entries;
       
   547 
       
   548     strLen = strlen((char*) inpDeviceName);
       
   549     entries->deviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
       
   550     if (!entries->deviceName)
       
   551         {
       
   552         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   553         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   554         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   555         return XA_RESULT_MEMORY_FAILURE;
       
   556         }
       
   557 
       
   558     strncpy((char*) entries->deviceName, (char*) inpDeviceName, strLen);
       
   559     entries->deviceName[strLen] = '\0'; /*Null terminate it*/
       
   560     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
       
   561     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
       
   562     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
       
   563     entries->isForTelephony = XA_BOOLEAN_FALSE;
       
   564     entries->minSampleRate = 8000000; /* milliHz */
       
   565     entries->maxSampleRate = 48000000; /* milliHz */
       
   566     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
       
   567     entries->numOfSamplingRatesSupported = 5;
       
   568     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
       
   569             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
       
   570     if (!entries->samplingRatesSupported)
       
   571         {
       
   572         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   573         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   574         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   575         return XA_RESULT_MEMORY_FAILURE;
       
   576         }
       
   577     /* entries in milliHz */
       
   578     entries->samplingRatesSupported[0] = 8000000;
       
   579     entries->samplingRatesSupported[1] = 16000000;
       
   580     entries->samplingRatesSupported[2] = 24000000;
       
   581     entries->samplingRatesSupported[3] = 32000000;
       
   582     entries->samplingRatesSupported[4] = 48000000;
       
   583     entries->maxChannels = 2;
       
   584 
       
   585     newNode->pEntry = (void*) entries;
       
   586 
       
   587     *ppNode = newNode;
       
   588     DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceFMRxCapabilities");
       
   589     return res;
       
   590     }
       
   591 
       
   592 /* Add AudioInputDeviceCaps */
       
   593 XAresult XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities(
       
   594         XACapabilities** ppNode)
       
   595     {
       
   596     XAresult res = XA_RESULT_SUCCESS;
       
   597     XACapabilities *newNode = NULL;
       
   598     XAAudioInputDescriptor *entries = NULL;
       
   599     XAchar inpDeviceName[] = "Call";
       
   600     int strLen = 0;
       
   601 
       
   602     DEBUG_API("->XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
       
   603     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
       
   604     if (!newNode)
       
   605         {
       
   606         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   607         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
       
   608         return XA_RESULT_MEMORY_FAILURE;
       
   609         }
       
   610 
       
   611     newNode->capsType = AUD_I;
       
   612     newNode->xaid = XA_ADAPTID_DEVSOUNDSRC_CALL;
       
   613     newNode->noOfEntries = 1;
       
   614 
       
   615     /* Allocate array */
       
   616     entries = (XAAudioInputDescriptor*) calloc(1,
       
   617             sizeof(XAAudioInputDescriptor));
       
   618     if (!entries)
       
   619         {
       
   620         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   621         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   622         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
       
   623         return XA_RESULT_MEMORY_FAILURE;
       
   624         }
       
   625 
       
   626     newNode->pEntry = (void*) entries;
       
   627 
       
   628     strLen = strlen((char*) inpDeviceName);
       
   629     entries->deviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
       
   630     if (!entries->deviceName)
       
   631         {
       
   632         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   633         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   634         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
       
   635         return XA_RESULT_MEMORY_FAILURE;
       
   636         }
       
   637 
       
   638     strncpy((char*) entries->deviceName, (char*) inpDeviceName, strLen);
       
   639     entries->deviceName[strLen] = '\0'; /*Null terminate it*/
       
   640     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
       
   641     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
       
   642     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
       
   643     entries->isForTelephony = XA_BOOLEAN_FALSE;
       
   644     entries->minSampleRate = 8000000; /* milliHz */
       
   645     entries->maxSampleRate = 48000000; /* milliHz */
       
   646     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
       
   647     entries->numOfSamplingRatesSupported = 5;
       
   648     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
       
   649             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
       
   650     if (!entries->samplingRatesSupported)
       
   651         {
       
   652         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
       
   653         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
       
   654         DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
       
   655         return XA_RESULT_MEMORY_FAILURE;
       
   656         }
       
   657     /* entries in milliHz */
       
   658     entries->samplingRatesSupported[0] = 8000000;
       
   659     entries->samplingRatesSupported[1] = 16000000;
       
   660     entries->samplingRatesSupported[2] = 24000000;
       
   661     entries->samplingRatesSupported[3] = 32000000;
       
   662     entries->samplingRatesSupported[4] = 48000000;
       
   663     entries->maxChannels = 2;
       
   664 
       
   665     newNode->pEntry = (void*) entries;
       
   666 
       
   667     *ppNode = newNode;
       
   668     DEBUG_API("<-XACapabilitiesMgr_GetAudioInputDeviceCallCapabilities");
   453     return res;
   669     return res;
   454     }
   670     }
   455 
   671 
   456 XAresult XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(
   672 XAresult XACapabilitiesMgr_GetAudioOutputDeviceCapabilities(
   457         XACapabilities **ppNode)
   673         XACapabilities **ppNode)
   460     XACapabilities *newNode = NULL;
   676     XACapabilities *newNode = NULL;
   461     XAAudioOutputDescriptor *entries = NULL;
   677     XAAudioOutputDescriptor *entries = NULL;
   462     XAchar outputDeviceName[] = "Default Speaker";
   678     XAchar outputDeviceName[] = "Default Speaker";
   463     int strLen = 0;
   679     int strLen = 0;
   464 
   680 
       
   681     DEBUG_API("->XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
   465     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
   682     newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
   466     if (!newNode)
   683     if (!newNode)
   467         {
   684         {
   468         res = XA_RESULT_MEMORY_FAILURE;
   685         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   469         return res;
   686         DEBUG_API("<-XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
       
   687         return XA_RESULT_MEMORY_FAILURE;
   470         }
   688         }
   471 
   689 
   472     newNode->capsType = AUD_O;
   690     newNode->capsType = AUD_O;
   473     newNode->xaid = 0xAD7E5002;
   691     newNode->xaid = XA_ADAPTID_DEVSOUNDSINK;
   474     newNode->noOfEntries = 1;
   692     newNode->noOfEntries = 1;
   475 
   693 
   476     /* Allocate array */
   694     /* Allocate array */
   477     entries = (XAAudioOutputDescriptor*) calloc(1,
   695     entries = (XAAudioOutputDescriptor*) calloc(1,
   478             sizeof(XAAudioOutputDescriptor));
   696             sizeof(XAAudioOutputDescriptor));
   479     if (!entries)
   697     if (!entries)
   480         {
   698         {
   481         res = XA_RESULT_MEMORY_FAILURE;
   699         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   482         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   700         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   483         return res;
   701         DEBUG_API("<-XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
       
   702         return XA_RESULT_MEMORY_FAILURE;
   484         }
   703         }
   485 
   704 
   486     newNode->pEntry = (void*) entries;
   705     newNode->pEntry = (void*) entries;
   487 
   706 
   488     strLen = strlen((char*) outputDeviceName);
   707     strLen = strlen((char*) outputDeviceName);
   489     entries->pDeviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
   708     entries->pDeviceName = (XAchar *) calloc(strLen + 1, sizeof(XAchar));
   490     if (!entries->pDeviceName)
   709     if (!entries->pDeviceName)
   491         {
   710         {
   492         res = XA_RESULT_MEMORY_FAILURE;
   711         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   493         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   712         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   494         return res;
   713         DEBUG_API("<-XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
       
   714         return XA_RESULT_MEMORY_FAILURE;
   495         }
   715         }
   496     strncpy((char*) entries->pDeviceName, (char*) outputDeviceName, strLen);
   716     strncpy((char*) entries->pDeviceName, (char*) outputDeviceName, strLen);
   497     entries->pDeviceName[strLen] = '\0'; /*Null terminate it*/
   717     entries->pDeviceName[strLen] = '\0'; /*Null terminate it*/
   498     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
   718     entries->deviceConnection = XA_DEVCONNECTION_INTEGRATED;
   499     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
   719     entries->deviceScope = XA_DEVSCOPE_ENVIRONMENT;
   500     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
   720     entries->deviceLocation = XA_DEVLOCATION_HANDSET;
   501     entries->isForTelephony = XA_BOOLEAN_FALSE;
   721     entries->isForTelephony = XA_BOOLEAN_FALSE;
   502     entries->minSampleRate = 8000000; /* milliHz */
   722     entries->minSampleRate = 8000000; /* milliHz */
   503     entries->maxSampleRate = 96000000; /* milliHz */
   723     entries->maxSampleRate = 48000000; /* milliHz */
   504     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
   724     entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
   505     entries->numOfSamplingRatesSupported = 12;
   725     entries->numOfSamplingRatesSupported = 5;
   506     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
   726     entries->samplingRatesSupported = (XAmilliHertz*) calloc(
   507             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
   727             entries->numOfSamplingRatesSupported, sizeof(XAmilliHertz));
   508     if (!entries->samplingRatesSupported)
   728     if (!entries->samplingRatesSupported)
   509         {
   729         {
   510         res = XA_RESULT_MEMORY_FAILURE;
   730         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   511         XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
   731         DEBUG_ERR("XA_RESULT_MEMORY_FAILURE");
   512         return res;
   732         DEBUG_API("<-XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
       
   733         return XA_RESULT_MEMORY_FAILURE;
   513         }
   734         }
   514     /* entries in milliHz */
   735     /* entries in milliHz */
   515     entries->samplingRatesSupported[0] = 8000000;
   736     entries->samplingRatesSupported[0] = 8000000;
   516     entries->samplingRatesSupported[1] = 11025000;
   737     entries->samplingRatesSupported[1] = 16000000;
   517     entries->samplingRatesSupported[2] = 12000000;
   738     entries->samplingRatesSupported[2] = 24000000;
   518     entries->samplingRatesSupported[3] = 16000000;
   739     entries->samplingRatesSupported[3] = 32000000;
   519     entries->samplingRatesSupported[4] = 22050000;
   740     entries->samplingRatesSupported[4] = 48000000;
   520     entries->samplingRatesSupported[5] = 24000000;
       
   521     entries->samplingRatesSupported[6] = 32000000;
       
   522     entries->samplingRatesSupported[7] = 44100000;
       
   523     entries->samplingRatesSupported[8] = 48000000;
       
   524     entries->samplingRatesSupported[9] = 64000000;
       
   525     entries->samplingRatesSupported[10] = 88200000;
       
   526     entries->samplingRatesSupported[11] = 96000000;
       
   527     entries->maxChannels = 2;
   741     entries->maxChannels = 2;
   528 
   742 
   529     newNode->pEntry = (void*) entries;
   743     newNode->pEntry = (void*) entries;
   530 
   744 
   531     *ppNode = newNode;
   745     *ppNode = newNode;
   532     return res;
   746 
   533     }
   747     DEBUG_API("<-XACapabilitiesMgr_GetAudioOutputDeviceCapabilities");
   534 
   748     return res;
       
   749     }