changeset 263:d999338cab17 src

prevent races
author mroi
date Wed, 20 Apr 2005 16:05:43 +0000
parents 7708d2fc1745
children 8c86b61eb06f
files dvdnav.c
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dvdnav.c	Fri Mar 18 20:27:14 2005 +0000
+++ b/dvdnav.c	Wed Apr 20 16:05:43 2005 +0000
@@ -1094,10 +1094,21 @@
    */
   uint32_t ops=0;
   
+  if(!this) {
+    printerr("Passed a NULL pointer.");
+    return *(user_ops_t*)&ops;
+  }
+  if(!this->started) {
+    printerr("Virtual DVD machine not started.");
+    return *(user_ops_t*)&ops;
+  }
+  
+  pthread_mutex_lock(&this->vm_lock); 
   ops|=*(uint32_t*)&this->pci.pci_gi.vobu_uop_ctl;
   
   if(this->vm && this->vm->state.pgc)
     ops|=*(uint32_t*)&this->vm->state.pgc->prohibited_ops;
+  pthread_mutex_unlock(&this->vm_lock); 
     
   return *(user_ops_t*)&ops;
 }