state_trackers/vdpau: Test if profile is supported first before trying to create...
authorMaarten Lankhorst <m.b.lankhorst@gmail.com>
Mon, 31 Oct 2011 09:26:02 +0000 (10:26 +0100)
committerChristian König <deathsimple@vodafone.de>
Thu, 3 Nov 2011 12:52:01 +0000 (13:52 +0100)
So a nicer error message is returned.

Signed-off-by: Maarten Lankhorst <m.b.lankhorst@gmail.com>
src/gallium/state_trackers/vdpau/decode.c

index 7689ce27793646e05b1c617e311bc0721dd085c9..2b23dfde9c55f10c57705ddd43c449c53c62f0c5 100644 (file)
@@ -43,15 +43,18 @@ vlVdpDecoderCreate(VdpDevice device,
 {
    enum pipe_video_profile p_profile;
    struct pipe_context *pipe;
+   struct pipe_screen *screen;
    vlVdpDevice *dev;
    vlVdpDecoder *vldecoder;
    VdpStatus ret;
    unsigned i;
+   bool supported;
 
    VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Creating decoder\n");
 
    if (!decoder)
       return VDP_STATUS_INVALID_POINTER;
+   *decoder = 0;
 
    if (!(width && height))
       return VDP_STATUS_INVALID_VALUE;
@@ -65,6 +68,15 @@ vlVdpDecoderCreate(VdpDevice device,
       return VDP_STATUS_INVALID_HANDLE;
 
    pipe = dev->context->pipe;
+   screen = dev->vscreen->pscreen;
+   supported = screen->get_video_param
+   (
+      screen,
+      p_profile,
+      PIPE_VIDEO_CAP_SUPPORTED
+   );
+   if (!supported)
+      return VDP_STATUS_INVALID_DECODER_PROFILE;
 
    vldecoder = CALLOC(1,sizeof(vlVdpDecoder));
    if (!vldecoder)