Пример #1
0
OMX_ERRORTYPE volcEmptyBufferDone(
  OMX_OUT OMX_HANDLETYPE hComponent,
  OMX_OUT OMX_PTR pAppData,
  OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {

  int data_read;
  static int iBufferDropped=0;

  DEBUG(DEB_LEV_FULL_SEQ, "Hi there, I am in the %s callback.\n", __func__);
  data_read = read(fd, pBuffer->pBuffer, BUFFER_IN_SIZE);
  pBuffer->nFilledLen = data_read;
  pBuffer->nOffset = 0;
  filesize -= data_read;
  if (data_read <= 0) {
    DEBUG(DEB_LEV_SIMPLE_SEQ, "In the %s no more input data available\n", __func__);
    iBufferDropped++;
    if(iBufferDropped>=2) {
      tsem_up(appPriv->eofSem);
      return OMX_ErrorNone;
    }
    pBuffer->nFilledLen=0;
    pBuffer->nFlags = OMX_BUFFERFLAG_EOS;
    bEOS=OMX_TRUE;
    err = OMX_EmptyThisBuffer(hComponent, pBuffer);
    return OMX_ErrorNone;
  }
  if(!bEOS) {
    DEBUG(DEB_LEV_FULL_SEQ, "Empty buffer %x\n", (int)pBuffer);
    err = OMX_EmptyThisBuffer(hComponent, pBuffer);
  }else {
    DEBUG(DEB_LEV_FULL_SEQ, "In %s Dropping Empty This buffer to Audio Dec\n", __func__);
  }

  return OMX_ErrorNone;
}
OMX_ERRORTYPE EmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
                              OMX_IN OMX_PTR pAppData,
                              OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
{
    int readBytes =0;

    /* To remove warning for unused variable to keep prototype same */
    (void)pAppData;

    ebd_cnt++;
    used_ip_buf_cnt--;
    pthread_mutex_lock(&etb_lock);
    if(!etb_done)
    {
        DEBUG_PRINT("\n*********************************************\n");
        DEBUG_PRINT("Wait till first set of buffers are given to component\n");
        DEBUG_PRINT("\n*********************************************\n");
        etb_done++;
        pthread_mutex_unlock(&etb_lock);
        etb_wait_for_event();
    }
    else
    {
        pthread_mutex_unlock(&etb_lock);
    }


    if(bInputEosReached)
    {
        DEBUG_PRINT("\n*********************************************\n");
        DEBUG_PRINT("   EBD::EOS on input port\n ");
        DEBUG_PRINT("*********************************************\n");
        return OMX_ErrorNone;
    }else if (bFlushing == true) {
      DEBUG_PRINT("omx_evrc13_adec_test: bFlushing is set to TRUE used_ip_buf_cnt=%d\n",used_ip_buf_cnt);
      if (used_ip_buf_cnt == 0) {
        bFlushing = false;
      } else {
        DEBUG_PRINT("omx_evrc13_adec_test: more buffer to come back used_ip_buf_cnt=%d\n",used_ip_buf_cnt);
        return OMX_ErrorNone;
      }
    }

    if((readBytes = Read_Buffer(pBuffer)) > 0) {
        pBuffer->nFilledLen = readBytes;
        used_ip_buf_cnt++;
        OMX_EmptyThisBuffer(hComponent,pBuffer);
    }
    else{
        pBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
        used_ip_buf_cnt++;
        bInputEosReached = true;
        pBuffer->nFilledLen = 0;
        OMX_EmptyThisBuffer(hComponent,pBuffer);
        DEBUG_PRINT("EBD..Either EOS or Some Error while reading file\n");
    }
    return OMX_ErrorNone;
}
Пример #3
0
OMX_ERRORTYPE audiosrcFillBufferDone(
    OMX_OUT OMX_HANDLETYPE hComponent,
    OMX_OUT OMX_PTR pAppData,
    OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {

    OMX_ERRORTYPE err;
    OMX_STATETYPE eState;

    if(pBuffer != NULL) {
        if(!bEOS) {
            /** if there is volume component component in processing state then send this buffer, in non tunneled case
              * else in non tunneled case, write the output buffer contents in the specified output file
              */
            if(flagIsVolCompRequested && (!flagSetupTunnel)) {
                OMX_GetState(appPriv->volume_handle,&eState);
                if(eState == OMX_StateExecuting || eState == OMX_StatePause) {
                    if(pInBufferVolc[0]->pBuffer == pBuffer->pBuffer) {
                        pInBufferVolc[0]->nFilledLen = pBuffer->nFilledLen;
                        err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[0]);
                    } else {
                        pInBufferVolc[1]->nFilledLen = pBuffer->nFilledLen;
                        err = OMX_EmptyThisBuffer(appPriv->volume_handle, pInBufferVolc[1]);
                    }
                    if(err != OMX_ErrorNone) {
                        DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
                    }
                } else {
                    err = OMX_FillThisBuffer(hComponent, pBuffer);
                }
            } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
                fwrite(pBuffer->pBuffer, 1,  pBuffer->nFilledLen, outfile);
                pBuffer->nFilledLen = 0;
            }
            if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
                DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
                bEOS = OMX_TRUE;
            }
            if(!bEOS && !flagIsVolCompRequested && (!flagSetupTunnel)) {
                err = OMX_FillThisBuffer(hComponent, pBuffer);
            }
        } else {
            DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
        }
    } else {
        DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
    }
    return OMX_ErrorNone;
}
    OMX_ERRORTYPE PortCommTest_WriteInBuffers(PortCommTestCtxt* pContext)
    {
        BufferList * pList;
        OMX_BUFFERHEADERTYPE *pBufHeader;
        OMX_ERRORTYPE eError = OMX_ErrorNone;
        OMX_U32 nPayload;

        pList = pContext->pInBufferList;
        while (pList && pList->pBufHdr)
        {
            pContext->nInBufBusy++;
            LIST_CLEAR_ENTRY(pList, pBufHeader);
            nPayload = (pContext->nBufFactor) ? pBufHeader->nAllocLen / pContext->nBufFactor : 1;
            pBufHeader->nFilledLen = OMX_OSAL_ReadFromInputFile(pBufHeader->pBuffer, nPayload,
                                     pBufHeader->nInputPortIndex);
            if (pBufHeader->nFilledLen != nPayload)
            {
                pBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
            }
            OMX_CONF_BAIL_IF_ERROR(OMX_EmptyThisBuffer(pContext->hWComp, pBufHeader));
        }

OMX_CONF_TEST_BAIL:
        return eError;
    }
Пример #5
0
void* audio_exec(void* udata) {
  float buffer_time_us = (float)(1e6 * NUM_SAMPLES) / SAMPLE_FREQ;
  while(1) {
    /* get a buffer */
    OMX_BUFFERHEADERTYPE *hdr;
    while((hdr = ilclient_get_input_buffer(audio_render, 100, 0)) == NULL) {
      usleep(buffer_time_us / 4); // wait 1/4 of the time to drain a buffer
    }

    // fill the buffer
    audio_fill_buffer((int16_t*)hdr->pBuffer, NUM_SAMPLES * 2);
    hdr->nOffset = 0;
    hdr->nFilledLen = scaled_buffer_size(NUM_SAMPLES);

    // submit the buffer
    OMX_ERRORTYPE error;
    error = OMX_EmptyThisBuffer(ILC_GET_HANDLE(audio_render), hdr);
    assert(error == OMX_ErrorNone);

    // drive down the latency to a buffer's length or less
    uint32_t latency;
    while(audio_get_latency() > NUM_SAMPLES) {
      usleep(buffer_time_us / 2);
    }
  }
}
Пример #6
0
OMX_ERRORTYPE read_into_buffer_and_empty(FILE *fp,
                                         COMPONENT_T *component,
                                         OMX_BUFFERHEADERTYPE *buff_header,
                                         int *toread)
{
    OMX_ERRORTYPE r;

    int buff_size = buff_header->nAllocLen;
    int nread = fread(buff_header->pBuffer, 1, buff_size, fp);

    buff_header->nFilledLen = nread;
    *toread -= nread;
    printf("Read %d, %d still left\n", nread, *toread);

    if (*toread <= 0)
    {
        printf("Setting EOS on input\n");
        buff_header->nFlags |= OMX_BUFFERFLAG_EOS;
    }
    r = OMX_EmptyThisBuffer(ilclient_get_handle(component),
                            buff_header);
    if (r != OMX_ErrorNone)
    {
        fprintf(stderr, "Empty buffer error %s\n",
                err2str(r));
    }
    return r;
}
Пример #7
0
OMX_ERRORTYPE omxSetAudioExtraData(struct OMX_COMPONENT_T *component, uint8_t *extraData, int extraSize)
{
	OMX_ERRORTYPE omxErr = OMX_ErrorNotReady;

	if ((extraSize <= 0) || (extraData == NULL)) {
		return OMX_ErrorNone;
	}

	OMX_BUFFERHEADERTYPE *omxBuffer = omxGetInputBuffer(component, 0);

	if(omxBuffer == NULL) {
		logInfo(LOG_OMX, "Error getting inputbuffer on component %s\n", component->componentName);
		return omxErr;
	}

	omxBuffer->nOffset = 0;
	omxBuffer->nFilledLen = extraSize;
	if(omxBuffer->nFilledLen > omxBuffer->nAllocLen) {
		logInfo(LOG_OMX, "Error omxBuffer->nFilledLen > omxBuffer->nAllocLen on component %s\n", component->componentName);
		return omxErr;
	}

	memset((unsigned char *)omxBuffer->pBuffer, 0x0, omxBuffer->nAllocLen);
	memcpy((unsigned char *)omxBuffer->pBuffer, extraData, omxBuffer->nFilledLen);
	omxBuffer->nFlags = OMX_BUFFERFLAG_CODECCONFIG | OMX_BUFFERFLAG_ENDOFFRAME;

	omxErr = OMX_EmptyThisBuffer(component->handle, omxBuffer);
	if (omxErr != OMX_ErrorNone) {
		logInfo(LOG_OMX, "Error OMX_EmptyThisBuffer on component %s (Error=0x%08x)\n", component->componentName, omxErr);
		return omxErr;
	}

	return OMX_ErrorNone;

}
OMX_ERRORTYPE port_enable(HTEST *hTest, OMX_U32 nPortIndex)
{
	OMX_ERRORTYPE ret = OMX_ErrorNone;
	OMX_COMPONENTTYPE *hComponent;
	OMX_U32 i;

	hComponent = hTest->hComponent;
	ret = SendCommand(hTest, OMX_CommandPortEnable, nPortIndex, NULL, OMX_FALSE);
	if(ret != OMX_ErrorNone)
		return ret;

	prepare_port_buffers(hTest, nPortIndex);

	WaitCommand(hTest, OMX_CommandPortEnable, nPortIndex, NULL);

	hTest->bHoldBuffers = OMX_FALSE;
	for(i=0; i<hTest->nBufferHdr[nPortIndex]; i++)
	{
		if(hTest->PortDir[nPortIndex] == OMX_DirInput)
		{
			read_frame(hTest, hTest->pBufferHdr[nPortIndex][i]);
			OMX_EmptyThisBuffer(hTest->hComponent, hTest->pBufferHdr[nPortIndex][i]);
		}
	}

	printf("port enable done.\n");

	return OMX_ErrorNone;
}
Пример #9
0
static void wait_complition(player_ctx_t *ctx)
{
    media_buffer_t *buf;
    OMX_BUFFERHEADERTYPE *hdr;
    OMX_ERRORTYPE err;

    if (ctx->common.stop)
        return; /* Force stop player by user */

    buf = decode_get_free_video_buffer(ctx->common.demux_ctx);
    if (!buf)
    {
        DBG_E("Unable to get free video buffer\n");
        return;
    }
    hdr = (OMX_BUFFERHEADERTYPE *)buf->app_data;
    hdr->pAppPrivate = buf;
    hdr->nOffset = 0;
    hdr->nFilledLen = 0;
    hdr->nTimeStamp = to_omx_time(0);
    hdr->nFlags = OMX_BUFFERFLAG_ENDOFFRAME | OMX_BUFFERFLAG_EOS | OMX_BUFFERFLAG_TIME_UNKNOWN;

    err = OMX_EmptyThisBuffer(ilcore_get_handle(ctx->decoder), hdr);
    if (err != OMX_ErrorNone)
    {
        DBG_E("OMX_EmptyThisBuffer failed. err=0x%08x\n", err);
        return;
    }
    DBG_I("Waiting for end of stream\n");
    while (!ctx->eos)
    {
        usleep(100000);
    }
}
OMX_ERRORTYPE AnatomyOMXClient::OnEmptyBufferDone(
	    OMX_IN OMX_HANDLETYPE hComponent,
	    OMX_IN OMX_PTR pAppData,
	    OMX_IN OMX_BUFFERHEADERTYPE *pBuffer) {

	AnatomyOMXClient* omxclient = reinterpret_cast<AnatomyOMXClient*>(pAppData);
	int nSize = 0;
	omxclient->addOMXBufferInfo(kPortIndexInput, pBuffer);
	CHECK(NULL != omxclient);
	CHECK( NULL != pBuffer );

	if( pBuffer->nFlags & OMX_BUFFERFLAG_EOS )
	{
		return OMX_ErrorNone;
	}

	omxclient->read(pBuffer->pBuffer, &nSize);

	if( nSize <= 0 ) {
		pBuffer->nSize = 0;
		pBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
	}
	else {
		pBuffer->nSize = nSize;
	}

	OMX_EmptyThisBuffer(hComponent, pBuffer);
	omxclient->removeOMXBufferInfo(kPortIndexInput, pBuffer);
	return OMX_ErrorNone;
}
int
renderImage(OPENMAX_JPEG_DECODER * decoder) {
    int ret;

    printf("Rendering image\n");
    printState(decoder->imageDecoder->handle);

    // setup render buffer
    decoder->ppRenderInputBufferHeader[0]->nFilledLen =
	decoder->pOutputBufferHeader->nFilledLen;
    decoder->ppRenderInputBufferHeader[0]->nFlags = OMX_BUFFERFLAG_EOS;

    printf("Render buffer has %d\n",
	   decoder->ppRenderInputBufferHeader[0]->nFilledLen);
    ret = OMX_EmptyThisBuffer(decoder->imageRender->handle,
			     decoder->ppRenderInputBufferHeader[0]);
    if (ret != OMX_ErrorNone) {
	perror("Emptying render input buffer");
	fprintf(stderr, "Error code %s\n", err2str(ret));
	return OMXJPEG_ERROR_MEMORY;
    } else {
	printf("Called to empty render input buffer\n");
    }

    return OMXJPEG_OK;
}
void * process_thread(void *ptr)
{
	HTEST *hTest = (HTEST*)ptr;
	OMX_BUFFERHEADERTYPE *pBufferHdr = NULL;
	MSG sMsg;

	while(1)
	{
		hTest->pMsgQ->Get(&sMsg);
		if(sMsg.type == EVENT)
		{
			process_event(hTest, &sMsg);
		}
		else if(sMsg.type == EMPTY_DONE)
		{
			pBufferHdr = sMsg.data.buffer.pBuffer;
			if(hTest->bHoldBuffers != OMX_TRUE)
			{
				read_data(hTest, pBufferHdr);
				OMX_EmptyThisBuffer(sMsg.hComponent, pBufferHdr);
			}
		}
		else if(sMsg.type == FILL_DONE)
		{
			pBufferHdr = sMsg.data.buffer.pBuffer;
			if(hTest->bHoldBuffers != OMX_TRUE)
				OMX_FillThisBuffer(sMsg.hComponent, pBufferHdr);
		}

		if(hTest->bStop == OMX_TRUE)
			break;
	}

	return NULL;
}
Пример #13
0
static void
rpi_codec_decode(struct media_codec *mc, struct video_decoder *vd,
		 struct media_queue *mq, struct media_buf *mb, int reqsize)
{
  media_pipe_t *mp = vd->vd_mp;
  rpi_video_codec_t *rvc = mc->opaque;
  const void *data = mb->mb_data;
  size_t len       = mb->mb_size;

