[VDPAU] [PATCH] Remove Adobe Flash bug workarounds

Stephen Warren swarren at wwwdotorg.org
Wed Dec 16 21:11:20 UTC 2020


From: Stephen Warren <swarren at nvidia.com>

Adobe has announced the End Of Life for Flash, and will soon block its
use: https://www.adobe.com/products/flashplayer/end-of-life.html.
Consequently, the libvdpau wrapper library no longer needs to maintain
bug workarounds for Adobe Flash, so remove them.
---
Note: I have compiled this patch, but not actually tested it at runtime.

 meson.build           |   2 -
 src/meson.build       |   2 -
 src/vdpau_wrapper.c   | 187 +-----------------------------------------
 src/vdpau_wrapper.cfg |   2 -
 4 files changed, 1 insertion(+), 192 deletions(-)
 delete mode 100644 src/vdpau_wrapper.cfg

diff --git a/meson.build b/meson.build
index afe865dae48c..9eb49924f48b 100644
--- a/meson.build
+++ b/meson.build
@@ -6,11 +6,9 @@ moduledir = get_option('moduledir')
 if moduledir == ''
     moduledir = join_paths(libdir, 'vdpau')
 endif
-sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'))
 
 cdata = configuration_data()
 cdata.set_quoted('VDPAU_MODULEDIR', moduledir)
-cdata.set_quoted('VDPAU_SYSCONFDIR', sysconfdir)
 cdata.set_quoted('VDPAU_DOC_PATH', meson.current_source_dir())
 cdata.set_quoted('VDPAU_HEADER_PATH', join_paths(meson.source_root(), 'include'))
 
diff --git a/src/meson.build b/src/meson.build
index 9bb253a48f2a..b0971280fc52 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -15,5 +15,3 @@ vdpau = shared_library('vdpau',
     version : '1.0.0',
     install : true,
 )
-
-install_data('vdpau_wrapper.cfg', install_dir : get_option('sysconfdir'))
diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
index 79dcb94f966d..1c6e5f5e8712 100644
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -240,159 +240,6 @@ static void _vdp_close_driver(void)
     _vdp_imp_device_create_x11_proc = NULL;
 }
 
