[Mesa-dev] [PATCH 4/7] st/vdpau: use a separate lock per decoder

Christian König deathsimple at vodafone.de
Mon Sep 23 06:58:50 PDT 2013


From: Christian König <christian.koenig at amd.com>

Signed-off-by: Christian König <christian.koenig at amd.com>
---
 src/gallium/state_trackers/vdpau/decode.c        | 20 +++++++++++---------
 src/gallium/state_trackers/vdpau/vdpau_private.h |  1 +
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/gallium/state_trackers/vdpau/decode.c b/src/gallium/state_trackers/vdpau/decode.c
index e884fb2..d741c79 100644
--- a/src/gallium/state_trackers/vdpau/decode.c
+++ b/src/gallium/state_trackers/vdpau/decode.c
@@ -130,6 +130,8 @@ vlVdpDecoderCreate(VdpDevice device,
       ret = VDP_STATUS_ERROR;
       goto error_handle;
    }
+
+   pipe_mutex_init(vldecoder->mutex);
    pipe_mutex_unlock(dev->mutex);
 
    return VDP_STATUS_OK;
@@ -155,9 +157,10 @@ vlVdpDecoderDestroy(VdpDecoder decoder)
    if (!vldecoder)
       return VDP_STATUS_INVALID_HANDLE;
 
-   pipe_mutex_lock(vldecoder->device->mutex);
+   pipe_mutex_lock(vldecoder->mutex);
    vldecoder->decoder->destroy(vldecoder->decoder);
-   pipe_mutex_unlock(vldecoder->device->mutex);
+   pipe_mutex_unlock(vldecoder->mutex);
+   pipe_mutex_destroy(vldecoder->mutex);
 
    vlRemoveDataHTAB(decoder);
    FREE(vldecoder);
@@ -477,8 +480,6 @@ vlVdpDecoderRender(VdpDecoder decoder,
       // TODO: Recreate decoder with correct chroma
       return VDP_STATUS_INVALID_CHROMA_TYPE;
 
-   pipe_mutex_lock(vlsurf->device->mutex);
-
    buffer_support[0] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
                                                PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE);
    buffer_support[1] = screen->get_video_param(screen, dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM,
@@ -489,6 +490,8 @@ vlVdpDecoderRender(VdpDecoder decoder,
                                           dec->profile, PIPE_VIDEO_ENTRYPOINT_BITSTREAM) ||
        !buffer_support[vlsurf->video_buffer->interlaced]) {
 
+      pipe_mutex_lock(vlsurf->device->mutex);
+
       /* destroy the old one */
       if (vlsurf->video_buffer)
          vlsurf->video_buffer->destroy(vlsurf->video_buffer);
@@ -510,6 +513,7 @@ vlVdpDecoderRender(VdpDecoder decoder,
          return VDP_STATUS_NO_IMPLEMENTATION;
       }
       vlVdpVideoSurfaceClear(vlsurf);
+      pipe_mutex_unlock(vlsurf->device->mutex);
    }
 
    for (i = 0; i < bitstream_buffer_count; ++i) {
@@ -535,18 +539,16 @@ vlVdpDecoderRender(VdpDecoder decoder,
       ret = vlVdpDecoderRenderH264(&desc.h264, (VdpPictureInfoH264 *)picture_info);
       break;
    default:
-      pipe_mutex_unlock(vlsurf->device->mutex);
       return VDP_STATUS_INVALID_DECODER_PROFILE;
    }
 
-   if (ret != VDP_STATUS_OK) {
-      pipe_mutex_unlock(vlsurf->device->mutex);
+   if (ret != VDP_STATUS_OK)
       return ret;
-   }
 
+   pipe_mutex_lock(vldecoder->mutex);
    dec->begin_frame(dec, vlsurf->video_buffer, &desc.base);
    dec->decode_bitstream(dec, vlsurf->video_buffer, &desc.base, bitstream_buffer_count, buffers, sizes);
    dec->end_frame(dec, vlsurf->video_buffer, &desc.base);
-   pipe_mutex_unlock(vlsurf->device->mutex);
+   pipe_mutex_unlock(vldecoder->mutex);
    return ret;
 }
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 54545fe..0812767 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -387,6 +387,7 @@ typedef struct
 typedef struct
 {
    vlVdpDevice *device;
+   pipe_mutex mutex;
    struct pipe_video_codec *decoder;
 } vlVdpDecoder;
 
-- 
1.8.1.2



More information about the mesa-dev mailing list