On Sat, Jan 31, 2009 at 11:23 AM, elupus <[email protected]> wrote:
> On Wed, 28 Jan 2009 23:25:44 +0100, Nico Sabbi wrote:
>
>>> [21 quoted lines suppressed]
>>
>> you broke the API extending an existing function for no reason; you
>> should add a new function and raise the minor number instead.
>>> [1 quoted line suppressed]
>
> Hmm.. No he didn't. dvd_read_name is a static local function.

Right, the only API change is to add the serial getting function.

> He should however have added the new dvd_serial property of vm_t at the
> end, as that would break any app using the vm.h structs, but i'm not sure
> if that is public or not.

Good question. If the vm.h header is installed, then we have to
consider it 'public'.
Because, if it is then people can use the functions there to run their
own VM. But, by
typing 'make install' I see that it is not installed. So it is likely
safe to stick that string
in the middle. There is a minor error in the code that writes the
serial data out. Line
196 indexes the serial string at 15, when that is the size of the
string - needs to be 14.

Patch (w/ minor fix) attached.

E

-- 
Erik Hovland
[email protected]
http://hovland.org/
Submitted patch from Matthew Wire

From: Erik Hovland <[email protected]>


---

 src/dvdnav.c        |    5 +++++
 src/dvdnav/dvdnav.h |    7 +++++++
 src/vm/vm.c         |    6 ++++--
 src/vm/vm.h         |    1 +
 4 files changed, 17 insertions(+), 2 deletions(-)


diff --git a/src/dvdnav.c b/src/dvdnav.c
index 6bf9f5e..24d9cab 100644
--- a/src/dvdnav.c
+++ b/src/dvdnav.c
@@ -825,6 +825,11 @@ dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str)
   return DVDNAV_STATUS_OK;
 }
 
+dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *this, const char **serial_str) {
+  (*serial_str) = this->vm->dvd_serial;
+  return DVDNAV_STATUS_OK;
+}
+
 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) {
   uint8_t         retval;
 
diff --git a/src/dvdnav/dvdnav.h b/src/dvdnav/dvdnav.h
index 37a588c..7586f81 100644
--- a/src/dvdnav/dvdnav.h
+++ b/src/dvdnav/dvdnav.h
@@ -537,6 +537,13 @@ dvdnav_status_t dvdnav_spu_language_select(dvdnav_t *self,
 dvdnav_status_t dvdnav_get_title_string(dvdnav_t *self, const char **title_str);
 
 /*
+ * Returns a string containing the serial number of the DVD.
+ * This has a max of 15 characters and should be more unique than the
+ * title string.
+ */
+dvdnav_status_t dvdnav_get_serial_string(dvdnav_t *self, const char **serial_str);
+
+/*
  * Get video aspect code.
  * The aspect code does only change on VTS boundaries.
  * See the DVDNAV_VTS_CHANGE event.
diff --git a/src/vm/vm.c b/src/vm/vm.c
index 6331d48..9256da5 100644
--- a/src/vm/vm.c
+++ b/src/vm/vm.c
@@ -156,7 +156,7 @@ static int os2_open(const char *name, int oflag)
 }
 #endif
 
-static void dvd_read_name(char *name, const char *device) {
+static void dvd_read_name(char *name, char *serial, const char *device) {
     /* Because we are compiling with _FILE_OFFSET_BITS=64
      * all off_t are 64bit.
      */
@@ -192,6 +192,8 @@ static void dvd_read_name(char *name, const char *device) {
               fprintf(MSG_OUT, " ");
             }
           }
+          strncpy(serial, (char*) &data[73], (i-73));
+          serial[14] = 0;
           fprintf(MSG_OUT, "\nlibdvdnav: DVD Title (Alternative): ");
           for(i=89; i < 128; i++ ) {
             if((data[i] == 0)) break;
@@ -352,7 +354,7 @@ int vm_reset(vm_t *vm, const char *dvdroot) {
       fprintf(MSG_OUT, "libdvdnav: vm: failed to open/read the DVD\n");
       return 0;
     }
-    dvd_read_name(vm->dvd_name, dvdroot);
+    dvd_read_name(vm->dvd_name, vm->dvd_serial, dvdroot);
     vm->map  = remap_loadmap(vm->dvd_name);
     vm->vmgi = ifoOpenVMGI(vm->dvd);
     if(!vm->vmgi) {
diff --git a/src/vm/vm.h b/src/vm/vm.h
index c4fc482..aaad1e5 100644
--- a/src/vm/vm.h
+++ b/src/vm/vm.h
@@ -82,6 +82,7 @@ typedef struct {
   dvd_state_t   state;
   int32_t       hop_channel;
   char          dvd_name[50];
+  char          dvd_serial[15];
   remap_t      *map;
   int           stopped;
 } vm_t;
_______________________________________________
DVDnav-discuss mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/dvdnav-discuss

Reply via email to