  while(len > 0) {
    OMX_BUFFERHEADERTYPE *buf = omx_get_buffer(rvc->rvc_decoder);
    buf->nOffset = 0;
    buf->nFilledLen = MIN(len, buf->nAllocLen);
    memcpy(buf->pBuffer, data, buf->nFilledLen);
    buf->nFlags = 0;


    if(rvc->rvc_last_epoch != mb->mb_epoch) {
      buf->nFlags |= OMX_BUFFERFLAG_DISCONTINUITY;
      rvc->rvc_last_epoch = mb->mb_epoch;
    }

    if(len <= buf->nAllocLen)
      buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;

    data += buf->nFilledLen;
    len  -= buf->nFilledLen;

    if(mb->mb_pts != PTS_UNSET)
      buf->nTimeStamp = omx_ticks_from_s64(mb->mb_pts);
    else {
      buf->nFlags |= OMX_BUFFERFLAG_TIME_UNKNOWN;
      buf->nTimeStamp = omx_ticks_from_s64(0);
    }

    if(mb->mb_skip)
      buf->nFlags |= OMX_BUFFERFLAG_DECODEONLY;

    if(rvc->rvc_decoder->oc_port_settings_changed) {
      rvc->rvc_decoder->oc_port_settings_changed = 0;
      frame_info_t fi;
      memset(&fi, 0, sizeof(fi));
      fi.fi_type        = 'omx';
      fi.fi_data[0]     = (void *)rvc->rvc_decoder;
      mp->mp_video_frame_deliver(&fi, mp->mp_video_frame_opaque);
    }

    omxchk(OMX_EmptyThisBuffer(rvc->rvc_decoder->oc_handle, buf));
  }  

