vdpau: implement and cleanup PresentationQueueTarget destruction
authorChristian König <deathsimple@vodafone.de>
Mon, 25 Apr 2011 09:39:41 +0000 (11:39 +0200)
committerChristian König <deathsimple@vodafone.de>
Mon, 25 Apr 2011 09:39:41 +0000 (11:39 +0200)
src/gallium/state_trackers/vdpau/device.c
src/gallium/state_trackers/vdpau/htab.c
src/gallium/state_trackers/vdpau/presentation.c
src/gallium/state_trackers/vdpau/vdpau_private.h

index 7906757ec1b12c206e7f8b2e337d46213f82c48c..b3de0f29305075de82a1cfd166d3b99fb1359a1c 100644 (file)
 
 #include <pipe/p_compiler.h>
 #include <pipe/p_video_context.h>
-#include <vl_winsys.h>
+
 #include <util/u_memory.h>
 #include <util/u_debug.h>
+
+#include <vl_winsys.h>
+
 #include "vdpau_private.h"
 
 PUBLIC VdpStatus
@@ -94,8 +97,8 @@ PUBLIC VdpStatus
 vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
                                       VdpPresentationQueueTarget *target)
 {
-   VdpStatus    ret;
-   vlVdpPresentationQueueTarget *pqt = NULL;
+   vlVdpPresentationQueueTarget *pqt;
+   VdpStatus ret;
 
    debug_printf("[VDPAU] Creating PresentationQueueTarget\n");
 
@@ -122,10 +125,27 @@ vlVdpPresentationQueueTargetCreateX11(VdpDevice device, Drawable drawable,
    return VDP_STATUS_OK;
 
 no_handle:
-   FREE(dev);
+   FREE(pqt);
    return ret;
 }
 
+VdpStatus
+vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
+{
+   vlVdpPresentationQueueTarget *pqt;
+
+   debug_printf("[VDPAU] Destroying PresentationQueueTarget\n");
+
+   pqt = vlGetDataHTAB(presentation_queue_target);
+   if (!pqt)
+      return VDP_STATUS_INVALID_HANDLE;
+
+   vlRemoveDataHTAB(presentation_queue_target);
+   FREE(pqt);
+
+   return VDP_STATUS_OK;
+}
+
 VdpStatus
 vlVdpDeviceDestroy(VdpDevice device)
 {
@@ -134,6 +154,7 @@ vlVdpDeviceDestroy(VdpDevice device)
    vlVdpDevice *dev = vlGetDataHTAB(device);
    if (!dev)
       return VDP_STATUS_INVALID_HANDLE;
+
    FREE(dev);
    vlDestroyHTAB();
 
index 0c9580553748b14b152a208d1d5c79c1aa40d448..20f5a171f1962ad9cf7125c6091418030b571bce 100644 (file)
@@ -92,3 +92,13 @@ void* vlGetDataHTAB(vlHandle handle)
    return (void*)handle;
 #endif
 }
+
+void vlRemoveDataHTAB(vlHandle handle)
+{
+#ifdef VL_HANDLES
+   pipe_mutex_lock(htab_lock);
+   if (htab)
+      handle_table_remove(htab, handle);
+   pipe_mutex_unlock(htab_lock);
+#endif
+}
index 063c63fb4ee773fdf75d194562f7b75e531e842f..2837e7a306f5c7f7201c3cb79d6f1e6cc4fa613a 100644 (file)
 
 #include <stdio.h>
 
-#include "vdpau_private.h"
 #include <vdpau/vdpau.h>
+
 #include <util/u_debug.h>
 #include <util/u_memory.h>
 
-VdpStatus
-vlVdpPresentationQueueTargetDestroy(VdpPresentationQueueTarget presentation_queue_target)
-{
-   return VDP_STATUS_NO_IMPLEMENTATION;
-}
+#include "vdpau_private.h"
 
 VdpStatus
 vlVdpPresentationQueueCreate(VdpDevice device,
index bd77507567f2a40e51eae75290c6772dbacdf429..ac1f9ccef99c38bf9fdd3ce9fdca3f628fee6d2a 100644 (file)
@@ -222,6 +222,8 @@ boolean vlCreateHTAB(void);
 void vlDestroyHTAB(void);
 vlHandle vlAddDataHTAB(void *data);
 void* vlGetDataHTAB(vlHandle handle);
+void vlRemoveDataHTAB(vlHandle handle);
+
 boolean vlGetFuncFTAB(VdpFuncId function_id, void **func);
 
 /* Public functions */