[libbluray-devel] _bd_read(): move check outside of read loop

hpi1 git at videolan.org
Thu Mar 10 11:48:37 CET 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Mar  9 13:23:09 2016 +0200| [51b1c068f2f2768b4b9f690033541069aed70724] | committer: hpi1

_bd_read(): move check outside of read loop

It could be triggered only at clip boundary, and is already checked there.

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=51b1c068f2f2768b4b9f690033541069aed70724
---

 src/libbluray/bluray.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index 98cf105..9aba36d 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1885,6 +1885,14 @@ static int _bd_read(BLURAY *bd, unsigned char *buf, int len)
         out_len = 0;
         BD_DEBUG(DBG_STREAM, "Reading [%d bytes] at %"PRIu64"...\n", len, bd->s_pos);
 
+        if (st->clip == NULL) {
+            // We previously reached the last clip.  Nothing
+            // else to read.
+            _queue_event(bd, BD_EVENT_END_OF_TITLE, 0);
+            bd->end_of_playlist |= 1;
+            return 0;
+        }
+
         while (len > 0) {
             uint32_t clip_pkt;
 
@@ -1913,13 +1921,6 @@ static int _bd_read(BLURAY *bd, unsigned char *buf, int len)
                     }
                 }
             }
-            if (st->clip == NULL) {
-                // We previously reached the last clip.  Nothing
-                // else to read.
-                _queue_event(bd, BD_EVENT_END_OF_TITLE, 0);
-                bd->end_of_playlist |= 1;
-                return 0;
-            }
             if (st->int_buf_off == 6144 || clip_pkt >= st->clip->end_pkt) {
 
                 // Do we need to get the next clip?



More information about the libbluray-devel mailing list