-static VdpGetProcAddress * _imp_get_proc_address;
-static VdpVideoSurfacePutBitsYCbCr * _imp_vid_put_bits_y_cb_cr;
-static VdpPresentationQueueSetBackgroundColor * _imp_pq_set_bg_color;
-static int _running_under_flash;
-static int _enable_flash_uv_swap = 1;
-static int _disable_flash_pq_bg_color = 1;
-
-static VdpStatus vid_put_bits_y_cb_cr_swapped(
-    VdpVideoSurface      surface,
-    VdpYCbCrFormat       source_ycbcr_format,
-    void const * const * source_data,
-    uint32_t const *     source_pitches
-)
-{
-    void const * data_reordered[3];
-    void const * const * data;
-
-    if (source_ycbcr_format == VDP_YCBCR_FORMAT_YV12) {
-        data_reordered[0] = source_data[0];
-        data_reordered[1] = source_data[2];
-        data_reordered[2] = source_data[1];
-        /*
-         * source_pitches[1] and source_pitches[2] should be equal,
-         * so no need to re-order.
-         */
-        data = data_reordered;
-    }
-    else {
-        data = source_data;
-    }
-
-    return _imp_vid_put_bits_y_cb_cr(
-        surface,
-        source_ycbcr_format,
-        data,
-        source_pitches
-    );
-}
-
-static VdpStatus pq_set_bg_color_noop(
-    VdpPresentationQueue presentation_queue,
-    VdpColor * const     background_color
-)
-{
-    (void) presentation_queue; (void) background_color;
-    return VDP_STATUS_OK;
-}
-
-static VdpStatus vdp_wrapper_get_proc_address(
-    VdpDevice device,
-    VdpFuncId function_id,
-    /* output parameters follow */
-    void * *  function_pointer
-)
-{
-    VdpStatus status;
-
-    status = _imp_get_proc_address(device, function_id, function_pointer);
-    if (status != VDP_STATUS_OK) {
-        return status;
-    }
-
-    if (_running_under_flash) {
-        switch (function_id) {
-        case VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR:
-            if (_enable_flash_uv_swap) {
-                _imp_vid_put_bits_y_cb_cr = *function_pointer;
-                *function_pointer = vid_put_bits_y_cb_cr_swapped;
-            }
-            break;
-        case VDP_FUNC_ID_PRESENTATION_QUEUE_SET_BACKGROUND_COLOR:
-            if (_disable_flash_pq_bg_color) {
-                _imp_pq_set_bg_color = *function_pointer;
-                *function_pointer = pq_set_bg_color_noop;
-            }
-            break;
-        default:
-            break;
-        }
-    }
-
-    return VDP_STATUS_OK;
-}
-
-static void init_running_under_flash(void)
-{
-    FILE *fp;
-    char buffer[1024];
-    int ret, i;
-
-    fp = fopen("/proc/self/cmdline", "r");
-    if (!fp) {
-        return;
-    }
-    ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
-    fclose(fp);
-    if (ret < 0) {
-        return;
-    }
-    /*
-     * Sometimes the file contains null between arguments. Wipe these out so
-     * strstr doesn't stop early.
-     */
-    for (i = 0; i < ret; i++) {
-        if (buffer[i] == '\0') {
-            buffer[i] = 'x';
-        }
-    }
-    buffer[ret] = '\0';
-
-    if (strstr(buffer, "libflashplayer") != NULL) {
-        _running_under_flash = 1;
-    }
-}
-
-static void init_config(void)
-{
-    FILE *fp;
-    char buffer[1024];
-
-    fp = fopen(VDPAU_SYSCONFDIR "/vdpau_wrapper.cfg", "r");
-    if (!fp) {
-        return;
-    }
-
-    while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-        char * equals = strchr(buffer, '=');
-        char * param;
-
-        if (equals == NULL) {
-            continue;
-        }
-
-        *equals = '\0';
-        param = equals + 1;
-
-        if (!strcmp(buffer, "enable_flash_uv_swap")) {
-            _enable_flash_uv_swap = atoi(param);
-        }
-        else if (!strcmp(buffer, "disable_flash_pq_bg_color")) {
-            _disable_flash_pq_bg_color = atoi(param);
-        }
-    }
-
-    fclose(fp);
-}
-
-static void init_fixes(void)
-{
-    init_running_under_flash();
-    init_config();
-}
-
 VdpStatus vdp_device_create_x11(
     Display *             display,
     int                   screen,
@@ -401,13 +248,9 @@ VdpStatus vdp_device_create_x11(
     VdpGetProcAddress * * get_proc_address
 )
 {
-    static pthread_once_t once = PTHREAD_ONCE_INIT;
     static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-    VdpGetProcAddress *gpa;
     VdpStatus status = VDP_STATUS_OK;
 
-    pthread_once(&once, init_fixes);
-
     pthread_mutex_lock(&lock);
     if (!_vdp_imp_device_create_x11_proc) {
         status = _vdp_open_driver(display, screen);
@@ -419,33 +262,5 @@ VdpStatus vdp_device_create_x11(
     if (status != VDP_STATUS_OK)
         return status;
 
-    status = _vdp_imp_device_create_x11_proc(display, screen, device, &gpa);
-    if (status != VDP_STATUS_OK) {
-        return status;
-    }
-
-    *get_proc_address = vdp_wrapper_get_proc_address;
-
-    pthread_mutex_lock(&lock);
-    if (_imp_get_proc_address != gpa) {
-        if (_imp_get_proc_address == NULL)
-            _imp_get_proc_address = gpa;
-        else
-        /* Currently the wrapper can only deal with one back-end.
-         * This should never happen, but better safe than sorry. */
-            status = VDP_STATUS_NO_IMPLEMENTATION;
-    }
-    pthread_mutex_unlock(&lock);
-
-    if (status != VDP_STATUS_OK) {
-        void *pv;
-
-        if (gpa(*device, VDP_FUNC_ID_DEVICE_DESTROY, &pv) == VDP_STATUS_OK) {
-            VdpDeviceDestroy *device_destroy = pv;
-
-            device_destroy(*device);
-        }
-    }
-
-    return status;
+    return _vdp_imp_device_create_x11_proc(display, screen, device, get_proc_address);
 }
diff --git a/src/vdpau_wrapper.cfg b/src/vdpau_wrapper.cfg
deleted file mode 100644
index 21d5b8c044bc..000000000000
--- a/src/vdpau_wrapper.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-enable_flash_uv_swap=1
-disable_flash_pq_bg_color=1
-- 
2.25.1



More information about the VDPAU mailing list