1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
From 918471a40f6ed9e8be9981e1f86ec6eaec139074 Mon Sep 17 00:00:00 2001
From: Voyager1 <voyager@xbmc.org>
Date: Sun, 14 Feb 2016 17:10:15 +0100
Subject: [PATCH 01/10] [xbmc][dvdnav] allow get/set vm state
---
src/dvdnav_internal.h | 12 +++++++++++
src/searching.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/vm/vm.c | 41 ++++++++++++++++++++++++++++++++++++
src/vm/vm.h | 3 +++
4 files changed, 114 insertions(+)
diff --git a/src/dvdnav_internal.h b/src/dvdnav_internal.h
index 534ccb8..6d936e9 100644
--- a/libdvdnav-5-0-3/src/dvdnav_internal.h
+++ b/libdvdnav-5-0-3/src/dvdnav_internal.h
@@ -222,6 +222,18 @@ struct dvdnav_s {
/* converts a dvd_time_t to PTS ticks */
int64_t dvdnav_convert_time(dvd_time_t *time);
+/* XBMC added functions */
+/*
+ * Get current playback state
+ */
+dvdnav_status_t dvdnav_get_state(dvdnav_t *this, dvd_state_t *save_state);
+
+/*
+ * Resume playback state
+ */
+dvdnav_status_t dvdnav_set_state(dvdnav_t *this, dvd_state_t *save_state);
+/* end XBMC */
+
/** USEFUL MACROS **/
#ifdef __GNUC__
diff --git a/src/searching.c b/src/searching.c
index f638b61..fd28fb3 100644
--- a/libdvdnav-5-0-3/src/searching.c
+++ b/libdvdnav-5-0-3/src/searching.c
@@ -731,6 +731,64 @@ fail:
return retval;
}
+dvdnav_status_t dvdnav_get_state(dvdnav_t *this, dvd_state_t *save_state)
+{
+ if (!this || !this->vm) return DVDNAV_STATUS_ERR;
+
+ pthread_mutex_lock(&this->vm_lock);
+
+ if (!vm_get_state(this->vm, save_state))
+ {
+ printerr("Failed to get vm state.");
+ pthread_mutex_unlock(&this->vm_lock);
+ return DVDNAV_STATUS_ERR;
+ }
+
+ pthread_mutex_unlock(&this->vm_lock);
+ return DVDNAV_STATUS_OK;
+}
+
+dvdnav_status_t dvdnav_set_state(dvdnav_t *this, dvd_state_t *save_state)
+{
+ if (!this || !this->vm)
+ {
+ printerr("Passed a NULL pointer.");
+ return DVDNAV_STATUS_ERR;
+ }
+
+ if (!this->started) {
+ printerr("Virtual DVD machine not started.");
+ return DVDNAV_STATUS_ERR;
+ }
+
+ pthread_mutex_lock(&this->vm_lock);
+
+ /* reset the dvdnav state */
+ memset(&this->pci, 0, sizeof(this->pci));
+ memset(&this->dsi, 0, sizeof(this->dsi));
+ this->last_cmd_nav_lbn = SRI_END_OF_CELL;
+
+ /* Set initial values of flags */
+ this->position_current.still = 0;
+ this->skip_still = 0;
+ this->sync_wait = 0;
+ this->sync_wait_skip = 0;
+ this->spu_clut_changed = 0;
+
+ /* set the state. this will also start the vm on that state */
+ /* means the next read block should be comming from that new */
+ /* state */
+ if (!vm_set_state(this->vm, save_state))
+ {
+ printerr("Failed to set vm state.");
+ pthread_mutex_unlock(&this->vm_lock);
+ return DVDNAV_STATUS_ERR;
+ }
+
+ pthread_mutex_unlock(&this->vm_lock);
+ return DVDNAV_STATUS_OK;
+}
+
/* Get an admap and admap_len */
static vobu_admap_t* dvdnav_admap_get(dvdnav_t *this, dvd_state_t *state,
int32_t *admap_len) {
diff --git a/src/vm/vm.c b/src/vm/vm.c
index 869dd05..35d08d5 100644
--- a/libdvdnav-5-0-3/src/vm/vm.c
+++ b/libdvdnav-5-0-3/src/vm/vm.c
@@ -1104,3 +1104,44 @@ void vm_ifo_close(ifo_handle_t *ifo)
{
ifoClose(ifo);
}
+
+int vm_get_state(vm_t *vm, dvd_state_t *save_state) {
+ *save_state = vm->state;
+ /* remove the pgc pointer as it might not be valid later*/
+ save_state->pgc = NULL;
+ return 1;
+}
+
+int vm_set_state(vm_t *vm, dvd_state_t *save_state) {
+ /* restore state from save_state as taken from ogle */
+
+ /* open the needed vts */
+ if (!ifoOpenNewVTSI(vm, vm->dvd, save_state->vtsN)) return 0;
+ // sets state.vtsN
+
+ vm->state = *save_state;
+ /* set state.domain before calling */
+ //calls get_pgcit()
+ // needs state.domain and sprm[0] set
+ // sets pgcit depending on state.domain
+ //writes: state.pgc
+ // state.pgN
+ // state.TT_PGCN_REG
+
+ if (!set_PGCN(vm, save_state->pgcN)) return 0;
+ save_state->pgc = vm->state.pgc;
+
+ /* set the rest of state after the call */
+ vm->state = *save_state;
+
+ /* if we are not in standard playback, we must get all data */
+ /* otherwise we risk loosing stillframes, and overlays */
+ if (vm->state.domain != DVD_DOMAIN_VTSTitle)
+ vm->state.blockN = 0;
+
+ /* force a flush of data here */
+ /* we don't need a hop seek here as it's a complete state*/
+ vm->hop_channel++;
+
+ return 1;
+}
diff --git a/src/vm/vm.h b/src/vm/vm.h
index e4b01c2..a6fdbf9 100644
--- a/libdvdnav-5-0-3/src/vm/vm.h
+++ b/libdvdnav-5-0-3/src/vm/vm.h
@@ -161,6 +161,9 @@ subp_attr_t vm_get_subp_attr(vm_t *vm, int streamN);
ifo_handle_t *vm_get_title_ifo(vm_t *vm, uint32_t title);
void vm_ifo_close(ifo_handle_t *ifo);
+int vm_get_state(vm_t *vm, dvd_state_t *save_state);
+int vm_set_state(vm_t *vm, dvd_state_t *save_state);
+
/* Uncomment for VM command tracing */
/* #define TRACE */
#ifdef TRACE
--
2.1.4
|