[libbluray-devel] [Git][videolan/libbluray][master] 4 commits: Fix mark triggering when multiple marks are passed during single read()

Petri Hintukainen gitlab at videolan.org
Wed Apr 17 11:06:41 CEST 2019



Petri Hintukainen pushed to branch master at VideoLAN / libbluray


Commits:
510df906 by hpi1 at 2019-04-17T08:07:56Z
Fix mark triggering when multiple marks are passed during single read()

- - - - -
5b3c09b5 by hpi1 at 2019-04-17T08:09:33Z
Cosmetics

- - - - -
e82e2430 by hpi1 at 2019-04-17T08:56:53Z
Split function. Fixes mark tracking timings at clip boundaries.

- - - - -
109bbb00 by hpi1 at 2019-04-17T08:57:45Z
properties: open file as binary.

May fix Windows issues.

- - - - -


2 changed files:

- src/libbluray/bluray.c
- src/libbluray/disc/properties.c


Changes:

=====================================
src/libbluray/bluray.c
=====================================
@@ -1579,19 +1579,23 @@ static void _find_next_playmark(BLURAY *bd)
 
 static void _playmark_reached(BLURAY *bd)
 {
-    BD_DEBUG(DBG_BLURAY, "PlayMark %d reached (%"PRIu64")\n", bd->next_mark, bd->next_mark_pos);
+    while (bd->next_mark >= 0 && bd->s_pos > bd->next_mark_pos) {
 
-    _queue_event(bd, BD_EVENT_PLAYMARK, bd->next_mark);
-    _bdj_event(bd, BDJ_EVENT_MARK, bd->next_mark);
+        BD_DEBUG(DBG_BLURAY, "PlayMark %d reached (%"PRIu64")\n", bd->next_mark, bd->next_mark_pos);
 
-    /* update next mark */
-    bd->next_mark++;
-    if ((unsigned)bd->next_mark < bd->title->mark_list.count) {
-        bd->next_mark_pos = (uint64_t)bd->title->mark_list.mark[bd->next_mark].title_pkt * 192L;
-    } else {
-        bd->next_mark = -1;
-        bd->next_mark_pos = (uint64_t)-1;
-    }
+        _queue_event(bd, BD_EVENT_PLAYMARK, bd->next_mark);
+        _bdj_event(bd, BDJ_EVENT_MARK, bd->next_mark);
+
+        /* update next mark */
+        bd->next_mark++;
+        if ((unsigned)bd->next_mark < bd->title->mark_list.count) {
+            bd->next_mark_pos = (uint64_t)bd->title->mark_list.mark[bd->next_mark].title_pkt * 192L;
+        } else {
+            /* no marks left */
+            bd->next_mark = -1;
+            bd->next_mark_pos = (uint64_t)-1;
+        }
+    };
 
     /* chapter tracking */
     _update_chapter_psr(bd);
@@ -1908,19 +1912,7 @@ static int64_t _clip_seek_time(BLURAY *bd, uint32_t tick)
 static int _bd_read(BLURAY *bd, unsigned char *buf, int len)
 {
     BD_STREAM *st = &bd->st0;
-    int out_len;
-
-    if (st->fp) {
-        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;
-        }
+    int out_len = 0;
 
         while (len > 0) {
             uint32_t clip_pkt;
@@ -2054,18 +2046,38 @@ static int _bd_read(BLURAY *bd, unsigned char *buf, int len)
             bd->s_pos += size;
         }
 
-        /* mark tracking */
-        if (bd->next_mark >= 0 && bd->s_pos > bd->next_mark_pos) {
-            _playmark_reached(bd);
-        }
-
         BD_DEBUG(DBG_STREAM, "%d bytes read OK!\n", out_len);
         return out_len;
+}
+
+static int _bd_read_locked(BLURAY *bd, unsigned char *buf, int len)
+{
+    BD_STREAM *st = &bd->st0;
+    int r;
+
+    if (!st->fp) {
+        BD_DEBUG(DBG_STREAM | DBG_CRIT, "bd_read(): no valid title selected!\n");
+        return -1;
     }
 
-    BD_DEBUG(DBG_STREAM | DBG_CRIT, "bd_read(): no valid title selected!\n");
+    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;
+    }
 
-    return -1;
+    BD_DEBUG(DBG_STREAM, "Reading [%d bytes] at %"PRIu64"...\n", len, bd->s_pos);
+
+    r = _bd_read(bd, buf, len);
+
+    /* mark tracking */
+    if (bd->next_mark >= 0 && bd->s_pos > bd->next_mark_pos) {
+        _playmark_reached(bd);
+    }
+
+    return r;
 }
 
 int bd_read(BLURAY *bd, unsigned char *buf, int len)
@@ -2073,7 +2085,7 @@ int bd_read(BLURAY *bd, unsigned char *buf, int len)
     int result;
 
     bd_mutex_lock(&bd->mutex);
-    result = _bd_read(bd, buf, len);
+    result = _bd_read_locked(bd, buf, len);
     bd_mutex_unlock(&bd->mutex);
 
     return result;
@@ -3544,7 +3556,7 @@ static int _read_ext(BLURAY *bd, unsigned char *buf, int len, BD_EVENT *event)
         }
     }
 
-    int bytes = _bd_read(bd, buf, len);
+    int bytes = _bd_read_locked(bd, buf, len);
 
     if (bytes == 0) {
 


=====================================
src/libbluray/disc/properties.c
=====================================
@@ -60,7 +60,7 @@ static int _read_prop_file(const char *file, char **data)
         return 0;
     }
 
-    fp = file_open(file, "rt");
+    fp = file_open(file, "rb");
     if (!fp) {
         goto unlink;
     }
@@ -114,7 +114,7 @@ static int _write_prop_file(const char *file, const char *data)
         return -1;
     }
 
-    fp = file_open(file, "wt");
+    fp = file_open(file, "wb");
     if (!fp) {
         return -1;
     }



View it on GitLab: https://code.videolan.org/videolan/libbluray/compare/a1869cb4a18b12f4c5a1bb6b69f8b0da24c28f73...109bbb00895a656ea9d85064b6cb61bd1271e37a

-- 
View it on GitLab: https://code.videolan.org/videolan/libbluray/compare/a1869cb4a18b12f4c5a1bb6b69f8b0da24c28f73...109bbb00895a656ea9d85064b6cb61bd1271e37a
You're receiving this email because of your account on code.videolan.org.



More information about the libbluray-devel mailing list