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

Generated for OpenMAX Bellagio rel. 0.3.5-svn by  doxygen 1.5.1
SourceForge.net Logo