[libdvdcss-devel] Patches for libdvdcss

Evgeny Grin karlson2k at kodi.tv
Tue Nov 18 00:02:51 CET 2014


OK.
Is it acceptable?
Can't send by git send-email (not working on win32)

>From d1f857ab8ab811a4d63907a8805ad42fea170bb1 Mon Sep 17 00:00:00 2001
From: Evgeny Grin <karlson2k at kodi.tv>
Date: Tue, 18 Nov 2014 00:51:44 +0300
Subject: [PATCH 1/2] fix position after partial read in libc_read

---
 src/device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/device.c b/src/device.c
index da4ecc4..94f448d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -570,10 +570,11 @@ static int libc_read ( dvdcss_t dvdcss, void
*p_buffer, int i_blocks )
     /* Handle partial reads */
     if( i_ret != i_size )
     {
-        int i_seek;
+        int i_seek, i_set_pos;

+        i_set_pos = dvdcss->i_pos + i_ret_blocks;
         dvdcss->i_pos = -1;
-        i_seek = libc_seek( dvdcss, i_ret_blocks );
+        i_seek = libc_seek( dvdcss, i_set_pos );
         if( i_seek < 0 )
         {
             return i_seek;
-- 
2.1.0.9738.g8768113


>From e68bdef901ce2c7f52f0912edb822d3e3a1c8c6d Mon Sep 17 00:00:00 2001
From: Evgeny Grin <karlson2k at kodi.tv>
Date: Tue, 18 Nov 2014 01:09:12 +0300
Subject: [PATCH 2/2] better handle partial read in libc_read

---
 src/device.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/device.c b/src/device.c
index 94f448d..ef26768 100644
--- a/src/device.c
+++ b/src/device.c
@@ -556,13 +556,23 @@ static int libc_read ( dvdcss_t dvdcss, void
*p_buffer, int i_blocks )
     ssize_t i_size, i_ret, i_ret_blocks;

     i_size = i_blocks * DVDCSS_BLOCK_SIZE;
-    i_ret = read( dvdcss->i_fd, p_buffer, i_size );
+    i_ret = 0;

-    if( i_ret < 0 )
+    while( i_ret < i_size )
     {
-        print_error( dvdcss, "read error" );
-        dvdcss->i_pos = -1;
-        return i_ret;
+        ssize_t i_r;
+
+        i_r = read( dvdcss->i_read_fd, ((char*)p_buffer) + i_ret, i_size -
i_ret );
+        if( i_r < 0 )
+        {
+            print_error( dvdcss, "read error" );
+            dvdcss->i_pos = -1;
+            return i_r;
+        }
+        if( i_r == 0 )
+            break;
+
+        i_ret += i_r;
     }

     i_ret_blocks = i_ret / DVDCSS_BLOCK_SIZE;
-- 
2.1.0.9738.g8768113


On 18 November 2014 01:34, Diego Biurrun <diego at biurrun.de> wrote:

> These are not the type of Git patch we are looking for.  Properly commit
> your changes and use git-format-patch or git-send-email please, not just
> git-diff.
>
> On Tue, Nov 18, 2014 at 01:22:11AM +0300, Evgeny Grin wrote:
> > No problem:
> >
> > fix position after partial read in libc_read
> >
> > diff --git a/src/device.c b/src/device.c
> > index da4ecc4..94f448d 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -570,10 +570,11 @@ static int libc_read ( dvdcss_t dvdcss, void
> *p_buffer, int i_blocks )
> >      /* Handle partial reads */
> >      if( i_ret != i_size )
> >      {
> > -        int i_seek;
> > +        int i_seek, i_set_pos;
> >
> > +        i_set_pos = dvdcss->i_pos + i_ret_blocks;
> >          dvdcss->i_pos = -1;
> > -        i_seek = libc_seek( dvdcss, i_ret_blocks );
> > +        i_seek = libc_seek( dvdcss, i_set_pos );
> >          if( i_seek < 0 )
> >          {
> >              return i_seek;
> >
> > fix position after partial read in libc_read
> >
> > diff --git a/src/device.c b/src/device.c
> > index 94f448d..ef26768 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -556,13 +556,23 @@ static int libc_read ( dvdcss_t dvdcss, void
> *p_buffer, int i_blocks )
> >      ssize_t i_size, i_ret, i_ret_blocks;
> >
> >      i_size = i_blocks * DVDCSS_BLOCK_SIZE;
> > -    i_ret = read( dvdcss->i_fd, p_buffer, i_size );
> > +    i_ret = 0;
> >
> > -    if( i_ret < 0 )
> > +    while( i_ret < i_size )
> >      {
> > -        print_error( dvdcss, "read error" );
> > -        dvdcss->i_pos = -1;
> > -        return i_ret;
> > +        ssize_t i_r;
> > +
> > +        i_r = read( dvdcss->i_read_fd, ((char*)p_buffer) + i_ret,
> i_size - i_ret );
> > +        if( i_r < 0 )
> > +        {
> > +            print_error( dvdcss, "read error" );
> > +            dvdcss->i_pos = -1;
> > +            return i_r;
> > +        }
> > +        if( i_r == 0 )
> > +            break;
> > +
> > +        i_ret += i_r;
> >      }
> >
> >      i_ret_blocks = i_ret / DVDCSS_BLOCK_SIZE;
> >
> > 18.11.2014, 00:04, "Diego Biurrun" <diego at biurrun.de>:
> > >  On Mon, Nov 17, 2014 at 11:42:43PM +0300, Evgeny Grin wrote:
> > >>   Here are the patches (made for 1.2.13, but applicable for latest
> git master):
> > >  Please use Git to create patches, thank you.
> > >
> > >  Diego
> > >  _______________________________________________
> > >  libdvdcss-devel mailing list
> > >  libdvdcss-devel at videolan.org
> > >  https://mailman.videolan.org/listinfo/libdvdcss-devel
> > -------- Завершение пересылаемого сообщения --------
> >
> > --
> > Best Wishes,
> > Evgeny Grin
> > _______________________________________________
> > libdvdcss-devel mailing list
> > libdvdcss-devel at videolan.org
> > https://mailman.videolan.org/listinfo/libdvdcss-devel
> _______________________________________________
> libdvdcss-devel mailing list
> libdvdcss-devel at videolan.org
> https://mailman.videolan.org/listinfo/libdvdcss-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/libdvdcss-devel/attachments/20141118/5cffeb83/attachment.html>


More information about the libdvdcss-devel mailing list