OpenMAX Bellagio 0.9.3
omx_clocksrc_component.c
Go to the documentation of this file.
1
27#include <omxcore.h>
28#include <omx_base_clock_port.h>
30#include <config.h>
31#include <unistd.h>
32
36 int omxErr;
37 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private;
38 OMX_U32 i;
39
41
42 if (!openmaxStandComp->pComponentPrivate) {
43 openmaxStandComp->pComponentPrivate = calloc(1, sizeof(omx_clocksrc_component_PrivateType));
44 if(openmaxStandComp->pComponentPrivate==NULL) {
46 }
47 }
48
49 omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate;
50 omx_clocksrc_component_Private->ports = NULL;
51
52 omxErr = omx_base_source_Constructor(openmaxStandComp,cComponentName);
53 if (omxErr != OMX_ErrorNone) {
55 }
56
57 omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nStartPortNumber = 0;
58 omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts = 3;
59
61 if (omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts && !omx_clocksrc_component_Private->ports) {
62 omx_clocksrc_component_Private->ports = calloc(omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts, sizeof(omx_base_PortType *));
63 if (!omx_clocksrc_component_Private->ports) {
65 }
66 for (i=0; i < omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts; i++) {
67 omx_clocksrc_component_Private->ports[i] = calloc(1, sizeof(omx_base_clock_PortType));
68 if (!omx_clocksrc_component_Private->ports[i]) {
70 }
71 base_clock_port_Constructor(openmaxStandComp, &omx_clocksrc_component_Private->ports[i], i, OMX_FALSE);
72 omx_clocksrc_component_Private->ports[i]->FlushProcessingBuffers = clocksrc_port_FlushProcessingBuffers;
73 }
74 }
75
76
77 /* initializing the OMX_TIME_CONFIG_CLOCKSTATETYPE */
78 setHeader(&omx_clocksrc_component_Private->sClockState, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE));
79 omx_clocksrc_component_Private->sClockState.eState = OMX_TIME_ClockStateStopped;
80 omx_clocksrc_component_Private->sClockState.nStartTime = 0;
81 omx_clocksrc_component_Private->sClockState.nOffset = 0;
82 omx_clocksrc_component_Private->sClockState.nWaitMask = 0xFF;
83
84 setHeader(&omx_clocksrc_component_Private->sMinStartTime, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
85 omx_clocksrc_component_Private->sMinStartTime.nTimestamp = 0;
86 omx_clocksrc_component_Private->sMinStartTime.nPortIndex = 0;
87
88 setHeader(&omx_clocksrc_component_Private->sConfigScale, sizeof(OMX_TIME_CONFIG_SCALETYPE));
89 omx_clocksrc_component_Private->sConfigScale.xScale = 1<<16; /* normal play mode */
90
91 setHeader(&omx_clocksrc_component_Private->sRefClock, sizeof(OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE));
92 omx_clocksrc_component_Private->sRefClock.eClock = OMX_TIME_RefClockNone;
93 omx_clocksrc_component_Private->eUpdateType = OMX_TIME_UpdateMax;
94
95 if(!omx_clocksrc_component_Private->clockEventSem) {
96 omx_clocksrc_component_Private->clockEventSem = calloc(1,sizeof(tsem_t));
97 tsem_init(omx_clocksrc_component_Private->clockEventSem, 0);
98 }
99
100 if(!omx_clocksrc_component_Private->clockEventCompleteSem) {
101 omx_clocksrc_component_Private->clockEventCompleteSem = calloc(1,sizeof(tsem_t));
102 tsem_init(omx_clocksrc_component_Private->clockEventCompleteSem, 0);
103 }
104
105 omx_clocksrc_component_Private->BufferMgmtCallback = omx_clocksrc_component_BufferMgmtCallback;
106 omx_clocksrc_component_Private->destructor = omx_clocksrc_component_Destructor;
107 omx_clocksrc_component_Private->BufferMgmtFunction = omx_clocksrc_BufferMgmtFunction;
108
111
115
116 return OMX_ErrorNone;
117}
118
122 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate;
123 OMX_U32 i;
124
125 omx_clocksrc_component_Private->sClockState.eState = OMX_TIME_ClockStateMax;
126
127 /*Deinitialize and free message semaphore*/
128 if(omx_clocksrc_component_Private->clockEventSem) {
129 tsem_deinit(omx_clocksrc_component_Private->clockEventSem);
130 free(omx_clocksrc_component_Private->clockEventSem);
131 omx_clocksrc_component_Private->clockEventSem=NULL;
132 }
133 if(omx_clocksrc_component_Private->clockEventCompleteSem) {
134 tsem_deinit(omx_clocksrc_component_Private->clockEventCompleteSem);
135 free(omx_clocksrc_component_Private->clockEventCompleteSem);
136 omx_clocksrc_component_Private->clockEventCompleteSem=NULL;
137 }
138
139 /* frees port/s */
140 if (omx_clocksrc_component_Private->ports) {
141 for (i=0; i < omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts; i++) {
142 if(omx_clocksrc_component_Private->ports[i])
143 omx_clocksrc_component_Private->ports[i]->PortDestructor(omx_clocksrc_component_Private->ports[i]);
144 }
145 free(omx_clocksrc_component_Private->ports);
146 omx_clocksrc_component_Private->ports=NULL;
147 }
148
149 return omx_base_source_Destructor(openmaxStandComp);
150}
151
153 OMX_HANDLETYPE hComponent,
154 OMX_INDEXTYPE nParamIndex,
155 OMX_PTR ComponentParameterStructure)
156{
158 OMX_OTHER_PARAM_PORTFORMATTYPE *pOtherPortFormat;
159 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
160 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate;
161 omx_base_clock_PortType* pPort; // = (omx_base_clock_PortType *) omx_clocksrc_component_Private->ports[OMX_BASE_SOURCE_OUTPUTPORT_INDEX];
162 OMX_PARAM_COMPONENTROLETYPE *pComponentRole;
163
164 if (ComponentParameterStructure == NULL) {
166 }
167 DEBUG(DEB_LEV_SIMPLE_SEQ, " Getting parameter %i\n", nParamIndex);
168 /* Check which structure we are being fed and fill its header */
169 switch(nParamIndex) {
171 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
172 break;
173 }
174 memcpy(ComponentParameterStructure, &omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther], sizeof(OMX_PORT_PARAM_TYPE));
175 break;
177 pOtherPortFormat = (OMX_OTHER_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
178 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE))) != OMX_ErrorNone) {
179 break;
180 }
181 if (pOtherPortFormat->nPortIndex < omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) {
182 pPort = (omx_base_clock_PortType *) omx_clocksrc_component_Private->ports[pOtherPortFormat->nPortIndex];
183 memcpy(pOtherPortFormat, &pPort->sOtherParam, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
184 } else {
186 }
187 break;
189 pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
190 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) {
191 break;
192 }
193 strcpy( (char*) pComponentRole->cRole, "");
194 break;
195 default: /*Call the base component function*/
196 return omx_base_component_GetParameter(hComponent, nParamIndex, ComponentParameterStructure);
197 }
198 return err;
199}
200
202 OMX_HANDLETYPE hComponent,
203 OMX_INDEXTYPE nParamIndex,
204 OMX_PTR ComponentParameterStructure)
205{
207 OMX_OTHER_PARAM_PORTFORMATTYPE *pOtherPortFormat;
208 OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE*)hComponent;
209 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate;
211 OMX_PARAM_COMPONENTROLETYPE *pComponentRole;
212
213 if (ComponentParameterStructure == NULL) {
215 }
216
217 DEBUG(DEB_LEV_SIMPLE_SEQ, " Setting parameter %i\n", nParamIndex);
218 /* Check which structure we are being fed and fill its header */
219 switch(nParamIndex) {
221 pOtherPortFormat = (OMX_OTHER_PARAM_PORTFORMATTYPE*)ComponentParameterStructure;
222 /*Check Structure Header and verify component state*/
223 err = omx_base_component_ParameterSanityCheck(hComponent, pOtherPortFormat->nPortIndex, pOtherPortFormat, sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
224 if(err!=OMX_ErrorNone) {
225 DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n", __func__, err);
226 break;
227 }
228 if (pOtherPortFormat->nPortIndex < omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) {
229 pPort = (omx_base_clock_PortType *) omx_clocksrc_component_Private->ports[pOtherPortFormat->nPortIndex];
230 memcpy(&pPort->sOtherParam,pOtherPortFormat,sizeof(OMX_OTHER_PARAM_PORTFORMATTYPE));
231 } else {
233 }
234 break;
236 pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)ComponentParameterStructure;
237
238 if (omx_clocksrc_component_Private->state != OMX_StateLoaded && omx_clocksrc_component_Private->state != OMX_StateWaitForResources) {
239 DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__, omx_clocksrc_component_Private->state, __LINE__);
241 }
242
243 if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_COMPONENTROLETYPE))) != OMX_ErrorNone) {
244 break;
245 }
246
247 if (strcmp( (char*) pComponentRole->cRole, "")) {
249 }
250 break;
251 default: /*Call the base component function*/
252 return omx_base_component_SetParameter(hComponent, nParamIndex, ComponentParameterStructure);
253 }
254 return err;
255}
256
258 OMX_HANDLETYPE hComponent,
259 OMX_COMMANDTYPE Cmd,
260 OMX_U32 nParam,
261 OMX_PTR pCmdData) {
262 OMX_COMPONENTTYPE* omxComponent = (OMX_COMPONENTTYPE*)hComponent;
263 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = (omx_clocksrc_component_PrivateType*)omxComponent->pComponentPrivate;
264 OMX_U32 nMask;
265
266 switch (Cmd) {
268 if (nParam >= omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts && nParam != OMX_ALL) {
270 }
271 if(nParam == OMX_ALL) {
272 nMask = 0xFF;
273 } else {
274 nMask = 0x1 << nParam;
275 }
276 omx_clocksrc_component_Private->sClockState.nWaitMask &= (~nMask);
277 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s nWaitMask =%08x Musk=%x\n",__func__,
278 (int)omx_clocksrc_component_Private->sClockState.nWaitMask,(int)(~nMask));
279
280 break;
282 if (nParam >= omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts && nParam != OMX_ALL) {
284 }
285 if(nParam == OMX_ALL) {
286 nMask = 0xFF;
287 } else {
288 nMask = 0x1 << nParam;
289 }
290 omx_clocksrc_component_Private->sClockState.nWaitMask &= nMask;
291 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s nWaitMask =%08x Musk=%x\n",__func__,
292 (int)omx_clocksrc_component_Private->sClockState.nWaitMask,(int)nMask);
293 break;
295 if ((nParam == OMX_StateLoaded) && (omx_clocksrc_component_Private->state == OMX_StateIdle)) {
296 omx_clocksrc_component_Private->transientState = OMX_TransStateIdleToLoaded;
297 /*Signal buffer management thread to exit*/
298 tsem_up(omx_clocksrc_component_Private->clockEventSem);
299 } else if ((nParam == OMX_StateExecuting) && (omx_clocksrc_component_Private->state == OMX_StatePause)) {
300 /*Dummy signal to the clock buffer management function*/
301 omx_clocksrc_component_Private->transientState = OMX_TransStatePauseToExecuting;
302 tsem_up(omx_clocksrc_component_Private->clockEventSem);
303 } else if (nParam == OMX_StateInvalid) {
304 omx_clocksrc_component_Private->transientState = OMX_TransStateInvalid;
305 /*Signal buffer management thread to exit*/
306 tsem_up(omx_clocksrc_component_Private->clockEventSem);
307 }
308 break;
309 default:
310 break;
311 }
312
313 DEBUG(DEB_LEV_SIMPLE_SEQ,"In %s calling omx_base_component_SendCommand\n",__func__);
314
315 return omx_base_component_SendCommand(hComponent,Cmd,nParam,pCmdData);
316}
317
319 OMX_HANDLETYPE hComponent,
320 OMX_INDEXTYPE nIndex,
321 OMX_PTR pComponentConfigStructure) {
322
323 OMX_COMPONENTTYPE* omxComponent = (OMX_COMPONENTTYPE*)hComponent;
324 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = (omx_clocksrc_component_PrivateType*)omxComponent->pComponentPrivate;
327 OMX_TIME_CONFIG_SCALETYPE *pConfigScale;
329 struct timeval tv;
330 struct timezone zv;
331
332 switch (nIndex) {
334 clockstate = (OMX_TIME_CONFIG_CLOCKSTATETYPE*) pComponentConfigStructure;
335 memcpy(clockstate, &omx_clocksrc_component_Private->sClockState, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE));
336 break;
338 timestamp = (OMX_TIME_CONFIG_TIMESTAMPTYPE*) pComponentConfigStructure;
339 gettimeofday(&tv,&zv);
340 timestamp->nTimestamp = (tv.tv_sec)*1000+tv.tv_usec; // converting the time read from gettimeofday into microseconds
341 DEBUG(DEB_LEV_SIMPLE_SEQ,"wall time obtained in %s =%x\n",__func__,(int)timestamp->nTimestamp);
342 break;
344 DEBUG(DEB_LEV_SIMPLE_SEQ," TBD portindex to be returned is OMX_ALL, OMX_IndexConfigTimeCurrentMediaTime in %s \n",__func__);
345 break;
347 pConfigScale = (OMX_TIME_CONFIG_SCALETYPE*) pComponentConfigStructure;
348 memcpy(pConfigScale, &omx_clocksrc_component_Private->sConfigScale, sizeof(OMX_TIME_CONFIG_SCALETYPE));
349 break;
351 pRefClock = (OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE*) pComponentConfigStructure;
352 memcpy(pRefClock,&omx_clocksrc_component_Private->sRefClock, sizeof(OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE));
353 break;
354 default:
356 break;
357 }
358 return OMX_ErrorNone;
359}
360
362 OMX_HANDLETYPE hComponent,
363 OMX_INDEXTYPE nIndex,
364 OMX_PTR pComponentConfigStructure) {
365
366 OMX_COMPONENTTYPE* omxComponent = (OMX_COMPONENTTYPE*)hComponent;
367 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = (omx_clocksrc_component_PrivateType*)omxComponent->pComponentPrivate;
369 OMX_TIME_CONFIG_TIMESTAMPTYPE* sRefTimeStamp;
371 OMX_U32 portIndex;
373 OMX_TIME_CONFIG_SCALETYPE *pConfigScale;
374 OMX_U32 nMask;
375 OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE* sMediaTimeRequest;
376 int i;
377 struct timeval tv;
378 struct timezone zv;
379 OMX_TICKS walltime, mediatime, mediaTimediff, wallTimediff;
380 OMX_S32 Scale;
381 unsigned int sleeptime;
382
383 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
384
385 switch (nIndex) {
387 clockstate = (OMX_TIME_CONFIG_CLOCKSTATETYPE*) pComponentConfigStructure;
388 switch (clockstate->eState) {
390 if(omx_clocksrc_component_Private->sClockState.eState == OMX_TIME_ClockStateRunning) {
391 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Received OMX_TIME_ClockStateRunning again\n",__func__);
392 }
393 DEBUG(DEB_LEV_SIMPLE_SEQ,"in %s ...set to OMX_TIME_ClockStateRunning\n",__func__);
394 memcpy(&omx_clocksrc_component_Private->sClockState, clockstate, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE));
395 omx_clocksrc_component_Private->eUpdateType = OMX_TIME_UpdateClockStateChanged;
396 /* update the state change in all port */
397 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
398 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[i];
399 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateClockStateChanged;
400 pPort->sMediaTime.eState = OMX_TIME_ClockStateRunning;
401 pPort->sMediaTime.xScale = omx_clocksrc_component_Private->sConfigScale.xScale;
402 }
403 /*Signal Buffer Management Thread*/
404 tsem_up(omx_clocksrc_component_Private->clockEventSem);
405 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for Clock Running Event for all ports\n");
406 tsem_down(omx_clocksrc_component_Private->clockEventCompleteSem);
407 break;
409 if(omx_clocksrc_component_Private->sClockState.eState == OMX_TIME_ClockStateRunning) {
411 } else if(omx_clocksrc_component_Private->sClockState.eState == OMX_TIME_ClockStateWaitingForStartTime) {
412 return OMX_ErrorSameState;
413 }
414 DEBUG(DEB_LEV_SIMPLE_SEQ," in %s ...set to OMX_TIME_ClockStateWaitingForStartTime mask sent=%d\n",__func__,(int)clockstate->nWaitMask);
415 memcpy(&omx_clocksrc_component_Private->sClockState, clockstate, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE));
416 break;
418 DEBUG(DEB_LEV_SIMPLE_SEQ," in %s ...set to OMX_TIME_ClockStateStopped\n",__func__);
419 memcpy(&omx_clocksrc_component_Private->sClockState, clockstate, sizeof(OMX_TIME_CONFIG_CLOCKSTATETYPE));
420 omx_clocksrc_component_Private->eUpdateType = OMX_TIME_UpdateClockStateChanged;
421 /* update the state change in all port */
422 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
423 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[i];
424 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateClockStateChanged;
425 pPort->sMediaTime.eState = OMX_TIME_ClockStateStopped;
426 pPort->sMediaTime.xScale = omx_clocksrc_component_Private->sConfigScale.xScale;
427 }
428 /*Signal Buffer Management Thread*/
429 tsem_up(omx_clocksrc_component_Private->clockEventSem);
430 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for Clock Stop Event for all ports\n");
431 tsem_down(omx_clocksrc_component_Private->clockEventCompleteSem);
432 break;
433 default:
434 break;
435 }
436 }
437 break;
439 sRefTimeStamp = (OMX_TIME_CONFIG_TIMESTAMPTYPE*) pComponentConfigStructure;
440 portIndex = sRefTimeStamp->nPortIndex;
441 if(portIndex > omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) {
443 }
444
445 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[portIndex];
446 if(!PORT_IS_ENABLED(pPort)) {
447 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Port is disabled \n",__func__);
449 }
450 memcpy(&pPort->sTimeStamp, sRefTimeStamp, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
451
452 /* update the nWaitMask to clear the flag for the client which has sent its start time */
453 if(omx_clocksrc_component_Private->sClockState.nWaitMask) {
454 DEBUG(DEB_LEV_SIMPLE_SEQ,"refTime set is =%x \n",(int)pPort->sTimeStamp.nTimestamp);
455 nMask = ~(0x1 << portIndex);
456 omx_clocksrc_component_Private->sClockState.nWaitMask = omx_clocksrc_component_Private->sClockState.nWaitMask & nMask;
457 if(omx_clocksrc_component_Private->sMinStartTime.nTimestamp >= pPort->sTimeStamp.nTimestamp){
458 omx_clocksrc_component_Private->sMinStartTime.nTimestamp = pPort->sTimeStamp.nTimestamp;
459 omx_clocksrc_component_Private->sMinStartTime.nPortIndex = pPort->sTimeStamp.nPortIndex;
460 }
461 }
462 if(!omx_clocksrc_component_Private->sClockState.nWaitMask &&
463 omx_clocksrc_component_Private->sClockState.eState == OMX_TIME_ClockStateWaitingForStartTime) {
464 omx_clocksrc_component_Private->sClockState.eState = OMX_TIME_ClockStateRunning;
465 omx_clocksrc_component_Private->sClockState.nStartTime = omx_clocksrc_component_Private->sMinStartTime.nTimestamp;
466 omx_clocksrc_component_Private->MediaTimeBase = omx_clocksrc_component_Private->sMinStartTime.nTimestamp;
467 gettimeofday(&tv,&zv);
468 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
469 omx_clocksrc_component_Private->WallTimeBase = walltime;
470 DEBUG(DEB_LEV_SIMPLE_SEQ,"Mediatimebase=%llx walltimebase=%llx \n",omx_clocksrc_component_Private->MediaTimeBase,omx_clocksrc_component_Private->WallTimeBase);
471 omx_clocksrc_component_Private->eUpdateType = OMX_TIME_UpdateClockStateChanged;
472 /* update the state change in all port */
473 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
474 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[i];
475 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateClockStateChanged;
476 pPort->sMediaTime.eState = OMX_TIME_ClockStateRunning;
477 pPort->sMediaTime.xScale = omx_clocksrc_component_Private->sConfigScale.xScale;
478 }
479 /*Signal Buffer Management Thread*/
480 tsem_up(omx_clocksrc_component_Private->clockEventSem);
481 DEBUG(DEB_LEV_SIMPLE_SEQ,"setting the state to running from %s \n",__func__);
482 DEBUG(DEB_LEV_SIMPLE_SEQ,"Waiting for Clock Running Event for all ports in case OMX_IndexConfigTimeClientStartTime\n");
483 tsem_down(omx_clocksrc_component_Private->clockEventCompleteSem);
484 }
485 break;
486
488 pRefClock = (OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE*) pComponentConfigStructure;
489 memcpy(&omx_clocksrc_component_Private->sRefClock, pRefClock, sizeof(OMX_TIME_CONFIG_ACTIVEREFCLOCKTYPE));
490 break;
491
493 sRefTimeStamp = (OMX_TIME_CONFIG_TIMESTAMPTYPE*) pComponentConfigStructure;
494 portIndex = sRefTimeStamp->nPortIndex;
495 if(portIndex > omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) {
497 }
498 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[portIndex];
499 memcpy(&pPort->sTimeStamp, sRefTimeStamp, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
500 gettimeofday(&tv,&zv);
501 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
502 omx_clocksrc_component_Private->WallTimeBase = walltime;
503 omx_clocksrc_component_Private->MediaTimeBase = sRefTimeStamp->nTimestamp; /* set the mediatime base of the received time stamp*/
504 break;
505
507 sRefTimeStamp = (OMX_TIME_CONFIG_TIMESTAMPTYPE*) pComponentConfigStructure;
508 portIndex = sRefTimeStamp->nPortIndex;
509 if(portIndex > omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) {
511 }
512 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[portIndex];
513 memcpy(&pPort->sTimeStamp, sRefTimeStamp, sizeof(OMX_TIME_CONFIG_TIMESTAMPTYPE));
514 gettimeofday(&tv,&zv);
515 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
516 omx_clocksrc_component_Private->WallTimeBase = walltime;
517 omx_clocksrc_component_Private->MediaTimeBase = sRefTimeStamp->nTimestamp; /* set the mediatime base of the received time stamp*/
518 break;
519
521 /* update the mediatime base and walltime base using the current scale value*/
522 Scale = omx_clocksrc_component_Private->sConfigScale.xScale >> 16; //* the scale currently in use, right shifted as Q16 format is used for the scale
523 gettimeofday(&tv,&zv);
524 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
525 mediatime = omx_clocksrc_component_Private->MediaTimeBase + Scale*(walltime - omx_clocksrc_component_Private->WallTimeBase);
526 omx_clocksrc_component_Private->WallTimeBase = walltime; // suitable start time to be used here
527 omx_clocksrc_component_Private->MediaTimeBase = mediatime; // TODO - needs to be checked
528
529 /* update the new scale value */
530 pConfigScale = (OMX_TIME_CONFIG_SCALETYPE*) pComponentConfigStructure;
531 memcpy( &omx_clocksrc_component_Private->sConfigScale,pConfigScale, sizeof(OMX_TIME_CONFIG_SCALETYPE));
532 omx_clocksrc_component_Private->eUpdateType = OMX_TIME_UpdateScaleChanged;
533 /* update the scale change in all ports */
534 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
535 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[i];
536 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateScaleChanged;
537 pPort->sMediaTime.eState = OMX_TIME_ClockStateRunning;
538 pPort->sMediaTime.xScale = omx_clocksrc_component_Private->sConfigScale.xScale;
539 pPort->sMediaTime.nMediaTimestamp = omx_clocksrc_component_Private->MediaTimeBase;
540 pPort->sMediaTime.nWallTimeAtMediaTime = omx_clocksrc_component_Private->WallTimeBase;
541 }
542 /*Signal Buffer Management Thread*/
543 tsem_up(omx_clocksrc_component_Private->clockEventSem);
544 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for Scale Change Event for all ports\n");
545 tsem_down(omx_clocksrc_component_Private->clockEventCompleteSem);
546 break;
547
549 Scale = omx_clocksrc_component_Private->sConfigScale.xScale >> 16;
550
551 if(omx_clocksrc_component_Private->sClockState.eState != OMX_TIME_ClockStateStopped && Scale != 0) {//TODO- what happens if request comes in pause mode
552
553 sMediaTimeRequest = (OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE*) pComponentConfigStructure;
554 portIndex = sMediaTimeRequest->nPortIndex;
555 pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[portIndex];
556 memcpy(&pPort->sMediaTimeRequest, sMediaTimeRequest, sizeof(OMX_TIME_CONFIG_MEDIATIMEREQUESTTYPE));
557
558 gettimeofday(&tv,&zv);
559 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
560 mediatime = omx_clocksrc_component_Private->MediaTimeBase + Scale*(walltime - omx_clocksrc_component_Private->WallTimeBase);
561 int thresh=2000; // TODO - what is a good threshold to use
562 mediaTimediff = (sMediaTimeRequest->nMediaTimestamp - (sMediaTimeRequest->nOffset*Scale)) - mediatime;
563 DEBUG(DEB_LEV_SIMPLE_SEQ," pI=%d MTD=%lld MT=%lld RT=%lld offset=%lld, Scale=%d\n",
564 (int)portIndex,mediaTimediff,mediatime,sMediaTimeRequest->nMediaTimestamp,sMediaTimeRequest->nOffset,(int)Scale);
565 if((mediaTimediff<0 && Scale>0) || (mediaTimediff>0 && Scale<0)) { /* if mediatime has already elapsed then request can not be fullfilled */
566 DEBUG(DEB_LEV_SIMPLE_SEQ," pI=%d RNF MTD<0 MB=%lld WB=%lld MT=%lld RT=%lld WT=%lld offset=%lld, Scale=%d\n",
567 (int)portIndex,omx_clocksrc_component_Private->MediaTimeBase,omx_clocksrc_component_Private->WallTimeBase,
568 mediatime,sMediaTimeRequest->nMediaTimestamp,walltime,sMediaTimeRequest->nOffset,(int)Scale);
569 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateRequestFulfillment; // TODO : to be checked
570 pPort->sMediaTime.nMediaTimestamp = sMediaTimeRequest->nMediaTimestamp;
571 pPort->sMediaTime.nOffset = 0xFFFFFFFF;
572 }else{
573 wallTimediff = mediaTimediff/Scale;
574 if(mediaTimediff){
575 if(wallTimediff>thresh) {
576 sleeptime = (unsigned int) (wallTimediff-thresh);
577 usleep(sleeptime);
578 wallTimediff = thresh; // ask : can I use this as the new walltimediff
579 gettimeofday(&tv,&zv);
580 walltime = ((OMX_TICKS)tv.tv_sec)*1000000 + ((OMX_TICKS)tv.tv_usec);
581 mediatime = omx_clocksrc_component_Private->MediaTimeBase + Scale*(walltime - omx_clocksrc_component_Private->WallTimeBase);
582 }
583 //pPort->sMediaTime.nMediaTimestamp = mediatime;
584 pPort->sMediaTime.nMediaTimestamp = sMediaTimeRequest->nMediaTimestamp;
585 pPort->sMediaTime.nWallTimeAtMediaTime = walltime + wallTimediff; //??????
586 pPort->sMediaTime.nOffset = wallTimediff; //????
587 pPort->sMediaTime.xScale = Scale;
588 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateRequestFulfillment;
589 DEBUG(DEB_LEV_SIMPLE_SEQ,"pI=%d MB=%lld WB=%lld MT=%lld RT=%lld WT=%lld \n",(int)portIndex,
590 omx_clocksrc_component_Private->MediaTimeBase,omx_clocksrc_component_Private->WallTimeBase, mediatime,sMediaTimeRequest->nMediaTimestamp,walltime);
591 }
592 }
593 /*Signal Buffer Management Thread*/
594 tsem_up(omx_clocksrc_component_Private->clockEventSem);
595 DEBUG(DEB_LEV_SIMPLE_SEQ, "Waiting for Scale Change Event for all ports\n");
596 tsem_down(omx_clocksrc_component_Private->clockEventCompleteSem);
597 } else {
598 DEBUG(DEB_LEV_ERR,"In %s Clock State=%x Scale=%x Line=%d \n",
599 __func__,(int)omx_clocksrc_component_Private->sClockState.eState,(int)Scale,__LINE__);
600 }
601 break;
602
603 default:
605 break;
606 }
607 return OMX_ErrorNone;
608}
609
614 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = openmaxStandComp->pComponentPrivate;
615 omx_base_clock_PortType *pPort = (omx_base_clock_PortType*)omx_clocksrc_component_Private->ports[outputbuffer->nOutputPortIndex];
616
617 memcpy(outputbuffer->pBuffer,&pPort->sMediaTime,sizeof(OMX_TIME_MEDIATIMETYPE));
618 outputbuffer->nFilledLen = sizeof(OMX_TIME_MEDIATIMETYPE);
619 pPort->sMediaTime.eUpdateType = OMX_TIME_UpdateMax; /* clear the update type */
620
621}
629 OMX_COMPONENTTYPE* openmaxStandComp = (OMX_COMPONENTTYPE*)param;
630 omx_base_component_PrivateType* omx_base_component_Private=(omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
631 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private = (omx_clocksrc_component_PrivateType*)omx_base_component_Private;
633 tsem_t* pOutputSem[MAX_CLOCK_PORTS];
634 queue_t* pOutputQueue[MAX_CLOCK_PORTS];
636 OMX_BOOL isOutputBufferNeeded[MAX_CLOCK_PORTS],bPortsBeingFlushed = OMX_FALSE;
637 int i,j,outBufExchanged[MAX_CLOCK_PORTS];
638
639 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
640 pOutPort[i] = (omx_base_clock_PortType *)omx_clocksrc_component_Private->ports[i];
641 pOutputSem[i] = pOutPort[i]->pBufferSem;
642 pOutputQueue[i] = pOutPort[i]->pBufferQueue;
643 pOutputBuffer[i] = NULL;
644 isOutputBufferNeeded[i] = OMX_TRUE;
645 outBufExchanged[i] = 0;
646 }
647
648 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
649 while(omx_clocksrc_component_Private->state == OMX_StateIdle
650 || omx_clocksrc_component_Private->state == OMX_StateExecuting
651 || omx_clocksrc_component_Private->state == OMX_StatePause
652 || omx_clocksrc_component_Private->transientState == OMX_TransStateLoadedToIdle){
653
654 /*Wait till the ports are being flushed*/
655 pthread_mutex_lock(&omx_clocksrc_component_Private->flush_mutex);
656 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
657 bPortsBeingFlushed |= PORT_IS_BEING_FLUSHED(pOutPort[i]);
658 }
659 while(bPortsBeingFlushed) {
660 pthread_mutex_unlock(&omx_clocksrc_component_Private->flush_mutex);
661 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
662 if(isOutputBufferNeeded[i]==OMX_FALSE && PORT_IS_BEING_FLUSHED(pOutPort[i])) {
663 pOutPort[i]->ReturnBufferFunction((omx_base_PortType*)pOutPort[i],pOutputBuffer[i]);
664 outBufExchanged[i]--;
665 pOutputBuffer[1]=NULL;
666 isOutputBufferNeeded[i]=OMX_TRUE;
667 DEBUG(DEB_LEV_FULL_SEQ, "Ports are flushing,so returning output buffer for port %i\n",i);
668 }
669 }
670
671 tsem_up(omx_clocksrc_component_Private->flush_all_condition);
672 tsem_down(omx_clocksrc_component_Private->flush_condition);
673 pthread_mutex_lock(&omx_clocksrc_component_Private->flush_mutex);
674
675 bPortsBeingFlushed = OMX_FALSE;
676 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
677 bPortsBeingFlushed |= PORT_IS_BEING_FLUSHED(pOutPort[i]);
678 }
679 }
680 pthread_mutex_unlock(&omx_clocksrc_component_Private->flush_mutex);
681
682 /*Wait for clock state event*/
683 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Waiting for clock event\n",__func__);
684 tsem_down(omx_clocksrc_component_Private->clockEventSem);
685 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s clock event occured semval=%d \n",__func__,omx_clocksrc_component_Private->clockEventSem->semval);
686
687 /*If port is not tunneled then simply return the buffer except paused state*/
688 if(omx_clocksrc_component_Private->transientState == OMX_TransStatePauseToExecuting) {
689 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
690 if(!PORT_IS_TUNNELED(pOutPort[i])) {
691
692 if(pOutputSem[i]->semval>0 && isOutputBufferNeeded[i]==OMX_TRUE ) {
693 tsem_down(pOutputSem[i]);
694 if(pOutputQueue[i]->nelem>0){
695 outBufExchanged[i]++;
696 isOutputBufferNeeded[i]=OMX_FALSE;
697 pOutputBuffer[i] = dequeue(pOutputQueue[i]);
698 if(pOutputBuffer[i] == NULL){
699 DEBUG(DEB_LEV_ERR, "Had NULL output buffer!!\n");
700 break;
701 }
702 }
703 }
704
705 if(isOutputBufferNeeded[i]==OMX_FALSE) {
706 /*Output Buffer has been produced or EOS. So, return output buffer and get new buffer*/
707 if(pOutputBuffer[i]->nFilledLen!=0) {
708 DEBUG(DEB_LEV_ERR, "In %s Returning Output nFilledLen=%d (line=%d)\n",
709 __func__,(int)pOutputBuffer[i]->nFilledLen,__LINE__);
710 pOutPort[i]->ReturnBufferFunction((omx_base_PortType*)pOutPort[i],pOutputBuffer[i]);
711 outBufExchanged[i]--;
712 pOutputBuffer[i]=NULL;
713 isOutputBufferNeeded[i]=OMX_TRUE;
714 }
715 }
716 }
717 }
718 omx_clocksrc_component_Private->transientState = OMX_TransStateMax;
719 }
720
721 if(omx_clocksrc_component_Private->state == OMX_StateLoaded ||
722 omx_clocksrc_component_Private->state == OMX_StateInvalid ||
723 omx_clocksrc_component_Private->transientState == OMX_TransStateIdleToLoaded ||
724 omx_clocksrc_component_Private->transientState == OMX_TransStateInvalid) {
725
726 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Buffer Management Thread is exiting (line %d)\n",__func__,__LINE__);
727 break;
728 }
729
730 for(i=0;i<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;i++) {
731 if(pOutPort[i]->sMediaTime.eUpdateType == OMX_TIME_UpdateClockStateChanged ||
734
735 if((isOutputBufferNeeded[i]==OMX_TRUE && pOutputSem[i]->semval==0) &&
736 (omx_clocksrc_component_Private->state != OMX_StateLoaded && omx_clocksrc_component_Private->state != OMX_StateInvalid)
737 && PORT_IS_ENABLED(pOutPort[i])) {
738 //Signalled from EmptyThisBuffer or FillThisBuffer or some where else
739 DEBUG(DEB_LEV_FULL_SEQ, "Waiting for next output buffer %i\n",i);
740 tsem_down(omx_clocksrc_component_Private->bMgmtSem);
741 }
742 if(omx_clocksrc_component_Private->state == OMX_StateLoaded ||
743 omx_clocksrc_component_Private->state == OMX_StateInvalid ||
744 omx_clocksrc_component_Private->transientState == OMX_TransStateIdleToLoaded ||
745 omx_clocksrc_component_Private->transientState == OMX_TransStateInvalid) {
746 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Buffer Management Thread is exiting (line %d)\n",__func__,__LINE__);
747 break;
748 }
749
750 if(pOutputSem[i]->semval>0 && isOutputBufferNeeded[i]==OMX_TRUE ) {
751 tsem_down(pOutputSem[i]);
752 if(pOutputQueue[i]->nelem>0){
753 outBufExchanged[i]++;
754 isOutputBufferNeeded[i]=OMX_FALSE;
755 pOutputBuffer[i] = dequeue(pOutputQueue[i]);
756 if(pOutputBuffer[i] == NULL){
757 DEBUG(DEB_LEV_ERR, "Had NULL output buffer!!\n");
758 break;
759 }
760 }
761 } else {
762 DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s Output buffer not available Port %d (line=%d)\n",__func__,(int)i,__LINE__);
763
764 /*Check if any dummy bMgmtSem signal and ports are flushing*/
765 pthread_mutex_lock(&omx_clocksrc_component_Private->flush_mutex);
766 bPortsBeingFlushed = OMX_FALSE;
767 for(j=0;j<omx_clocksrc_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;j++) {
768 bPortsBeingFlushed |= PORT_IS_BEING_FLUSHED(pOutPort[j]);
769 }
770 pthread_mutex_unlock(&omx_clocksrc_component_Private->flush_mutex);
771 if(bPortsBeingFlushed) {
772 DEBUG(DEB_LEV_ERR, "In %s Ports are being flushed - breaking (line %d)\n",__func__,__LINE__);
773 break;
774 }
775 }
776 /*Process Output buffer of Port i */
777 if(isOutputBufferNeeded[i]==OMX_FALSE) {
778 if (omx_clocksrc_component_Private->BufferMgmtCallback) {
779 (*(omx_clocksrc_component_Private->BufferMgmtCallback))(openmaxStandComp, pOutputBuffer[i]);
780 } else {
781 /*If no buffer management call back then don't produce any output buffer*/
782 pOutputBuffer[i]->nFilledLen = 0;
783 }
784
785 /*Output Buffer has been produced or EOS. So, return output buffer and get new buffer*/
786 if(pOutputBuffer[i]->nFilledLen!=0) {
787 pOutPort[i]->ReturnBufferFunction((omx_base_PortType*)pOutPort[i],pOutputBuffer[i]);
788 outBufExchanged[i]--;
789 pOutputBuffer[i]=NULL;
790 isOutputBufferNeeded[i]=OMX_TRUE;
791 }
792 }
793 }
794 }
795
796 DEBUG(DEB_LEV_SIMPLE_SEQ, "Sent Clock Event for all ports\n");
797 tsem_up(omx_clocksrc_component_Private->clockEventCompleteSem);
798 }
799 DEBUG(DEB_LEV_SIMPLE_SEQ,"Exiting Buffer Management Thread\n");
800 return NULL;
801}
802
808 omx_clocksrc_component_PrivateType* omx_clocksrc_component_Private;
809 OMX_BUFFERHEADERTYPE* pBuffer;
810 int errQue;
811
812 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
813 omx_clocksrc_component_Private = (omx_clocksrc_component_PrivateType*)openmaxStandPort->standCompContainer->pComponentPrivate;
814
815 pthread_mutex_lock(&omx_clocksrc_component_Private->flush_mutex);
816 openmaxStandPort->bIsPortFlushed=OMX_TRUE;
817 /*Signal the buffer management thread of port flush,if it is waiting for buffers*/
818 if(omx_clocksrc_component_Private->bMgmtSem->semval==0) {
819 tsem_up(omx_clocksrc_component_Private->bMgmtSem);
820 }
821 tsem_up(omx_clocksrc_component_Private->clockEventSem);
822 tsem_up(omx_clocksrc_component_Private->clockEventCompleteSem);
823
824 if(omx_clocksrc_component_Private->state==OMX_StatePause ) {
825 /*Waiting at paused state*/
826 tsem_signal(omx_clocksrc_component_Private->bStateSem);
827 }
828 DEBUG(DEB_LEV_FULL_SEQ, "In %s waiting for flush all condition port index =%d\n", __func__,(int)openmaxStandPort->sPortParam.nPortIndex);
829 /* Wait until flush is completed */
830 pthread_mutex_unlock(&omx_clocksrc_component_Private->flush_mutex);
831 tsem_down(omx_clocksrc_component_Private->flush_all_condition);
832
833 tsem_reset(omx_clocksrc_component_Private->bMgmtSem);
834 tsem_reset(omx_clocksrc_component_Private->clockEventSem);
835
836 /* Flush all the buffers not under processing */
837 while (openmaxStandPort->pBufferSem->semval > 0) {
838 DEBUG(DEB_LEV_FULL_SEQ, "In %s TFlag=%x Flusing Port=%d,Semval=%d Qelem=%d\n",
839 __func__,(int)openmaxStandPort->nTunnelFlags,(int)openmaxStandPort->sPortParam.nPortIndex,
840 (int)openmaxStandPort->pBufferSem->semval,(int)openmaxStandPort->pBufferQueue->nelem);
841
842 tsem_down(openmaxStandPort->pBufferSem);
843 pBuffer = dequeue(openmaxStandPort->pBufferQueue);
844 if (PORT_IS_TUNNELED(openmaxStandPort) && !PORT_IS_BUFFER_SUPPLIER(openmaxStandPort)) {
845 DEBUG(DEB_LEV_FULL_SEQ, "In %s: Comp %s is returning io:%d buffer\n",
846 __func__,omx_clocksrc_component_Private->name,(int)openmaxStandPort->sPortParam.nPortIndex);
847 if (openmaxStandPort->sPortParam.eDir == OMX_DirInput) {
848 ((OMX_COMPONENTTYPE*)(openmaxStandPort->hTunneledComponent))->FillThisBuffer(openmaxStandPort->hTunneledComponent, pBuffer);
849 } else {
850 ((OMX_COMPONENTTYPE*)(openmaxStandPort->hTunneledComponent))->EmptyThisBuffer(openmaxStandPort->hTunneledComponent, pBuffer);
851 }
852 } else if (PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort)) {
853 errQue = queue(openmaxStandPort->pBufferQueue,pBuffer);
854 if (errQue) {
855 /* /TODO the queue is full. This can be handled in a fine way with
856 * some retrials, or other checking. For the moment this is a critical error
857 * and simply causes the failure of this call
858 */
860 }
861 } else {
862 (*(openmaxStandPort->BufferProcessedCallback))(
863 openmaxStandPort->standCompContainer,
864 omx_clocksrc_component_Private->callbackData,
865 pBuffer);
866 }
867 }
868 /*Port is tunneled and supplier and didn't received all it's buffer then wait for the buffers*/
869 if (PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(openmaxStandPort)) {
870 while(openmaxStandPort->pBufferQueue->nelem!= openmaxStandPort->nNumAssignedBuffers){
871 tsem_down(openmaxStandPort->pBufferSem);
872 DEBUG(DEB_LEV_PARAMS, "In %s Got a buffer qelem=%d\n",__func__,openmaxStandPort->pBufferQueue->nelem);
873 }
874 tsem_reset(openmaxStandPort->pBufferSem);
875 }
876
877 pthread_mutex_lock(&omx_clocksrc_component_Private->flush_mutex);
878 openmaxStandPort->bIsPortFlushed=OMX_FALSE;
879 pthread_mutex_unlock(&omx_clocksrc_component_Private->flush_mutex);
880
881 tsem_up(omx_clocksrc_component_Private->flush_condition);
882
883 DEBUG(DEB_LEV_FULL_SEQ, "Out %s Port Index=%d bIsPortFlushed=%d Component %s\n", __func__,
884 (int)openmaxStandPort->sPortParam.nPortIndex,(int)openmaxStandPort->bIsPortFlushed,omx_clocksrc_component_Private->name);
885
886 DEBUG(DEB_LEV_PARAMS, "In %s TFlag=%x Qelem=%d BSem=%d bMgmtsem=%d component=%s\n", __func__,
887 (int)openmaxStandPort->nTunnelFlags,
888 (int)openmaxStandPort->pBufferQueue->nelem,
889 (int)openmaxStandPort->pBufferSem->semval,
890 (int)omx_clocksrc_component_Private->bMgmtSem->semval,
891 omx_clocksrc_component_Private->name);
892
893 DEBUG(DEB_LEV_FUNCTION_NAME, "Out %s Port Index=%d\n", __func__,(int)openmaxStandPort->sPortParam.nPortIndex);
894
895 return OMX_ErrorNone;
896}
897
OMX_ERRORTYPE
Definition: OMX_Core.h:127
@ OMX_ErrorInsufficientResources
Definition: OMX_Core.h:131
@ OMX_ErrorSameState
Definition: OMX_Core.h:187
@ OMX_ErrorBadPortIndex
Definition: OMX_Core.h:224
@ OMX_ErrorNone
Definition: OMX_Core.h:128
@ OMX_ErrorBadParameter
Definition: OMX_Core.h:147
@ OMX_ErrorIncorrectStateTransition
Definition: OMX_Core.h:212
@ OMX_ErrorIncorrectStateOperation
Definition: OMX_Core.h:215
OMX_INDEXTYPE
Definition: OMX_Index.h:60
@ OMX_IndexConfigTimeCurrentVideoReference
Definition: OMX_Index.h:234
@ OMX_IndexConfigTimeClockState
Definition: OMX_Index.h:229
@ OMX_IndexConfigTimeCurrentMediaTime
Definition: OMX_Index.h:231
@ OMX_IndexConfigTimeClientStartTime
Definition: OMX_Index.h:236
@ OMX_IndexConfigTimeActiveRefClock
Definition: OMX_Index.h:230
@ OMX_IndexConfigTimeCurrentWallTime
Definition: OMX_Index.h:232
@ OMX_IndexConfigTimeCurrentAudioReference
Definition: OMX_Index.h:233
@ OMX_IndexParamStandardComponentRole
Definition: OMX_Index.h:85
@ OMX_IndexConfigTimeScale
Definition: OMX_Index.h:228
@ OMX_IndexParamOtherPortFormat
Definition: OMX_Index.h:221
@ OMX_IndexParamOtherInit
Definition: OMX_Index.h:67
@ OMX_IndexConfigTimeMediaTimeRequest
Definition: OMX_Index.h:235
@ OMX_TIME_UpdateRequestFulfillment
Definition: OMX_Other.h:122
@ OMX_TIME_UpdateScaleChanged
Definition: OMX_Other.h:123
@ OMX_TIME_UpdateMax
Definition: OMX_Other.h:127
@ OMX_TIME_UpdateClockStateChanged
Definition: OMX_Other.h:124
@ OMX_TIME_RefClockNone
Definition: OMX_Other.h:132
struct OMX_TIME_MEDIATIMETYPE OMX_TIME_MEDIATIMETYPE
@ OMX_TIME_ClockStateWaitingForStartTime
Definition: OMX_Other.h:143
@ OMX_TIME_ClockStateMax
Definition: OMX_Other.h:149
@ OMX_TIME_ClockStateStopped
Definition: OMX_Other.h:146
@ OMX_TIME_ClockStateRunning
Definition: OMX_Other.h:142
#define OMX_ALL
Definition: OMX_Types.h:99
unsigned long OMX_U32
Definition: OMX_Types.h:145
char * OMX_STRING
Definition: OMX_Types.h:206
OMX_BOOL
Definition: OMX_Types.h:189
@ OMX_TRUE
Definition: OMX_Types.h:191
@ OMX_FALSE
Definition: OMX_Types.h:190
void * OMX_PTR
Definition: OMX_Types.h:199
OMX_S64 OMX_TICKS
Definition: OMX_Types.h:282
void * OMX_HANDLETYPE
Definition: OMX_Types.h:295
signed long OMX_S32
Definition: OMX_Types.h:148
@ OMX_DirInput
Definition: OMX_Types.h:226
@ OMX_PortDomainOther
Definition: OMX_Component.h:54
@ OMX_StateExecuting
Definition: OMX_Core.h:105
@ OMX_StateWaitForResources
Definition: OMX_Core.h:108
@ OMX_StateLoaded
Definition: OMX_Core.h:97
@ OMX_StateInvalid
Definition: OMX_Core.h:94
@ OMX_StateIdle
Definition: OMX_Core.h:102
@ OMX_StatePause
Definition: OMX_Core.h:107
OMX_COMMANDTYPE
Definition: OMX_Core.h:50
@ OMX_CommandPortDisable
Definition: OMX_Core.h:53
@ OMX_CommandPortEnable
Definition: OMX_Core.h:54
@ OMX_CommandStateSet
Definition: OMX_Core.h:51
OMX_ERRORTYPE base_clock_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, omx_base_PortType **openmaxStandPort, OMX_U32 nPortIndex, OMX_BOOL isInput)
the base constructor for the generic OpenMAX ST Clock port
OMX_ERRORTYPE omx_base_component_SendCommand(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData)
standard SendCommand function
OMX_ERRORTYPE omx_base_component_SetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_ParameterSanityCheck(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pStructure, size_t size)
void setHeader(OMX_PTR header, OMX_U32 size)
Simply fills the first two fields in any OMX structure with the size and the version.
OMX_ERRORTYPE omx_base_component_GetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE checkHeader(OMX_PTR header, OMX_U32 size)
Checks the header of a structure for consistency with size and spec version.
@ OMX_TransStatePauseToExecuting
@ OMX_TransStateInvalid
@ OMX_TransStateIdleToLoaded
@ OMX_TransStateMax
@ OMX_TransStateLoadedToIdle
#define PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:46
#define PORT_IS_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:45
#define PORT_IS_TUNNELED(pPort)
Definition: omx_base_port.h:43
#define PORT_IS_ENABLED(pPort)
Definition: omx_base_port.h:41
#define PORT_IS_BEING_FLUSHED(pPort)
Definition: omx_base_port.h:39
OMX_ERRORTYPE omx_base_source_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
OMX_ERRORTYPE omx_base_source_Destructor(OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE omx_clocksrc_component_GetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
OMX_ERRORTYPE omx_clocksrc_component_SetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
OMX_ERRORTYPE omx_clocksrc_component_GetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE omx_clocksrc_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp)
void * omx_clocksrc_BufferMgmtFunction(void *param)
OMX_ERRORTYPE clocksrc_port_FlushProcessingBuffers(omx_base_PortType *openmaxStandPort)
Releases buffers under processing. This function must be implemented in the derived classes,...
OMX_ERRORTYPE omx_clocksrc_component_SetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE omx_clocksrc_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
OMX_ERRORTYPE omx_clocksrc_component_SendCommand(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData)
void omx_clocksrc_component_BufferMgmtCallback(OMX_COMPONENTTYPE *openmaxStandComp, OMX_BUFFERHEADERTYPE *outputbuffer)
#define CLOCK_COMP_NAME
#define MAX_CLOCK_COMPONENTS
#define MAX_CLOCK_PORTS
#define DEB_LEV_PARAMS
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_SIMPLE_SEQ
#define DEB_LEV_FULL_SEQ
#define DEBUG(n, fmt, args...)
OMX_ERRORTYPE RM_RegisterComponent(char *name, int max_components)
OMX_ERRORTYPE err
int queue(queue_t *queue, void *data)
Definition: queue.c:103
void * dequeue(queue_t *queue)
Definition: queue.c:122
OMX_U32 nOutputPortIndex
Definition: OMX_Core.h:439
OMX_ERRORTYPE(* GetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_INOUT OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* SetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* SetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure)
OMX_ERRORTYPE(* GetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure)
OMX_PTR pComponentPrivate
OMX_ERRORTYPE(* SendCommand)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_COMMANDTYPE Cmd, OMX_IN OMX_U32 nParam1, OMX_IN OMX_PTR pCmdData)
OMX_TIME_UPDATETYPE eUpdateType
Definition: OMX_Other.h:222
OMX_PARAM_PORTDEFINITIONTYPE sPortParam
OMX_ERRORTYPE(* BufferProcessedCallback)(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_U32 nNumAssignedBuffers
OMX_BOOL bIsPortFlushed
OMX_HANDLETYPE hTunneledComponent
OMX_COMPONENTTYPE * standCompContainer
queue_t * pBufferQueue
OMX_ERRORTYPE(* ReturnBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_OTHER_PARAM_PORTFORMATTYPE sOtherParam
OMX_TIME_MEDIATIMETYPE sMediaTime
Definition: queue.h:43
int nelem
Definition: queue.h:46
unsigned int semval
Definition: tsemaphore.h:41
void tsem_deinit(tsem_t *tsem)
Definition: tsemaphore.c:57
void tsem_signal(tsem_t *tsem)
Definition: tsemaphore.c:141
void tsem_up(tsem_t *tsem)
Definition: tsemaphore.c:110
int tsem_init(tsem_t *tsem, unsigned int val)
Definition: tsemaphore.c:39
void tsem_down(tsem_t *tsem)
Definition: tsemaphore.c:97
void tsem_reset(tsem_t *tsem)
Definition: tsemaphore.c:121

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