[libbluray-devel] psr_init_3D: bail out if profile 5 or 6 already set

hpi1 git at videolan.org
Tue Sep 19 11:00:29 CEST 2017


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Sep 19 11:51:44 2017 +0300| [b5e30fca591978aeed447dab92a5e0f896ac487e] | committer: Petri Hintukainen

psr_init_3D: bail out if profile 5 or 6 already set

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

 src/libbluray/register.c | 18 +++++++++++++++++-
 src/libbluray/register.h |  2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/register.c b/src/libbluray/register.c
index f44c171b..34c44f4c 100644
--- a/src/libbluray/register.c
+++ b/src/libbluray/register.c
@@ -534,10 +534,24 @@ void registers_restore(BD_REGISTERS *p, const uint32_t *psr, const uint32_t *gpr
  *
  */
 
-void psr_init_3D(BD_REGISTERS *p, int initial_mode)
+int psr_init_3D(BD_REGISTERS *p, int initial_mode, int force)
 {
     bd_psr_lock(p);
 
+    /* make automatic initialization to fail if app has already changed player profile */
+    if (!force) {
+        if ((bd_psr_read(p, PSR_PROFILE_VERSION) & BLURAY_PLAYER_PROFILE_VERSION_MASK) >= 0x0300) {
+            BD_DEBUG(DBG_BLURAY | DBG_CRIT, "psr_init_3D() failed: profile version already set to >= 0x0300 (profile 6)\n");
+            bd_psr_unlock(p);
+            return -1;
+        }
+        if (bd_psr_read(p, PSR_PROFILE_VERSION) & BLURAY_PLAYER_PROFILE_3D_FLAG) {
+            BD_DEBUG(DBG_BLURAY | DBG_CRIT, "psr_init_3D() failed: 3D already set in profile\n");
+            bd_psr_unlock(p);
+            return -1;
+        }
+    }
+
     bd_psr_setting_write(p, PSR_OUTPUT_PREFER,
                          BLURAY_OUTPUT_PREFER_3D);
 
@@ -558,6 +572,8 @@ void psr_init_3D(BD_REGISTERS *p, int initial_mode)
                  !!initial_mode);
 
     bd_psr_unlock(p);
+
+    return 0;
 }
 
 int psr_init_UHD(BD_REGISTERS *p, int force)
diff --git a/src/libbluray/register.h b/src/libbluray/register.h
index ddb04569..8757818b 100644
--- a/src/libbluray/register.h
+++ b/src/libbluray/register.h
@@ -267,7 +267,7 @@ void bd_psr_register_cb(BD_REGISTERS *, void (*callback)(void*,BD_PSR_EVENT*), v
  */
 void bd_psr_unregister_cb(BD_REGISTERS *, void (*callback)(void*,BD_PSR_EVENT*), void *cb_handle);
 
-BD_PRIVATE void psr_init_3D(BD_REGISTERS *, int initial_mode);
+BD_PRIVATE int psr_init_3D(BD_REGISTERS *, int initial_mode, int force);
 
 /**
  *



More information about the libbluray-devel mailing list