# HG changeset patch # User mroi # Date 1049196534 0 # Node ID e375b765ebf5dc7b4caad2a0e9f9f8f765ea3e86 # Parent 8f63f4c25f2fe39c3bdb22cc1af8a0ea8053f045 some more sanity checking will prevent segfaults in these functions diff -r 8f63f4c25f2f -r e375b765ebf5 dvdnav.c --- 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 *