  frame_info_t fi;
  memset(&fi, 0, sizeof(fi));
  fi.fi_drive_clock = mb->mb_drive_clock;
  fi.fi_epoch       = mb->mb_epoch;
  fi.fi_pts         = PTS_UNSET;
  fi.fi_delta       = mb->mb_delta;
  fi.fi_type        = 'omx';
  mp->mp_video_frame_deliver(&fi, mp->mp_video_frame_opaque);
}
/*========================================================*/
OMX_ERRORTYPE SampleTest_WriteInBuffers(SampleCompTestCtxt * pContext)
{

	OMX_ERRORTYPE eError = OMX_ErrorNone;
	BufferList *pList;
	OMX_BUFFERHEADERTYPE *pBufHeader;
#ifdef OMX_SAMPLE_TILER_TEST
	OMX_U8 *pTmpBuffer = NULL, *pOrigTmpBuffer = NULL;
#endif
	pList = pContext->pInBufferList;
	while (pList && pList->pBufHdr)
	{
		BUFFERLIST_CLEAR_ENTRY(pList, pBufHeader);
		printf("\nAbout to read from input file\n");
#if defined(OMX_SAMPLE_TILER_TEST)

		//OMX_SAMPLE_BUFFER_SIZE is the total amt of data to be sent in the buffer
		pTmpBuffer =
		    TIMM_OSAL_Malloc(OMX_SAMPLE_BUFFER_SIZE, 0, 0, 0);
		if (pTmpBuffer == NULL)
			OMX_TEST_SET_ERROR_BAIL
			    (OMX_ErrorInsufficientResources,
			    "malloc failed \n");
		pOrigTmpBuffer = pTmpBuffer;

		SampleTest_ReadInputFile(pContext, pTmpBuffer,
		    OMX_SAMPLE_BUFFER_SIZE, pContext->pInputfile);

		Test_Util_Memcpy_1Dto2D(pBufHeader->pBuffer, pTmpBuffer,
		    OMX_SAMPLE_BUFFER_SIZE, OMX_SAMPLE_IN_HEIGHT,
		    OMX_SAMPLE_IN_WIDTH, STRIDE_LINUX);
		pBufHeader->nFilledLen = OMX_SAMPLE_BUFFER_SIZE;

		printf("\nBefore ETB pBufHeader->nInputPortIndex = %d\n",
		    pBufHeader->nInputPortIndex);

		TIMM_OSAL_Free(pOrigTmpBuffer);

#else
		SampleTest_ReadInputFile(pContext, pBufHeader->pBuffer,
		    pBufHeader->nAllocLen, pContext->pInputfile);
		pBufHeader->nFilledLen = pBufHeader->nAllocLen;

#endif
		if (pContext->bEOS == OMX_TRUE)
		{
			pBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
		}

		eError = OMX_EmptyThisBuffer(pContext->hComp, pBufHeader);

		OMX_TEST_BAIL_IF_ERROR(eError);
	}

      OMX_TEST_BAIL:
	return eError;

}
Пример #15
0
OMX_ERRORTYPE EmptyBufferDone(OMX_IN OMX_HANDLETYPE hComponent,
                              OMX_IN OMX_PTR pAppData,
                              OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
{
    int readBytes =0;


    DEBUG_PRINT("\nFunction %s cnt[%d]\n", __FUNCTION__, ebd_cnt);
    ebd_cnt++;
    used_ip_buf_cnt--;
    if(bInputEosReached) {
        DEBUG_PRINT("\n*********************************************\n");
    DEBUG_PRINT("   EBD::EOS on input port\n ");
    DEBUG_PRINT("   TBD:::De Init the open max here....!!!\n");
    DEBUG_PRINT("*********************************************\n");
        if(tunnel)
            event_complete();
        return OMX_ErrorNone;
    }    else if (bFlushing == true) {
        DEBUG_PRINT("omx_aac_adec_test: bFlushing is set to TRUE used_ip_buf_cnt=%d\n",used_ip_buf_cnt);
      if (used_ip_buf_cnt == 0) {
        //fseek(inputBufferFile, 0, 0);
        bFlushing = false;
      } else {
        DEBUG_PRINT("omx_aac_adec_test: more buffer to come back used_ip_buf_cnt=%d\n",used_ip_buf_cnt);
        return OMX_ErrorNone;
      }
    }

    if((readBytes = Read_Buffer(pBuffer)) > 0) {
        pBuffer->nFilledLen = readBytes;
        used_ip_buf_cnt++;
        OMX_EmptyThisBuffer(hComponent,pBuffer);
    }
    else{
      pBuffer->nFlags |= OMX_BUFFERFLAG_EOS;
            bInputEosReached = true;
        pBuffer->nFilledLen = 0;
        OMX_EmptyThisBuffer(hComponent,pBuffer);
        DEBUG_PRINT("EBD..Either EOS or Some Error while reading file\n");
    }
    return OMX_ErrorNone;
}
Пример #16
0
OMX_ERRORTYPE omxil_comp::EmptyThisBuffer(OMX_BUFFERHEADERTYPE *pBuffer)
{
	OMX_ERRORTYPE result;

	result = OMX_EmptyThisBuffer(comp, pBuffer);
	if (result != OMX_ErrorNone) {
		fprintf(stderr, "OMX_EmptyThisBuffer failed.\n");
	}

	return result;
}
Пример #17
0
static void UnlockSurface(picture_t *picture)
{
    picture_sys_t *picsys = picture->p_sys;
    vout_display_sys_t *p_sys = picsys->sys;
    OMX_BUFFERHEADERTYPE *p_buffer = picsys->buf;

    if (!p_buffer->nFilledLen)
        OMX_FIFO_PUT(&p_sys->port.fifo, p_buffer);
    else
        OMX_EmptyThisBuffer(p_sys->omx_handle, p_buffer);
}
Пример #18
0
OMX_ERRORTYPE volumeFillBufferDone(
    OMX_OUT OMX_HANDLETYPE hComponent,
    OMX_OUT OMX_PTR pAppData,
    OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer) {

    OMX_ERRORTYPE err;
    if(pBuffer != NULL) {
        if(!bEOS) {
            /** if there is no sink component then write buffer content in output file, in non tunneled case
              * else in non tunneled case, call the sink comp handle to process this buffer as its input buffer
              */
            if(flagIsSinkRequested && (!flagSetupTunnel)) {
                if(pInBufferSink[0]->pBuffer == pBuffer->pBuffer) {
                    pInBufferSink[0]->nFilledLen = pBuffer->nFilledLen;
                    err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[0]);
                } else {
                    pInBufferSink[1]->nFilledLen = pBuffer->nFilledLen;
                    err = OMX_EmptyThisBuffer(appPriv->alsasink_handle, pInBufferSink[1]);
                }
                if(err != OMX_ErrorNone) {
                    DEBUG(DEB_LEV_ERR, "In %s Error %08x Calling FillThisBuffer\n", __func__,err);
                }
            } else if((pBuffer->nFilledLen > 0) && (!flagSetupTunnel)) {
                fwrite(pBuffer->pBuffer, 1,  pBuffer->nFilledLen, outfile);
                pBuffer->nFilledLen = 0;
            }
            if(pBuffer->nFlags == OMX_BUFFERFLAG_EOS) {
                DEBUG(DEB_LEV_ERR, "In %s: eos=%x Calling Empty This Buffer\n", __func__, (int)pBuffer->nFlags);
                bEOS = OMX_TRUE;
            }
            if(!bEOS && !flagIsSinkRequested && (!flagSetupTunnel)) {
                err = OMX_FillThisBuffer(hComponent, pBuffer);
            }
        } else {
            DEBUG(DEB_LEV_ERR, "In %s: eos=%x Dropping Empty This Buffer\n", __func__,(int)pBuffer->nFlags);
        }
    } else {
        DEBUG(DEB_LEV_ERR, "Ouch! In %s: had NULL buffer to output...\n", __func__);
    }
    return OMX_ErrorNone;
}
Пример #19
0
OMX_ERRORTYPE COMXCoreComponent::EmptyThisBuffer(OMX_BUFFERHEADERTYPE *omx_buffer)
{
    OMX_ERRORTYPE omx_err = OMX_ErrorNone;

    if(!m_handle || !omx_buffer)
        return OMX_ErrorUndefined;

    omx_err = OMX_EmptyThisBuffer(m_handle, omx_buffer);
    if (omx_err != OMX_ErrorNone) {
        Logger::LogOut(LOG_LEVEL_ERROR, "COMXCoreComponent::EmptyThisBuffer component(%s) - failed with result(0x%x)",
                m_componentName.c_str(), omx_err);
    }

    return omx_err;
}
Пример #20
0
int32_t ilctts_send_audio(TTSRENDER_STATE_T *st, uint8_t *buffer, uint32_t length) {
	OMX_BUFFERHEADERTYPE *hdr = NULL, *prev = NULL;
	int32_t ret = -1;

	if(length % st->bytes_per_sample) {
		ERROR("length invalid in ilctts_send_audio: %d", length);
		return -1;
	}

	if (length > st->buffer_size) {
		ERROR("length exceeds component buffer size in ilctts_send_audio: %d, buffer size: %d", length, st->buffer_size); 
		return -1;
	}

	sem_wait(&st->buffer_list_sema);

	// search through user list for the right buffer header
	hdr = st->user_buffer_list;
	while(hdr != NULL && hdr->pBuffer != buffer && hdr->nAllocLen < length) {
		prev = hdr;
		hdr = hdr->pAppPrivate;
	}

	if(hdr) {
		// we found it, remove from list
		ret = 0;
		if(prev)
			prev->pAppPrivate = hdr->pAppPrivate;
		else
			st->user_buffer_list = hdr->pAppPrivate;
	}

	sem_post(&st->buffer_list_sema);

	if(hdr) {
		OMX_ERRORTYPE omx_err;
		hdr->pAppPrivate = NULL;
		hdr->nOffset = 0;
		hdr->nFilledLen = length;
		INFO(LOGLEVEL_5, "Calling empty_this_buffer");
		omx_err = OMX_EmptyThisBuffer(ILC_GET_HANDLE(st->audio_render), hdr);
		if (omx_err != OMX_ErrorNone) {
			ERROR("OMX_EmptyThisBuffer returned error in ilctts_send_audio: %d", omx_err);
			return -1;
		}
	}
	return ret;
} // end ilctts_send_audio
Пример #21
0
void
g_omx_port_release_buffer (GOmxPort *port,
                           OMX_BUFFERHEADERTYPE *omx_buffer)
{
    switch (port->type)
    {
        case GOMX_PORT_INPUT:
            OMX_EmptyThisBuffer (port->core->omx_handle, omx_buffer);
            break;
        case GOMX_PORT_OUTPUT:
            OMX_FillThisBuffer (port->core->omx_handle, omx_buffer);
            break;
        default:
            break;
    }
}
Пример #22
0
/* -------------------------------------------------
/       audioplay_play_buffer() 
/		TODO	why?>	
/---------------------------------------------------*/
INT32 audioplay_play_buffer(
	AUDIOPLAY_STATE_T	*st,
	UINT8			*buffer,
	UINT32			length
){
	OMX_BUFFERHEADERTYPE	*hdr = NULL, *prev = NULL;
	INT32	ret = -1;

	if(length % st->bytes_per_sample)
		return ret;
	
	sem_wait(&st->sema);
	
	/* search through user list for the right buffer header */
	hdr = st->user_buffer_list;
	while(hdr != NULL && hdr->pBuffer != buffer && hdr->nAllocLen < length){
		
		prev = hdr;
		hdr = hdr->pAppPrivate;
	}
	
	/* we found it , remove from list  */
	if(hdr){
		ret = 0;
		if(prev){
			prev->pAppPrivate = hdr->pAppPrivate;
		}else{
			st->user_buffer_list = hdr->pAppPrivate;
		}

	}

	sem_post(&st->sema);
	
	if(hdr){
		OMX_ERRORTYPE	error;
		
		hdr->pAppPrivate = NULL;
		hdr->nOffset = 0;
		hdr->nFilledLen = length;

		error = OMX_EmptyThisBuffer(ILC_GET_HANDLE(st->audio_render), hdr);
		assert(error == OMX_ErrorNone);

	}
	return ret;
}	
Пример #23
0
OMX_ERRORTYPE Component::EmptyThisBuffer(OMX_BUFFERHEADERTYPE *omxBuffer)
{
    if(!handle) 
{
	ofLogError(__func__) << getName() << " NO HANDLE";
	return OMX_ErrorNone;
}

	if(!omxBuffer)
	{
		return OMX_ErrorUndefined;
	}
	OMX_ERRORTYPE error = OMX_EmptyThisBuffer(handle, omxBuffer);
	OMX_TRACE(error);

	return error;
}
Пример #24
0
static void omx_renderer_decode_and_play_sample(char* data, int length) {
  int decodeLen = opus_multistream_decode(decoder, data, length, pcmBuffer, FRAME_SIZE, 0);
  if (decodeLen > 0) {
	buf = ilclient_get_input_buffer(component, 100, 1);
    buf->nOffset = 0;
    buf->nFlags = OMX_BUFFERFLAG_TIME_UNKNOWN;
	int bufLength = decodeLen * sizeof(short) * channelCount;
    memcpy(buf->pBuffer, pcmBuffer, bufLength);
    buf->nFilledLen = bufLength;
    int r = OMX_EmptyThisBuffer(ilclient_get_handle(component), buf);
    if (r != OMX_ErrorNone) {
    fprintf(stderr, "Empty buffer error\n");
    } 
  } else {
    printf("Opus error from decode: %d\n", decodeLen);
  }
}
Пример #25
0
	/* output */
	{
		GooIterator* iter =
			goo_component_iterate_output_ports (component);
		goo_iterator_nth (iter, 0);
		GooPort* port = GOO_PORT (goo_iterator_get_current (iter));
		g_assert (port != NULL);

		GOO_PORT_GET_DEFINITION (port)->nBufferSize =
			OUTPUT_BUFFERSIZE;
		GOO_PORT_GET_DEFINITION (port)->nBufferCountActual = OUTPUT_NUM_BUFFERS;
		GOO_PORT_GET_DEFINITION (port)->format.audio.eEncoding =
			OMX_AUDIO_CodingPCM;

		g_object_unref (iter);
		g_object_unref (port);
	}

	return;
}

