omx_alsasink_component.c

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

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