FM Radio sample code | developer.brewmp.com FM Radio sample code | developer.brewmp.com

Developer

FM Radio sample code

Forums:

Hi all,

Is there any sample code related to obtaining a handle to the FM chipset driver and using it to stream FM radio?  The documentation is pretty sparse, so a complete example would be very useful.  As a starting point, I am trying to get the minimum and maximum frequencies in my area via IRadio_GetValidFreqRange(IRadio* pIRadio,int* pnFreqMin,int* pnFreqMax), but I don't see how to obtain a pointer to an IRadio implementation.  The following code snippet from IFMRDS looks promising:

Note: This is just sample usage code only, it is intended to show only how      to use the API'svoid SampleFMRDS_Usage(SampleUsage *me){   int nResult = AEE_SUCCESS;   do {          nResult = ISHELL_CreateInstance(me->pIShell,                                      AEECLSID_FMRadio,                                      (void **)&me->pIFMRadio);      BREAKIF(nResult);      nResult = ISHELL_CreateInstance(me->pIShell,                                      AEECLSID_FMRDS,                                      (void **)&me->pIFMRDS);      BREAKIF(nResult);      CALLBACK_Init(&pMe->tFMRDSSSCb,                    (PFNNOTIFY) SampleUsageFMRDS_SetStationCb,                    (void *)me);      IFMRadio_SetStation(me->pIFMRadio,                           me->nInitialFMStationFrequency,                          &me->nFMRadioResult,                          me->tFMRDSSSCb);       }while(0);   return;}void SampleUsageFMRDS_SetStationCb(void *me){   SampleUsage *pMe = (SampleUsage *)me;   CALLBACK_Init(&pMe->tFMRDSGRDCb,                 (PFNNOTIFY)SampleUsageFMRDS_GetRawDataCb,                 (void *)pMe);   IFMRadio_EnablePlay(pMe->pIFMRadio, TRUE);   //Register call back for RawData.   IFMRDS_InfoReadable(pMe->pIFMRDS,                       &pMe->tFMRDSGRDCb,                       0,                       AEEFMRDS_RAW_DATA);   CALLBACK_Init(&pMe->tFMRDSGGDCb,                  (PFNNOTIFY)SampleUsageFMRDS_GetGroupedDataCb,                  (void *)pMe);    //Register call back for grouped data.    IFMRDS_InfoReadable(pMe->pIFMRDS,                        &pMe->tFMRDSGGDCb,                        AEEFMRDS_INFO_2A,                        AEEFMRDS_RAW_GROUPED_DATA);    CALLBACK_Init(&pMe->tFMRDSGPDCb,                  (PFNNOTIFY)SampleUsageFMRDS_GetParsedDataCb,                  (void *)pMe);        //Register call back for Parsed Data.    IFMRDS_InfoReadable(pMe->pIFMRDS,                        &pMe->tFMRDSGPDCb,                        AEEFMRDS_INFO_2B,                        AEEFMRDS_PARSED_DATA);    return; }void SampleUsageFMRDS_GetGroupedDataCb(void *me){   SampleUsage *pMe = (SampleUsage *)me;   int nBufSize = 0, nBufSizeReq = 0, nSequence = 0;   void *pBuf = NULL;   nResult = IFMRDS_GetInfoData(pMe->pIFMRDS,                                AEEFMRDS_INFO_2A,                                &nSequence,                                NULL,                                0,                                &nBufSizeReq);   if(SUCCESS != nResult){     // Do Error handling   }   pBuf = MALLOC(nBufSizeReq * sizeof(AEEFMRDSGroup));   if(NULL == pBuf){     nResult = ENOMEMORY;     //Do Error handling   }   nBufSize = nBufSizeReq;   nResult = IFMRDS_GetInfoData(pMe->pIFMRDS,                                AEEFMRDS_INFO_2A,                                &nSequence,                                pBuf,                                nBufSize,                                &nBufSizeReq);   if(SUCCESS != nResult){     //Do Error handling   }   //finally release the buffer   FREEEIF(pBuf);   return;}void SampleUsageFMRDS_GetRawDataCb(void *me){  SampleUsage *pMe = (SampleUsage *)me;  int nFMRDSGroupsBufSize = 0, nFMRDSBufSizeReq = 0, nSequence = 0;  void *pFMRDSGroupsBuf = NULL;  nResult = IFMRDS_GetNextData(pIFMRDS,                               &nSequence,                               NULL,                               0,                               &nFMRDSBufSizeReq);  if(SUCCESS != nResult){    // Do Error handling  }  pFMRDSGroupsBuf = MALLOC(nFMRDSBufSizeReq * sizeof(AEEFMRDSGroup));  if(NULL == pFMRDSGroupsBuf){    nResult = ENOMEMORY;    //Do Error handling  }  nFMRDSGroupsBufSize = nFMRDSBufSizeReq;  nResult = IFMRDS_GetNextData(pIFMRDS,                               &nSequence,                               pFMRDSGroupsBuf,                               nFMRDSGroupsBufSize,                               &nFMRDSBufSizeReq);  if(SUCCESS != nResult){    //Do Error handling  }  //fianlly free the buffer  FREEIF(pFMRDSGroupBuf);  return;}static void SampleUsageFMRDS_GetParsedDataCb(void *p){   SampleUsage *pMe = (SampleUsage *) p;   AEEFMRDSParsedInfo *pRDSInfo = NULL;   int nResult = SUCCESS;      pRDSInfo = (AEEFMRDSParsedInfo *)MALLOC(sizeof(AEEFMRDSParsedInfo));   if(NULL == pRDSInfo){      nResult = ENOMEMORY;      return;   }   nResult = IFMRDS_GetParsedData(pMe->pIFMRDS,                                  AEEFMRDS_INFO_2B,                                  pRDSInfo);    if(SUCCESS != nResult){       return;    }    //update UI accordingly    //fianlly free the memory    FREE(pRDSInfo);    return;}

 

What does ISHELL_CreateInstance(...) do exactly?  Is that the function I need to get a handle to the device (an Xperia E)'s FM chipset for tuning etc.?

 

thanks,

Jeff

 

You can get handle of IFMRadio Interface using AEECLSID_FMRadio in the call to ISHELL_CreateInstance().
Then you can interact with FM-Radio
ASIC using the functions of this interface. Some features of IFMRadio are Tune to a station, Scan for strongest channels in a band,Get notifications about signal strength change, Set the fidelity mode for the audio path.
Please see documentation of IFMRadio API interfaces for more details.
 
Similarly handle of IFMRDS can be obtained using CLASSID AEECLSID_FMRDS.
 

You can get handle of IFMRadio Interface using AEECLSID_FMRadio in the call to ISHELL_CreateInstance().
Then you can interact with FM-Radio
ASIC using the functions of this interface. Some features of IFMRadio are Tune to a station, Scan for strongest channels in a band,Get notifications about signal strength change, Set the fidelity mode for the audio path.
Please see documentation of IFMRadio API interfaces for more details.
 
Similarly handle of IFMRDS can be obtained using CLASSID AEECLSID_FMRDS.