#if 0 /* i think it is not necessary now */
static void
goo_ti_mp3dec_release_buffer (GooComponent* self,
			      OMX_BUFFERHEADERTYPE* buffer)
{
	g_assert (GOO_IS_COMPONENT (self));
	g_assert (buffer != NULL);
	g_assert (self->cur_state == OMX_StateExecuting ||
		  self->cur_state == OMX_StateIdle);

	GooPort* port = GOO_PORT (g_object_ref (buffer->pAppPrivate));

	if (goo_port_is_eos (port) || goo_port_is_tunneled (port))
	{
		g_object_unref (port);
		return;
	}

	if ((buffer->nFlags & OMX_BUFFERFLAG_EOS) == 0x1)
	{
		GOO_OBJECT_INFO (port, "eos found!");
		goo_port_set_eos (port);
	}

	/* We should always push the EOS buffer */
	GOO_OBJECT_NOTICE (self, "OMX_EmptyThisBuffer, 0x%x", buffer);

	if (self->cur_state != OMX_StateIdle)
	{
		GOO_OBJECT_LOCK (self);
		GOO_RUN (
			OMX_EmptyThisBuffer (self->handle, buffer)
			);
		GOO_OBJECT_UNLOCK (self);
	}
	else
	{
		g_print("INFORMATION (workaround): Implementing workaround "
			"for DR OMAPS00143083\n");
	}

	g_object_unref (port);

	GOO_OBJECT_DEBUG (self, "");

	return;
}
void * process_thread(void *ptr)
{
	HTEST *hTest = (HTEST*)ptr;
	OMX_BUFFERHEADERTYPE *pBufferHdr = NULL;
	MSG sMsg;

	while(1)
	{
		hTest->pMsgQ->Get(&sMsg);
		if(sMsg.type == EVENT)
		{
			process_event(hTest, &sMsg);
		}
		else if(sMsg.type == EMPTY_DONE)
		{
			pBufferHdr = sMsg.data.buffer.pBuffer;
			if(hTest->bHoldBuffers != OMX_TRUE)
			{
				OMX_EmptyThisBuffer(sMsg.hComponent, pBufferHdr);
			}
		}
		else if(sMsg.type == FILL_DONE)
		{
			pBufferHdr = sMsg.data.buffer.pBuffer;
			if (hTest->bAudioTrackStopped && hTest->bVideoTrackStopped)
				break;

			if (pBufferHdr->nOutputPortIndex == hTest->nAudioTrackNum)
			{
				if (hTest->bAudioTrackStopped)
					continue;
			}
			else if (pBufferHdr->nOutputPortIndex == hTest->nVideoTrackNum)
			{
				if (hTest->bVideoTrackStopped)
					continue;
			}

			if(hTest->bHoldBuffers != OMX_TRUE)
				OMX_FillThisBuffer(sMsg.hComponent, pBufferHdr);
		}

	}

	return NULL;
}
// like emptyBuffer, but the data is already in header->pBuffer
status_t OMXNodeInstance::emptyDirectBuffer(
        OMX_BUFFERHEADERTYPE *header,
        OMX_U32 rangeOffset, OMX_U32 rangeLength,
        OMX_U32 flags, OMX_TICKS timestamp) {
    Mutex::Autolock autoLock(mLock);

    header->nFilledLen = rangeLength;
    header->nOffset = rangeOffset;
    header->nFlags = flags;
    header->nTimeStamp = timestamp;

    OMX_ERRORTYPE err = OMX_EmptyThisBuffer(mHandle, header);
    if (err != OMX_ErrorNone) {
        ALOGW("emptyDirectBuffer failed, OMX err=0x%x", err);
    }

    return StatusFromOMXError(err);
}
Пример #28
0
 iterator EmptyThis(uint8_t const* beg, uint8_t const* end, int flags) {
     auto it = FindFreeBuffer(input_port);
     if (it == input_port.end()) {
         ERR_EXIT("%s",__FUNCTION__);
     } else {
         OMX_BUFFERHEADERTYPE* bh = it->buf;
         bh->nFlags = flags;
         bh->nOffset = 0;
         bh->nFilledLen = end - beg;
         memcpy(bh->pBuffer, beg, bh->nFilledLen);
         // OMX_BUFFERFLAG_CODECCONFIG OMX_BUFFERFLAG_ENDOFFRAME OMX_BUFFERFLAG_DECODEONLY
         it->flags |= MSK_USED;
         OMX_ERRORTYPE err = OMX_EmptyThisBuffer(component, bh);
         ERR_EXIT_IF(err!=OMX_ErrorNone, "OMX_EmptyThisBuffer %d", int(err));
         printf("%s: P0[%d] len %u\n",__FUNCTION__, INDEX(it), bh->nFilledLen);
     }
     return it;
 }
