[libbluray-devel] split bd_open()
hpi1
git at videolan.org
Fri Mar 20 14:10:34 CET 2015
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Mar 20 14:46:19 2015 +0200| [da324c9abc045e3059936ef2dcb620fdc7ceb5b1] | committer: hpi1
split bd_open()
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=da324c9abc045e3059936ef2dcb620fdc7ceb5b1
---
src/libbluray/bluray.c | 48 ++++++++++++++++++++++++++++++++++++++----------
src/libbluray/bluray.h | 24 ++++++++++++++++++++++--
2 files changed, 60 insertions(+), 12 deletions(-)
diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
index e05b61d..738c0ec 100644
--- a/src/libbluray/bluray.c
+++ b/src/libbluray/bluray.c
@@ -1275,17 +1275,10 @@ static void _storage_free(BLURAY *bd)
* open / close
*/
-BLURAY *bd_open(const char *device_path, const char *keyfile_path)
+BLURAY *bd_init(void)
{
- BD_ENC_INFO enc_info;
-
BD_DEBUG(DBG_BLURAY, "libbluray version "BLURAY_VERSION_STRING"\n");
- if (!device_path) {
- BD_DEBUG(DBG_BLURAY | DBG_CRIT, "No device path provided!\n");
- return NULL;
- }
-
BLURAY *bd = calloc(1, sizeof(BLURAY));
if (!bd) {
@@ -1305,17 +1298,52 @@ BLURAY *bd_open(const char *device_path, const char *keyfile_path)
bd_mutex_init(&bd->argb_buffer_mutex);
#endif
+ BD_DEBUG(DBG_BLURAY, "BLURAY initialized!\n");
+
+ return bd;
+}
+
+int bd_open_disc(BLURAY *bd, const char *device_path, const char *keyfile_path)
+{
+ BD_ENC_INFO enc_info;
+
+ if (!bd) {
+ return 0;
+ }
+
+ if (!device_path) {
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "No device path provided!\n");
+ return 0;
+ }
+
+ if (bd->disc) {
+ BD_DEBUG(DBG_BLURAY | DBG_CRIT, "Disc already open\n");
+ return 0;
+ }
+
bd->disc = disc_open(device_path,
&enc_info, keyfile_path,
(void*)bd->regs, (void*)bd_psr_read, (void*)bd_psr_write);
if (!bd->disc) {
- return bd;
+ return 0;
}
_fill_disc_info(bd, &enc_info);
- BD_DEBUG(DBG_BLURAY, "BLURAY initialized!\n");
+ return bd->disc_info.bluray_detected;
+}
+
+BLURAY *bd_open(const char *device_path, const char *keyfile_path)
+{
+ BLURAY *bd;
+
+ bd = bd_init();
+ if (!bd) {
+ return NULL;
+ }
+
+ bd_open_disc(bd, device_path, keyfile_path);
return bd;
}
diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
index c089d07..c4e4b9d 100644
--- a/src/libbluray/bluray.h
+++ b/src/libbluray/bluray.h
@@ -285,7 +285,6 @@ typedef struct bd_sound_effect {
*/
void bd_get_version(int *major, int *minor, int *micro);
-
/*
* Disc functions
*/
@@ -293,13 +292,34 @@ void bd_get_version(int *major, int *minor, int *micro);
/**
* Open BluRay disc
*
- * @param device_path path to mounted Blu-ray disc or device
+ * Shortcut for bd_open_disc(bd_init(), device_path, keyfile_path)
+ *
+ * @param device_path path to mounted Blu-ray disc, device or image file
* @param keyfile_path path to KEYDB.cfg (may be NULL)
* @return allocated BLURAY object, NULL if error
*/
BLURAY *bd_open(const char *device_path, const char *keyfile_path);
/**
+ * Initialize BLURAY object
+ *
+ * Resulting object can be passed to following bd_open_??? functions.
+ *
+ * @return allocated BLURAY object, NULL if error
+ */
+BLURAY *bd_init(void);
+
+/**
+ * Open BluRay disc
+ *
+ * @param bd BLURAY object
+ * @param device_path path to mounted Blu-ray disc, device or image file
+ * @param keyfile_path path to KEYDB.cfg (may be NULL)
+ * @return 1 on success, 0 if error
+ */
+int bd_open_disc(BLURAY *bd, const char *device_path, const char *keyfile_path);
+
+/**
* Close BluRay disc
*
* @param bd BLURAY object
More information about the libbluray-devel
mailing list