omx_alsasrc_component.c

Go to the documentation of this file.
00001 
00030 #include <omxcore.h>
00031 #include <omx_base_audio_port.h>
00032 #include <omx_alsasrc_component.h>
00033 
00035 #define MAX_COMPONENT_ALSASRC 1
00036 
00038 static OMX_U32 noAlsasrcInstance=0;
00039 
00042 OMX_ERRORTYPE omx_alsasrc_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,OMX_STRING cComponentName) {
00043   int err;
00044   int omxErr;
00045   omx_base_audio_PortType *pPort;
00046   omx_alsasrc_component_PrivateType* omx_alsasrc_component_Private;
00047   OMX_U32 i;
00048 
00049   if (!openmaxStandComp->pComponentPrivate) {
00050     openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_alsasrc_component_PrivateType));
00051     if(openmaxStandComp->pComponentPrivate==NULL) {
00052       return OMX_ErrorInsufficientResources;
00053     }
00054   }
00055 
00056   omx_alsasrc_component_Private = openmaxStandComp->pComponentPrivate;
00057   omx_alsasrc_component_Private->ports = NULL;
00058   
00059   omxErr = omx_base_source_Constructor(openmaxStandComp,cComponentName);
00060   if (omxErr != OMX_ErrorNone) {
00061     return OMX_ErrorInsufficientResources;
00062   }
00063 
00064   omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nStartPortNumber = 0;
00065   omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts = 1;
00066 
00068   if (omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts && !omx_alsasrc_component_Private->ports) {
00069     omx_alsasrc_component_Private->ports = calloc(omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts, sizeof(omx_base_PortType *));
00070     if (!omx_alsasrc_component_Private->ports) {
00071       return OMX_ErrorInsufficientResources;
00072     }
00073     for (i=0; i < omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
00074       omx_alsasrc_component_Private->ports[i] = calloc(1, sizeof(omx_base_audio_PortType));
00075       if (!omx_alsasrc_component_Private->ports[i]) {
00076         return OMX_ErrorInsufficientResources;
00077       }
00078     }
00079   }
00080 
00081   base_audio_port_Constructor(openmaxStandComp, &omx_alsasrc_component_Private->ports[0], 0, OMX_FALSE);
00082 
00083   pPort = (omx_base_audio_PortType *) omx_alsasrc_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
00084 
00085   // set the pPort params, now that the ports exist  
00087   pPort->sPortParam.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
00088   /*Input pPort buffer size is equal to the size of the output buffer of the previous component*/
00089   pPort->sPortParam.nBufferSize = DEFAULT_OUT_BUFFER_SIZE;
00090 
00091   omx_alsasrc_component_Private->BufferMgmtCallback = omx_alsasrc_component_BufferMgmtCallback;
00092   omx_alsasrc_component_Private->destructor = omx_alsasrc_component_Destructor;
00093 
00094   setHeader(&pPort->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00095   pPort->sAudioParam.nPortIndex = 0;
00096   pPort->sAudioParam.nIndex = 0;
00097   pPort->sAudioParam.eEncoding = OMX_AUDIO_CodingPCM;
00098 
00099   /* OMX_AUDIO_PARAM_PCMMODETYPE */
00100   setHeader(&omx_alsasrc_component_Private->sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00101   omx_alsasrc_component_Private->sPCMModeParam.nPortIndex = 0;
00102   omx_alsasrc_component_Private->sPCMModeParam.nChannels = 2;
00103   omx_alsasrc_component_Private->sPCMModeParam.eNumData = OMX_NumericalDataSigned;
00104   omx_alsasrc_component_Private->sPCMModeParam.eEndian = OMX_EndianLittle;
00105   omx_alsasrc_component_Private->sPCMModeParam.bInterleaved = OMX_TRUE;
00106   omx_alsasrc_component_Private->sPCMModeParam.nBitPerSample = 16;
00107   omx_alsasrc_component_Private->sPCMModeParam.nSamplingRate = 8000;
00108   omx_alsasrc_component_Private->sPCMModeParam.ePCMMode = OMX_AUDIO_PCMModeLinear;
00109   omx_alsasrc_component_Private->sPCMModeParam.eChannelMapping[0] = OMX_AUDIO_ChannelNone;
00110 
00111   noAlsasrcInstance++;
00112   if(noAlsasrcInstance > MAX_COMPONENT_ALSASRC) {
00113     return OMX_ErrorInsufficientResources;
00114   }
00115   
00116   //char *device = "plughw:0,0"; /* default device */
00117   /* Allocate the playback handle and the hardware parameter structure */
00118   if ((err = snd_pcm_open (&omx_alsasrc_component_Private->playback_handle, "default", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
00119     DEBUG(DEB_LEV_ERR, "cannot open audio device %s (%s)\n", "default", snd_strerror (err));
00120     return OMX_ErrorHardware;
00121   }
00122   else
00123     DEBUG(DEB_LEV_SIMPLE_SEQ, "Got playback handle at %08x %08X in %i\n", (int)omx_alsasrc_component_Private->playback_handle, (int)&omx_alsasrc_component_Private->playback_handle, getpid());
00124 
00125   if (snd_pcm_hw_params_malloc(&omx_alsasrc_component_Private->hw_params) < 0) {
00126     DEBUG(DEB_LEV_ERR, "%s: failed allocating input pPort hw parameters\n", __func__);
00127     return OMX_ErrorHardware;
00128   }
00129   else
00130     DEBUG(DEB_LEV_SIMPLE_SEQ, "Got hw parameters at %08x\n", (int)omx_alsasrc_component_Private->hw_params);
00131 
00132   if ((err = snd_pcm_hw_params_any (omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params)) < 0) {
00133     DEBUG(DEB_LEV_ERR, "cannot initialize hardware parameter structure (%s)\n",  snd_strerror (err));
00134     return OMX_ErrorHardware;
00135   }
00136 
00137   openmaxStandComp->SetParameter  = omx_alsasrc_component_SetParameter;
00138   openmaxStandComp->GetParameter  = omx_alsasrc_component_GetParameter;
00139 
00140   /* Write in the default paramenters */
00141   omx_alsasrc_component_Private->AudioPCMConfigured  = 0;
00142 
00143   if (!omx_alsasrc_component_Private->AudioPCMConfigured) {
00144     DEBUG(DEB_LEV_SIMPLE_SEQ, "Configuring the PCM interface in the Init function\n");
00145     omxErr = omx_alsasrc_component_SetParameter(openmaxStandComp, OMX_IndexParamAudioPcm, &omx_alsasrc_component_Private->sPCMModeParam);
00146     if(omxErr != OMX_ErrorNone){
00147       DEBUG(DEB_LEV_ERR, "In %s Error %08x\n",__func__,omxErr);
00148     }
00149   }
00150 
00151   return OMX_ErrorNone;
00152 }
00153 
00156 OMX_ERRORTYPE omx_alsasrc_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp) {
00157   omx_alsasrc_component_PrivateType* omx_alsasrc_component_Private = openmaxStandComp->pComponentPrivate;
00158   OMX_U32 i;
00159 
00160   if(omx_alsasrc_component_Private->hw_params) {
00161     snd_pcm_hw_params_free (omx_alsasrc_component_Private->hw_params);
00162   }
00163   if(omx_alsasrc_component_Private->playback_handle) {
00164     snd_pcm_close(omx_alsasrc_component_Private->playback_handle);
00165   }
00166 
00167   /* frees port/s */
00168   if (omx_alsasrc_component_Private->ports) {
00169     for (i=0; i < omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts; i++) {
00170       if(omx_alsasrc_component_Private->ports[i])
00171         omx_alsasrc_component_Private->ports[i]->PortDestructor(omx_alsasrc_component_Private->ports[i]);
00172     }
00173     free(omx_alsasrc_component_Private->ports);
00174     omx_alsasrc_component_Private->ports=NULL;
00175   }
00176 
00177   noAlsasrcInstance--;
00178 
00179   return omx_base_source_Destructor(openmaxStandComp);
00180 
00181 }
00182 
00186 void omx_alsasrc_component_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE* outputbuffer) {
00187   OMX_U32  frameSize;
00188   OMX_S32 data_read;
00189   omx_alsasrc_component_PrivateType* omx_alsasrc_component_Private = openmaxStandComp->pComponentPrivate;
00190 
00191   /* Feed it to ALSA */
00192   frameSize = (omx_alsasrc_component_Private->sPCMModeParam.nChannels * omx_alsasrc_component_Private->sPCMModeParam.nBitPerSample) >> 3;
00193   DEBUG(DEB_LEV_FULL_SEQ, "Framesize is %u chl=%d bufSize=%d\n", 
00194   (int)frameSize, (int)omx_alsasrc_component_Private->sPCMModeParam.nChannels, (int)outputbuffer->nFilledLen);
00195 
00196   if(outputbuffer->nAllocLen < frameSize){
00197     DEBUG(DEB_LEV_ERR, "Ouch!! In %s input buffer filled len(%d) less than frame size(%d)\n",__func__, (int)outputbuffer->nFilledLen, (int)frameSize);
00198     return;
00199   }
00200 
00201   data_read = snd_pcm_readi(omx_alsasrc_component_Private->playback_handle,outputbuffer->pBuffer,outputbuffer->nAllocLen/frameSize);
00202   if (data_read<0) {
00203     if (data_read !=-EPIPE){
00204       DEBUG(DEB_LEV_ERR,"alsa_card_read 1: snd_pcm_readi() failed:%s.\n",snd_strerror(data_read));
00205     }
00206     snd_pcm_prepare(omx_alsasrc_component_Private->playback_handle);
00207     data_read=snd_pcm_readi(omx_alsasrc_component_Private->playback_handle,outputbuffer->pBuffer,outputbuffer->nAllocLen/frameSize);
00208     if (data_read<0) {
00209       DEBUG(DEB_LEV_ERR,"alsa_card_read 2: snd_pcm_readi() failed:%s.\n",snd_strerror(data_read));
00210       return;
00211     }
00212   }
00213 
00214   outputbuffer->nFilledLen =  data_read*frameSize;
00215 
00216   DEBUG(DEB_LEV_FULL_SEQ, "Data read=%d, framesize=%d, o/b filled len=%d alloclen=%d\n",(int)data_read,(int)frameSize,(int)outputbuffer->nFilledLen,(int)outputbuffer->nAllocLen);
00217 
00218 }
00219 
00220 OMX_ERRORTYPE omx_alsasrc_component_SetParameter(
00221   OMX_IN  OMX_HANDLETYPE hComponent,
00222   OMX_IN  OMX_INDEXTYPE nParamIndex,
00223   OMX_IN  OMX_PTR ComponentParameterStructure)
00224 {
00225   int err;
00226   int omxErr = OMX_ErrorNone;
00227   OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;
00228   OMX_U32 portIndex;
00229 
00230   /* Check which structure we are being fed and make control its header */
00231   OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
00232   omx_alsasrc_component_PrivateType* omx_alsasrc_component_Private = openmaxStandComp->pComponentPrivate;
00233   omx_base_audio_PortType* pPort = (omx_base_audio_PortType *) omx_alsasrc_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
00234   snd_pcm_t* playback_handle = omx_alsasrc_component_Private->playback_handle;
00235   snd_pcm_hw_params_t* hw_params = omx_alsasrc_component_Private->hw_params;
00236 
00237   if (ComponentParameterStructure == NULL) {
00238     return OMX_ErrorBadParameter;
00239   }
00240 
00241   DEBUG(DEB_LEV_SIMPLE_SEQ, "   Setting parameter %i\n", nParamIndex);
00242 
00248   err = snd_pcm_hw_params_any (omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params);
00249 
00250   switch(nParamIndex) {
00251   case OMX_IndexParamAudioPortFormat:
00252     pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00253     portIndex = pAudioPortFormat->nPortIndex;
00254     /*Check Structure Header and verify component state*/
00255     omxErr = omx_base_component_ParameterSanityCheck(hComponent, portIndex, pAudioPortFormat, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00256     if(omxErr!=OMX_ErrorNone) { 
00257       DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, omxErr); 
00258       break;
00259     } 
00260     if (portIndex < 1) {
00261       memcpy(&pPort->sAudioParam,pAudioPortFormat,sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00262     } else {
00263       return OMX_ErrorBadPortIndex;
00264     }
00265     break;
00266   case OMX_IndexParamAudioPcm:
00267     {
00268       unsigned int rate;
00269       OMX_AUDIO_PARAM_PCMMODETYPE* sPCMModeParam = (OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure;
00270 
00271       portIndex = sPCMModeParam->nPortIndex;
00272       /*Check Structure Header and verify component state*/
00273       omxErr = omx_base_component_ParameterSanityCheck(hComponent, portIndex, sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00274       if(omxErr!=OMX_ErrorNone) { 
00275         DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, omxErr); 
00276         break;
00277       } 
00278 
00279       omx_alsasrc_component_Private->AudioPCMConfigured  = 1;
00280       if(sPCMModeParam->nPortIndex != omx_alsasrc_component_Private->sPCMModeParam.nPortIndex){
00281         DEBUG(DEB_LEV_ERR, "Error setting input pPort index\n");
00282         omxErr = OMX_ErrorBadParameter;
00283         break;
00284       }
00285 
00286       DEBUG(DEB_LEV_PARAMS, "Debug: nCh=%d, sRate=%d, bIL=%x,ePCMMode=%x,bps=%d\n",
00287         (int)sPCMModeParam->nChannels,
00288         (int)sPCMModeParam->nSamplingRate,
00289         sPCMModeParam->bInterleaved,
00290         sPCMModeParam->ePCMMode,
00291         (int)sPCMModeParam->nBitPerSample);
00292 
00293       if(snd_pcm_hw_params_set_channels(playback_handle, hw_params, sPCMModeParam->nChannels)){
00294         DEBUG(DEB_LEV_ERR, "Error setting number of channels\n");
00295         return OMX_ErrorBadParameter;
00296       }
00297 
00298       if(sPCMModeParam->bInterleaved == OMX_TRUE){
00299         if ((err = snd_pcm_hw_params_set_access(omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
00300           DEBUG(DEB_LEV_ERR, "cannot set access type intrleaved (%s)\n", snd_strerror (err));
00301           return OMX_ErrorHardware;
00302         }
00303       }
00304       else{
00305         if ((err = snd_pcm_hw_params_set_access(omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params, SND_PCM_ACCESS_RW_NONINTERLEAVED)) < 0) {
00306           DEBUG(DEB_LEV_ERR, "cannot set access type non interleaved (%s)\n", snd_strerror (err));
00307           return OMX_ErrorHardware;
00308         }
00309       }
00310       rate = sPCMModeParam->nSamplingRate;
00311       if ((err = snd_pcm_hw_params_set_rate_near(omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params, &rate, 0)) < 0) {
00312         DEBUG(DEB_LEV_ERR, "cannot set sample rate (%s)\n", snd_strerror (err));
00313         return OMX_ErrorHardware;
00314       }
00315       else{
00316         DEBUG(DEB_LEV_PARAMS, "Set correctly sampling rate to %i\n", (int)omx_alsasrc_component_Private->sPCMModeParam.nSamplingRate);
00317       }
00318 
00319       if(sPCMModeParam->ePCMMode == OMX_AUDIO_PCMModeLinear){
00320         snd_pcm_format_t snd_pcm_format = SND_PCM_FORMAT_UNKNOWN;
00321         DEBUG(DEB_LEV_PARAMS, "Bit per sample %i, signed=%i, little endian=%i\n",
00322         (int)sPCMModeParam->nBitPerSample,
00323         (int)sPCMModeParam->eNumData == OMX_NumericalDataSigned,
00324         (int)sPCMModeParam->eEndian ==  OMX_EndianLittle);
00325 
00326         switch(sPCMModeParam->nBitPerSample){
00327         case 8:
00328           if(sPCMModeParam->eNumData == OMX_NumericalDataSigned) {
00329             snd_pcm_format = SND_PCM_FORMAT_S8;
00330           } else {
00331             snd_pcm_format = SND_PCM_FORMAT_U8;
00332           }
00333           break;
00334         case 16:
00335           if(sPCMModeParam->eNumData == OMX_NumericalDataSigned){
00336             if(sPCMModeParam->eEndian ==  OMX_EndianLittle) {
00337               snd_pcm_format = SND_PCM_FORMAT_S16_LE;
00338             } else {
00339               snd_pcm_format = SND_PCM_FORMAT_S16_BE;
00340             }
00341           }
00342         if(sPCMModeParam->eNumData == OMX_NumericalDataUnsigned){
00343           if(sPCMModeParam->eEndian ==  OMX_EndianLittle){
00344             snd_pcm_format = SND_PCM_FORMAT_U16_LE;
00345           } else {
00346             snd_pcm_format = SND_PCM_FORMAT_U16_BE;
00347           }
00348         }
00349         break;
00350         case 24:
00351           if(sPCMModeParam->eNumData == OMX_NumericalDataSigned){
00352             if(sPCMModeParam->eEndian ==  OMX_EndianLittle) {
00353               snd_pcm_format = SND_PCM_FORMAT_S24_LE;
00354             } else {
00355               snd_pcm_format = SND_PCM_FORMAT_S24_BE;
00356             }
00357           }
00358           if(sPCMModeParam->eNumData == OMX_NumericalDataUnsigned){
00359             if(sPCMModeParam->eEndian ==  OMX_EndianLittle) {
00360               snd_pcm_format = SND_PCM_FORMAT_U24_LE;
00361             } else {
00362               snd_pcm_format = SND_PCM_FORMAT_U24_BE;
00363             }
00364           }
00365           break;
00366 
00367         case 32:
00368           if(sPCMModeParam->eNumData == OMX_NumericalDataSigned){
00369             if(sPCMModeParam->eEndian ==  OMX_EndianLittle) {
00370               snd_pcm_format = SND_PCM_FORMAT_S32_LE;
00371             } else {
00372               snd_pcm_format = SND_PCM_FORMAT_S32_BE;
00373             }
00374           }
00375           if(sPCMModeParam->eNumData == OMX_NumericalDataUnsigned){
00376             if(sPCMModeParam->eEndian ==  OMX_EndianLittle) {
00377               snd_pcm_format = SND_PCM_FORMAT_U32_LE;
00378             } else {
00379               snd_pcm_format = SND_PCM_FORMAT_U32_BE;
00380             }
00381           }
00382           break;
00383         default:
00384           omxErr = OMX_ErrorBadParameter;
00385           break;
00386         }
00387 
00388         if(snd_pcm_format != SND_PCM_FORMAT_UNKNOWN){
00389           if ((err = snd_pcm_hw_params_set_format(playback_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
00390             DEBUG(DEB_LEV_ERR, "cannot set sample format (%s)\n",  snd_strerror (err));
00391             return OMX_ErrorHardware;
00392           }
00393           memcpy(&omx_alsasrc_component_Private->sPCMModeParam, ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00394         } else{
00395           DEBUG(DEB_LEV_SIMPLE_SEQ, "ALSA OMX_IndexParamAudioPcm configured\n");
00396           memcpy(&omx_alsasrc_component_Private->sPCMModeParam, ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00397         }
00398       }
00399       else if(sPCMModeParam->ePCMMode == OMX_AUDIO_PCMModeALaw){
00400         DEBUG(DEB_LEV_SIMPLE_SEQ, "Configuring ALAW format\n\n");
00401         if ((err = snd_pcm_hw_params_set_format(playback_handle, hw_params, SND_PCM_FORMAT_A_LAW)) < 0) {
00402           DEBUG(DEB_LEV_ERR, "cannot set sample format (%s)\n",  snd_strerror (err));
00403           return OMX_ErrorHardware;
00404         }
00405         memcpy(&omx_alsasrc_component_Private->sPCMModeParam, ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00406       }
00407       else if(sPCMModeParam->ePCMMode == OMX_AUDIO_PCMModeMULaw){
00408         DEBUG(DEB_LEV_SIMPLE_SEQ, "Configuring ALAW format\n\n");
00409         if ((err = snd_pcm_hw_params_set_format(playback_handle, hw_params, SND_PCM_FORMAT_MU_LAW)) < 0) {
00410           DEBUG(DEB_LEV_ERR, "cannot set sample format (%s)\n", snd_strerror (err));
00411           return OMX_ErrorHardware;
00412         }
00413         memcpy(&omx_alsasrc_component_Private->sPCMModeParam, ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00414       }
00415 
00417       DEBUG(DEB_LEV_SIMPLE_SEQ, "Configuring the PCM interface\n");
00418       if ((err = snd_pcm_hw_params (omx_alsasrc_component_Private->playback_handle, omx_alsasrc_component_Private->hw_params)) < 0) {
00419         DEBUG(DEB_LEV_ERR, "cannot set parameters (%s)\n",  snd_strerror (err));
00420         return OMX_ErrorHardware;
00421       }
00422 
00423       if ((err = snd_pcm_prepare (omx_alsasrc_component_Private->playback_handle)) < 0) {
00424         DEBUG(DEB_LEV_ERR, "cannot prepare audio interface for use (%s)\n", snd_strerror (err));
00425         return OMX_ErrorHardware;
00426       }
00427     }
00428     break;
00429   default: /*Call the base component function*/
00430     return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00431   }
00432   return omxErr;
00433 }
00434 
00435 OMX_ERRORTYPE omx_alsasrc_component_GetParameter(
00436   OMX_IN  OMX_HANDLETYPE hComponent,
00437   OMX_IN  OMX_INDEXTYPE nParamIndex,
00438   OMX_INOUT OMX_PTR ComponentParameterStructure)
00439 {
00440   OMX_AUDIO_PARAM_PORTFORMATTYPE *pAudioPortFormat;  
00441   OMX_ERRORTYPE err = OMX_ErrorNone;
00442   OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
00443   omx_alsasrc_component_PrivateType* omx_alsasrc_component_Private = openmaxStandComp->pComponentPrivate;
00444   omx_base_audio_PortType *pPort = (omx_base_audio_PortType *) omx_alsasrc_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];  
00445   if (ComponentParameterStructure == NULL) {
00446     return OMX_ErrorBadParameter;
00447   }
00448   DEBUG(DEB_LEV_SIMPLE_SEQ, "   Getting parameter %i\n", nParamIndex);
00449   /* Check which structure we are being fed and fill its header */
00450   switch(nParamIndex) {
00451   case OMX_IndexParamAudioInit:
00452     if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) { 
00453       break;
00454     }
00455     memcpy(ComponentParameterStructure, &omx_alsasrc_component_Private->sPortTypesParam[OMX_PortDomainAudio], sizeof(OMX_PORT_PARAM_TYPE));
00456     break;    
00457   case OMX_IndexParamAudioPortFormat:
00458     pAudioPortFormat = (OMX_AUDIO_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
00459     if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE))) != OMX_ErrorNone) { 
00460       break;
00461     }
00462     if (pAudioPortFormat->nPortIndex < 1) {
00463       memcpy(pAudioPortFormat, &pPort->sAudioParam, sizeof(OMX_AUDIO_PARAM_PORTFORMATTYPE));
00464     } else {
00465       return OMX_ErrorBadPortIndex;
00466     }
00467     break;    
00468   case OMX_IndexParamAudioPcm:
00469     if(((OMX_AUDIO_PARAM_PCMMODETYPE*)ComponentParameterStructure)->nPortIndex !=
00470       omx_alsasrc_component_Private->sPCMModeParam.nPortIndex) {
00471       return OMX_ErrorBadParameter;
00472     }
00473     if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE))) != OMX_ErrorNone) { 
00474       break;
00475     }
00476     memcpy(ComponentParameterStructure, &omx_alsasrc_component_Private->sPCMModeParam, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
00477     break;
00478   default: /*Call the base component function*/
00479   return omx_base_component_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
00480   }
00481   return err;
00482 }

Generated for OpenMAX Bellagio rel. 0.9.0 by  doxygen 1.5.1
SourceForge.net Logo