This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

create channels repeatedly error!

Hello

I'm using the 8168 with the DVRRDK4.01 for NVR.

 I like to create 8 channel with 2560x896 with multithreaded application.And every thread is like this

     VdecVdis_bitsRdGetEmptyBitBufs(&emptyBufList, chId);

     if (emptyBufList.numBufs)
    {
         VdecVdis_bitsRdReadData(&emptyBufList);
         VdecVdis_bitsRdSendFullBitBufs(&emptyBufList);
    }

But when I use  Vdec_deleteChn() and Vdec_createChn() to create channels repeatedly, Sometime I get the following message time and time again.

[host] RingBuf(377, RingBufferWriterAcquire) - Writer: Acquire already done

I don't understand why. Could someone tell me the reason?

Thanks in advance!

 

  • I hope your application ensures that IpcBitsOutLink_getEmptyBufs() is not invoked when ch delete is in progress (specifically during RingBufferDeInit() happens).

    Please share the complete log after adding a print with ch number during RingBufferInit() / RingBufferDeInit().

  • Thanks for you answer.

    My application ensures that IpcBitsOutLink_getEmptyBufs() is not invoked when ch delete is in progress.

    This is compelete log.2146.log.log

     

     

  • How can I tell whether the function of 'VdecVdis_bitsRdSendFullBitBufs(&emptyBufList);' is executed correctly?

    • Log shows this sequence.

    ******* RingBuf 7 deleted ********

    ******* RingBuf 7 created ********

    ******* RingBuf 4 deleted ********

    ******* RingBuf 7 created ********

    This is incorrect. RingBuf 7 (CH = 7) is created twice.

     

    Also, your app seems to aquire bitstream buffers and queue them. This is not possible with ringBuf based implementation. Each call to IpcBitsOutLink_getEmptyBufs() should be immediately followed by IpcBitsOutLink_putFullVideoBitStreamBufs().

    Multiple calls to IpcBitsOutLink_getEmptyBufs() to queue them wont work in new implementation. 

    You can refer our NVR implementation on usage of ipcBitsOut bit buffer management . Also, please read thro the App Note on IPC Bits Out to understand the changes wrt buffer management in latest release.

    For further debug,

    1. Check the issue with creation for ch 7.  

    2. Print the chId (ringBufId) & also call RingBufferPrintInfo() whenever "Writer: Acquire already done" print comes. This print comes from RingBufferWriterAcquire() routine.

     

    • VdecVdis_bitsRdSendFullBitBufs(&emptyBufList) execution will happen correctly if emptyBufList parameters are not already except for data filling / len update. Possible errors in IpcBitsOutLink_putFullBufs() will be logged which should give enough information.
  • Thanks for your suggest!

    And also I change RingBuf.c to make sure RingBuf is created and delete one by one.

    And I find it is OK.

     

  • Can you pls share what change you did in RingBuf.c. Multithread support is basic requirement and it should work without requiring any changes in your app. If it doesnt work it is a bug in dvrrdk. IpcBitsOutLink already has the correct locks and checks in place and it should never result in ringio getting created twice

  • Int32 RingBufferInit(RingBufferHandle_t *ringBufferHndl, Void *pBaseAddr, UInt32 size, Int32 chId)

    {
    Int32 status = RINGBUF_OK;

    memset(ringBufferHndl, 0, sizeof(*ringBufferHndl));
    ringBufferHndl->initDone = FALSE;

    ringBufferHndl->baseAddr = pBaseAddr;
    ringBufferHndl->usableSize = ringBufferHndl->totalSize = size;
    ringBufferHndl->rdReleaseLen = size;
    //ringBufferHndl->ringBufId = ringBufNum;
    ringBufferHndl->ringBufId = chId;
    ringBufNum++;

    status |= RingBufferCreateLock(&ringBufferHndl->lock);
    UTILS_assert(status == RINGBUF_OK);
    ringBufferHndl->initDone = (status == RINGBUF_OK) ? TRUE : FALSE;
    OSA_printf ("\r\n******* RingBuf %d created ********\n", ringBufferHndl->ringBufId);
    return status;
    }

    /**
    \brief Delete Ring Buffer

    \param ringBufferHndl [IN] Ring buffer handle to be terminated

    \return RINGBUF_OK on success
    */
    Int32 RingBufferDeInit(RingBufferHandle_t *ringBufferHndl, Int32 chId)
    {
    if (ringBufferHndl->initDone == TRUE)
    {
    RingBufferDeleteLock(&ringBufferHndl->lock);
    OSA_printf ("******* RingBuf %d deleted ********\n", ringBufferHndl->ringBufId);
    ringBufferHndl->initDone = FALSE;
    memset(ringBufferHndl, 0, sizeof(*ringBufferHndl));
    ringBufNum--;
    }
    return RINGBUF_OK;
    }

  • Was below line of code your bug fix:

    //ringBufferHndl->ringBufId = ringBufNum;
    ringBufferHndl->ringBufId = chId;

    The original code is surely wrong and the fix you have done is correct. Howevevr the ringBufId was used only for print purpose and that would have caused some wrong print such as same ring buffer created twice.

    I don't see how it would have caused the RingBuf "writer already acquired " warning which was the original issue you faced.

    Are you sure your issue is resolved with just above change.