Пример #29
0
static u32 omx_push(void* frame, u32 samples, bool wait)
{
	if(audio_buffers == NULL)
		return 1;

	size_t data_size = samples * 4;

	while(data_size > 0)
	{
		size_t copy_size = std::min(buffer_size, data_size);

		// Don't have more than maximum audio latency
		u32 latency = omx_get_latency();
		if(latency > latency_max)
		{
			usleep((latency - latency_max) * 1000);
		}
		else if(latency == 0)
		{
			fprintf(stderr, "OMX: underrun occurred\n");
		}

		memcpy(audio_buffers[audio_buffer_idx]->pBuffer + buffer_length, frame, copy_size);
		buffer_length += copy_size;

		// Flush buffer and swap
		if(buffer_length >= buffer_size)
		{
			audio_buffers[audio_buffer_idx]->nOffset = 0;
			audio_buffers[audio_buffer_idx]->nFilledLen = buffer_size;

			OMX_ERRORTYPE error = OMX_EmptyThisBuffer(omx_handle, audio_buffers[audio_buffer_idx]);
			if(error != OMX_ErrorNone)
				fprintf(stderr, "OMX: failed to empty buffer[%u]. Error 0x%X\n", audio_buffer_idx, error);

			audio_buffer_idx = (audio_buffer_idx + 1) % buffer_count;
			buffer_length = 0;
		}

		data_size -= copy_size;
	}

	return 1;
}
void AnatomyOMXClient::excute() {
	int nSize = 0;
	OMX_BUFFERHEADERTYPE *pInputHeader = NULL;
	OMX_BUFFERHEADERTYPE *pOutputHeader = NULL;

	for(size_t i = 0; i < mBufferInfo.size(); i++) {
		if( mBufferInfo[i].mPortIndex == kPortIndexInput ) {
			pInputHeader = mBufferInfo[i].mBufferHeader;
			read((char*)(pInputHeader->pBuffer), &nSize);
			OMX_EmptyThisBuffer(mComponentHandle, pInputHeader);
			removeOMXBufferInfo(kPortIndexInput, mBufferInfo[i].mBufferHeader);
		}
		if( mBufferInfo[i].mPortIndex == kPortIndexOutput ) {
			pOutputHeader = mBufferInfo[i].mBufferHeader;
			OMX_FillThisBuffer(mComponentHandle, pOutputHeader);
			removeOMXBufferInfo(kPortIndexOutput, mBufferInfo[i].mBufferHeader);
		}
	}
}