From 23300b0383286bf4628f679cbf7fccc65d713d9a Mon Sep 17 00:00:00 2001 From: Johns Date: Thu, 29 Dec 2011 00:55:57 +0100 Subject: [PATCH] Add missing VdpauDecoderDestroy. --- Todo | 2 ++ softhddev.c | 5 ++-- softhddevice.cpp | 2 +- video.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/Todo b/Todo index e92f99f..fb54979 100644 --- a/Todo +++ b/Todo @@ -10,6 +10,8 @@ missing: vdpau: 1080i with temporal spatial too slow GT 520 + VdpPreemptionCallback handling + Loose a surface libva-intel-driver: intel still has hangups most with 1080i diff --git a/softhddev.c b/softhddev.c index 040fae3..16bf21e 100644 --- a/softhddev.c +++ b/softhddev.c @@ -274,9 +274,9 @@ static void VideoEnqueue(int64_t pts, const void *data, int size) // new + grow reserves FF_INPUT_BUFFER_PADDING_SIZE av_grow_packet(avpkt, ((size + VIDEO_BUFFER_SIZE / 2) - / (VIDEO_BUFFER_SIZE / 2)) * (VIDEO_BUFFER_SIZE / 2)); + / (VIDEO_BUFFER_SIZE / 2)) * (VIDEO_BUFFER_SIZE / 2)); #ifdef DEBUG - if (avpkt->size <= avpkt->stream_index + size ) { + if (avpkt->size <= avpkt->stream_index + size) { abort(); } #endif @@ -888,6 +888,7 @@ void Stop(void) MyAudioDecoder = NULL; } + VideoOsdExit(); VideoExit(); AudioExit(); CodecExit(); diff --git a/softhddevice.cpp b/softhddevice.cpp index 9ebe0ca..e8b9679 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -39,7 +39,7 @@ extern "C" { ////////////////////////////////////////////////////////////////////////////// -static const char *const VERSION = "0.1.2"; +static const char *const VERSION = "0.1.3"; static const char *const DESCRIPTION = trNOOP("A software and GPU emulated HD device"); diff --git a/video.c b/video.c index 7d8af37..fad0f57 100644 --- a/video.c +++ b/video.c @@ -3211,9 +3211,10 @@ static void VdpauCreateSurfaces(VdpauDecoder * decoder, int width, int height) VdpauVideoSurfaceCreate(decoder->Device, decoder->ChromaType, width, height, decoder->SurfacesFree + i); if (status != VDP_STATUS_OK) { - Fatal(_("video/vdpau: can't create video surface: %s\n"), + Error(_("video/vdpau: can't create video surface: %s\n"), VdpauGetErrorString(status)); - // FIXME: no fatal + decoder->SurfacesFree[i] = VDP_INVALID_HANDLE; + // FIXME: better error handling } Debug(4, "video/vdpau: created video surface %dx%d with id 0x%08x\n", width, height, decoder->SurfacesFree[i]); @@ -3238,11 +3239,14 @@ static void VdpauDestroySurfaces(VdpauDecoder * decoder) Debug(3, "video/vdpau: invalid surface\n"); } #endif + Debug(4, "video/vdpau: destroy video surface with id 0x%08x\n", + decoder->SurfacesFree[i]); status = VdpauVideoSurfaceDestroy(decoder->SurfacesFree[i]); if (status != VDP_STATUS_OK) { Error(_("video/vdpau: can't destroy video surface: %s\n"), VdpauGetErrorString(status)); } + decoder->SurfacesFree[i] = VDP_INVALID_HANDLE; } for (i = 0; i < decoder->SurfaceUsedN; ++i) { #ifdef DEBUG @@ -3250,11 +3254,14 @@ static void VdpauDestroySurfaces(VdpauDecoder * decoder) Debug(3, "video/vdpau: invalid surface\n"); } #endif + Debug(4, "video/vdpau: destroy video surface with id 0x%08x\n", + decoder->SurfacesUsed[i]); status = VdpauVideoSurfaceDestroy(decoder->SurfacesUsed[i]); if (status != VDP_STATUS_OK) { Error(_("video/vdpau: can't destroy video surface: %s\n"), VdpauGetErrorString(status)); } + decoder->SurfacesUsed[i] = VDP_INVALID_HANDLE; } decoder->SurfaceFreeN = 0; decoder->SurfaceUsedN = 0; @@ -3517,6 +3524,15 @@ static void VdpauCleanup(VdpauDecoder * decoder) VdpStatus status; int i; + if (decoder->VideoDecoder != VDP_INVALID_HANDLE) { + status = VdpauDecoderDestroy(decoder->VideoDecoder); + if (status != VDP_STATUS_OK) { + Error(_("video/vdpau: can't destroy video decoder: %s\n"), + VdpauGetErrorString(status)); + } + decoder->VideoDecoder = VDP_INVALID_HANDLE; + } + if (decoder->VideoMixer != VDP_INVALID_HANDLE) { status = VdpauVideoMixerDestroy(decoder->VideoMixer); if (status != VDP_STATUS_OK) { @@ -3934,6 +3950,8 @@ static void VideoVdpauInit(const char *display_name) Fatal(_("video/vdpau: can't create output surface: %s\n"), VdpauGetErrorString(status)); } + Debug(3, "video/vdpau: created output surface %dx%d with id 0x%08x\n", + VideoWindowWidth, VideoWindowHeight, VdpauSurfacesRb[i]); } } @@ -3942,12 +3960,15 @@ static void VideoVdpauInit(const char *display_name) /// static void VideoVdpauExit(void) { + int i; + if (VdpauDecoders[0]) { VdpauDelDecoder(VdpauDecoders[0]); VdpauDecoders[0] = NULL; } if (VdpauDevice) { + if (VdpauQueue) { VdpauPresentationQueueDestroy(VdpauQueue); VdpauQueue = 0; @@ -3956,7 +3977,24 @@ static void VideoVdpauExit(void) VdpauPresentationQueueTargetDestroy(VdpauQueueTarget); VdpauQueueTarget = 0; } + // + // destroy display output surfaces + // + for (i = 0; i < OUTPUT_SURFACES_MAX; ++i) { + VdpStatus status; + + Debug(4, "video/vdpau: destroy output surface with id 0x%08x\n", + VdpauSurfacesRb[i]); + status = VdpauOutputSurfaceDestroy(VdpauSurfacesRb[i]); + if (status != VDP_STATUS_OK) { + Error(_("video/vdpau: can't destroy output surface: %s\n"), + VdpauGetErrorString(status)); + } + VdpauSurfacesRb[i] = VDP_INVALID_HANDLE; + } + // FIXME: more VDPAU cleanups... + if (VdpauDeviceDestroy) { VdpauDeviceDestroy(VdpauDevice); } @@ -5071,6 +5109,7 @@ static void VdpauOsdInit(int width, int height) if (!VdpauDevice) { Debug(3, "video/vdpau: vdpau not setup\n"); + return; } VdpauOsdWidth = width; @@ -5089,6 +5128,9 @@ static void VdpauOsdInit(int width, int height) Error(_("video/vdpau: can't create bitmap surface: %s\n"), VdpauGetErrorString(status)); } + Debug(4, + "video/vdpau: created bitmap surface %dx%d with id 0x%08x\n", + width, height, VdpauOsdBitmapSurface[i]); } } #else @@ -5101,6 +5143,9 @@ static void VdpauOsdInit(int width, int height) Error(_("video/vdpau: can't create output surface: %s\n"), VdpauGetErrorString(status)); } + Debug(4, + "video/vdpau: created osd output surface %dx%d with id 0x%08x\n", + width, height, VdpauOsdOutputSurface[i]); } } #endif @@ -5110,6 +5155,14 @@ static void VdpauOsdInit(int width, int height) VdpauOsdClear(); } +/** +** Cleanup osd. +*/ +static void VdpauOsdExit(void) +{ + Debug(3, "FIXME: %s\n", __FUNCTION__); +} + #endif //---------------------------------------------------------------------------- @@ -5264,6 +5317,25 @@ void VideoOsdInit(void) #endif } +/** +** Cleanup OSD. +*/ +void VideoOsdExit(void) +{ +#ifdef USE_VAAPI + if (VideoVaapiEnabled) { + // FIXME: VaapiOsdExit(); + return; + } +#endif +#ifdef USE_VDPAU + if (VideoVdpauEnabled) { + VdpauOsdExit(); + return; + } +#endif +} + #if 0 //----------------------------------------------------------------------------