[MPlayer-dev-eng] Performance of libdvdread/libdvdcss

Vicente Sendra visenri at yahoo.es
Sat Sep 1 11:20:05 CEST 2012


--- El vie, 31/8/12, Reimar Döffinger <Reimar.Doeffinger at gmx.de> escribió:

> De: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> Asunto: Re: [MPlayer-dev-eng] Performance of libdvdread/libdvdcss
> Para: mplayer-dev-eng at mplayerhq.hu
> Fecha: viernes, 31 de agosto, 2012 22:53
> On Fri, Aug 31, 2012 at 10:51:03PM
> +0200, Reimar Döffinger wrote:
> > On Fri, Aug 31, 2012 at 10:42:09PM +0200, Reimar
> Döffinger wrote:
> > > There is a special function to get a file
> descriptor from a handle.
> > > By using that one you should be able to replace
> the ReadFile calls by
> > > read() calls, and with a bit more effort even keep
> the whole
> > > open/authenticate code as is while using the
> standard libc read
> > > functions.
> > 
> > Sorry, I think that won't work since the function is
> _get_osf_handle
> > and it works the other way round.
> > You could try if replacing FILE_FLAG_RANDOM_ACCESS
> (appears at least in
> > device.c) with 0 or FILE_FLAG_SEQUENTIAL_SCAN makes a
> difference,
> > the latter one might behave badly e.g. while seeking
> though.
> 
> Embarrassing, second correction: There is _open_osfhandle
> and it could
> be used to try my original suggestion.

I did it and it just works, but it makes no difference, reading is slow.


In device .c in function win2kopen:

############################################

    dvdcss->i_fd = (int)
                CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
                            FILE_SHARE_READ | FILE_SHARE_WRITE,
                            NULL, OPEN_EXISTING,
                            FILE_FLAG_RANDOM_ACCESS, NULL );

    if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
        dvdcss->i_fd = (int)
                    CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
                                NULL, OPEN_EXISTING,
                                FILE_FLAG_RANDOM_ACCESS, NULL );

    if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
    {
        print_error( dvdcss, "failed opening device" );
        return -1;
    }else{
        dvdcss->i_read_fd = _open_osfhandle((intptr_t)dvdcss->i_fd,_O_RDONLY);
        if(dvdcss->i_read_fd == -1){
            print_error( dvdcss, "failed opening device with _open_osfhandle" );
            CloseHandle( (HANDLE) dvdcss->i_fd );
            return -1;
        }else{
            print_error( dvdcss, "success with _open_osfhandle" );
        }
    }


##############################################

In device .c in function in function _dvdcss_close:

##############################################
        close( dvdcss->i_fd );
        //CloseHandle( (HANDLE) dvdcss->i_fd );
##############################################


And changed function pointers in _dvdcss_open:

 ##############################################

        print_debug( dvdcss, "using Win2K API for access" );
        dvdcss->pf_seek  = libc_seek; // win2k_seek
        dvdcss->pf_read  = libc_read; // win2k_read
        dvdcss->pf_readv = libc_readv;// win_readv
        return win2k_open( dvdcss, psz_device );


 ##############################################


But we are doing things that we should not do, because we are using both functions with the os file handle (ioct) and functions with the C run-time file descriptor (read). And this is a bad thing if we read this:
http://support.microsoft.com/kb/99173/en-us

I'm going to try the mixed solution, reading with win2k, closing, then reading with libc with keys from win2k.





More information about the MPlayer-dev-eng mailing list