viddec3test: close file descriptor created for input buffer
authorAmarinder Bindra <a-bindra@ti.com>
Thu, 13 Mar 2014 07:48:46 +0000 (13:18 +0530)
committerAmarinder Bindra <a-bindra@ti.com>
Thu, 20 Mar 2014 12:29:56 +0000 (17:59 +0530)
omap_bo_dmabuf creates a dup file descriptor for the caller to use
the buffers. The caller needs to explicitly close the dup fd to avoid
any fd leak. Adding the close of fd for the input buffer stream.

Signed-off-by: Amarinder Bindra <a-bindra@ti.com>
viddec3test.c

index cd915ba0052e7877048a2f92ee28822347fd860f..20fc252b2bf6f08004275c69914dc08f01b5e199 100644 (file)
@@ -89,7 +89,11 @@ decoder_close(struct decoder *decoder)
        if (decoder->status)         dce_free(decoder->status);
        if (decoder->params)         dce_free(decoder->params);
        if (decoder->dynParams)      dce_free(decoder->dynParams);
-       if (decoder->inBufs)         dce_free(decoder->inBufs);
+       if (decoder->inBufs) {
+               dce_buf_unlock(1, &(decoder->inBufs->descs[0].buf));
+               close(decoder->inBufs->descs[0].buf);
+               dce_free(decoder->inBufs);
+       }
        if (decoder->outBufs)        dce_free(decoder->outBufs);
        if (decoder->inArgs)         dce_free(decoder->inArgs);
        if (decoder->outArgs)        dce_free(decoder->outArgs);
@@ -275,6 +279,7 @@ decoder_open(int argc, char **argv)
        decoder->inBufs = dce_alloc(sizeof(XDM2_BufDesc));
        decoder->inBufs->numBufs = 1;
        decoder->inBufs->descs[0].buf = (XDAS_Int8 *)omap_bo_dmabuf(decoder->input_bo);
+       dce_buf_lock(1, &(decoder->inBufs->descs[0].buf));
        decoder->inBufs->descs[0].bufSize.bytes = omap_bo_size(decoder->input_bo);
        decoder->inBufs->descs[0].memType = XDM_MEMTYPE_RAW;