[VDPAU] [PATCH] Add a special check for the Opera browser

Robert Morell rmorell at nvidia.com
Thu Dec 5 11:05:41 PST 2013


On Thu, Dec 05, 2013 at 08:47:53AM -0800, Jeroen Roovers wrote:
> Let me try again. This time we just check specially for Opera and do
> some magic in /proc/self/maps only then. Checked with Opera (naturally)
> as well as Firefox, Chrome and Seamonkey.
>
> ---
>  src/vdpau_wrapper.c | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/src/vdpau_wrapper.c b/src/vdpau_wrapper.c
> index 9932937..c2eff15 100644
> --- a/src/vdpau_wrapper.c
> +++ b/src/vdpau_wrapper.c
> @@ -301,12 +301,14 @@ static void init_running_under_flash(void)
>  {
>      FILE *fp;
>      char buffer[1024];
> -    int ret, i;
> +    int _running_under_opera = 0, ret, i;
>  
> +    /* Check for processes that list libflashplayer in argv() */
>      fp = fopen("/proc/self/cmdline", "r");
>      if (!fp) {
>          return;
>      }
> +
>      ret = fread(buffer, 1, sizeof(buffer) - 1, fp);
>      fclose(fp);
>      if (ret < 0) {
> @@ -323,9 +325,32 @@ static void init_running_under_flash(void)
>      }
>      buffer[ret] = '\0';
>  

I think this is a good apprach, but it would be clearer to restructure
this.  I would suggest:

- Leave the libflashplayer check first; if it succeeds, then you're done.
- Otherwise, check for operapluginwrapper; if that string is present,
  then call a separate static function which opens /proc/self/maps and
  checks for libflashplayer there.

Something like this:

    if (strstr(buffer, "libflashplayer") != NULL) {
        _running_under_flash = 1;
    } else if (strstr(buffer, "operapluginwrapper") != NULL) {
        if (libflash_is_mapped()) {
            _running_under_flash = 1;
        }
    }
}

where there is a function called:
static int libflash_is_mapped(void);
that returns 1 if it find libflashplayer in /proc/self/maps, and 0
otherwise.

- Robert

> +    if (strstr(buffer, "operapluginwrapper") != NULL) {
> +        _running_under_opera = 1;
> +    }
>      if (strstr(buffer, "libflashplayer") != NULL) {
>          _running_under_flash = 1;
>      }
> +
> +    if(!_running_under_opera) {
> +        return;
> +    }
> +    
> +    /* Check for operapluginwrapper which does not list libflashplayer
> in argv()
> +     * Check maps instead */
> +    fp = fopen("/proc/self/maps", "r");
> +    if (!fp) {
> +        return;
> +    }
> +
> +    while(fgets(buffer, sizeof(buffer), fp)) {
> +        if (strstr(buffer, "libflashplayer") != NULL) {
> +            _running_under_flash = 1;
> +            break;
> +        }
> +    }
> +
> +    fclose(fp);
>  }
>  
>  static void init_config(void)
> -- 
> 1.8.3.2
> 
> _______________________________________________
> VDPAU mailing list
> VDPAU at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/vdpau
> 


More information about the VDPAU mailing list