Commit da324c9a authored by hpi1's avatar hpi1

split bd_open()

parent 9bf8997a
......@@ -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;
}
......
......@@ -285,7 +285,6 @@ typedef struct bd_sound_effect {
*/
void bd_get_version(int *major, int *minor, int *micro);
/*
* Disc functions
*/
......@@ -293,12 +292,33 @@ 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
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment