changeset 142:e375b765ebf5 src

some more sanity checking will prevent segfaults in these functions
author mroi
date Tue, 01 Apr 2003 11:28:54 +0000
parents 8f63f4c25f2f
children 0b302ca31859
files dvdnav.c
diffstat 1 files changed, 71 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Mon Mar 31 13:48:36 2003 +0000
+++ b/dvdnav.c	Tue Apr 01 11:28:54 2003 +0000
@@ -813,9 +813,15 @@
 uint8_t dvdnav_get_video_aspect(dvdnav_t *this) {
   uint8_t         retval;
   
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
-  
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
+
   pthread_mutex_lock(&this->vm_lock);
   retval = (uint8_t)vm_get_video_aspect(this->vm);
   pthread_mutex_unlock(&this->vm_lock);
@@ -826,8 +832,14 @@
 uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) {
   uint8_t         retval;
   
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock);
   retval = (uint8_t)vm_get_video_scale_permission(this->vm);
@@ -839,8 +851,14 @@
 uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *this, uint8_t stream) {
   audio_attr_t  attr;
   
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock); 
   attr = vm_get_audio_attr(this->vm, stream);
@@ -855,8 +873,14 @@
 uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) {
   subp_attr_t  attr;
   
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock); 
   attr = vm_get_subp_attr(this->vm, stream);
@@ -871,11 +895,18 @@
 int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) {
   int8_t       retval;
   
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -888,11 +919,18 @@
 int8_t dvdnav_get_spu_logical_stream(dvdnav_t *this, uint8_t subp_num) {
   int8_t       retval;
 
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
 
   pthread_mutex_lock(&this->vm_lock);
   if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -905,11 +943,18 @@
 int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) {
   int8_t        retval;
 
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock); 
   if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -922,11 +967,18 @@
 int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) {
   int8_t        retval;
 
-  if(!this)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock); 
   if (!this->vm->state.pgc) {
+    printerr("No current PGC.");
     pthread_mutex_unlock(&this->vm_lock); 
     return -1;
   }
@@ -939,8 +991,14 @@
 static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) {
   int8_t        retval;
   
-  if (!this || !this->started)
+  if(!this) {
+    printerr("Passed a NULL pointer.");
     return -1;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return -1;
+  }
   
   pthread_mutex_lock(&this->vm_lock);
   retval = (this->vm->state.domain == domain);
@@ -1021,6 +1079,9 @@
 
 /*
  * $Log$
+ * Revision 1.49  2003/04/01 11:28:54  mroi
+ * some more sanity checking will prevent segfaults in these functions
+ *
  * Revision 1.48  2003/03/31 13:48:36  mroi
  * update position on HOP_CHANNEL, do not rely on a following CELL_CHANGE
  *