[DVDnav-discuss] r864 - in trunk/libdvdnav/src: dvdnav.c highlight.c navigation.c searching.c
nicodvb
subversion at mplayerhq.hu
Wed Apr 11 22:13:57 CEST 2007
Author: nicodvb
Date: Wed Apr 11 22:13:56 2007
New Revision: 864
Modified:
trunk/libdvdnav/src/dvdnav.c
trunk/libdvdnav/src/highlight.c
trunk/libdvdnav/src/navigation.c
trunk/libdvdnav/src/searching.c
Log:
removed nonsensical checks on the sanity of dvdnav_t *this
passed to nearly every function;
checks like those don't belong to the library and are good only
to hide bugs in applications (whose quality will likely decrease)
Modified: trunk/libdvdnav/src/dvdnav.c
==============================================================================
--- trunk/libdvdnav/src/dvdnav.c (original)
+++ trunk/libdvdnav/src/dvdnav.c Wed Apr 11 22:13:56 2007
@@ -122,11 +122,6 @@ dvdnav_status_t dvdnav_close(dvdnav_t *t
fprintf(MSG_OUT, "libdvdnav: close:called\n");
#endif
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
if (this->file) {
DVDCloseFile(this->file);
#ifdef LOG_DEBUG
@@ -159,11 +154,6 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *t
fprintf(MSG_OUT, "libdvdnav: reset:called\n");
#endif
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
#ifdef LOG_DEBUG
@@ -184,12 +174,6 @@ dvdnav_status_t dvdnav_reset(dvdnav_t *t
}
dvdnav_status_t dvdnav_path(dvdnav_t *this, const char** path) {
-
- if(!this || !path) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
(*path) = this->path;
return DVDNAV_STATUS_OK;
@@ -412,11 +396,6 @@ dvdnav_status_t dvdnav_get_next_cache_bl
dvd_state_t *state;
int32_t result;
- if(!this || !event || !len || !buf || !*buf) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if(!this->started) {
@@ -829,23 +808,13 @@ dvdnav_status_t dvdnav_get_next_cache_bl
}
dvdnav_status_t dvdnav_get_title_string(dvdnav_t *this, const char **title_str) {
-
- if(!this || !title_str) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
(*title_str) = this->vm->dvd_name;
return DVDNAV_STATUS_OK;
}
uint8_t dvdnav_get_video_aspect(dvdnav_t *this) {
uint8_t retval;
-
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
+
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -861,10 +830,6 @@ uint8_t dvdnav_get_video_aspect(dvdnav_t
uint8_t dvdnav_get_video_scale_permission(dvdnav_t *this) {
uint8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -880,10 +845,6 @@ uint8_t dvdnav_get_video_scale_permissio
uint16_t dvdnav_audio_stream_to_lang(dvdnav_t *this, uint8_t stream) {
audio_attr_t attr;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -903,10 +864,6 @@ uint16_t dvdnav_audio_stream_format(dvdn
audio_attr_t attr;
uint16_t format;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1; /* 0xffff */
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1; /* 0xffff */
@@ -945,10 +902,6 @@ uint16_t dvdnav_audio_stream_channels(dv
audio_attr_t attr;
uint16_t format;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1; /* 0xffff */
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1; /* 0xffff */
@@ -964,10 +917,6 @@ uint16_t dvdnav_audio_stream_channels(dv
uint16_t dvdnav_spu_stream_to_lang(dvdnav_t *this, uint8_t stream) {
subp_attr_t attr;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -986,10 +935,6 @@ uint16_t dvdnav_spu_stream_to_lang(dvdna
int8_t dvdnav_get_audio_logical_stream(dvdnav_t *this, uint8_t audio_num) {
int8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -1010,10 +955,6 @@ int8_t dvdnav_get_audio_logical_stream(d
int8_t dvdnav_get_spu_logical_stream(dvdnav_t *this, uint8_t subp_num) {
int8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -1034,10 +975,6 @@ int8_t dvdnav_get_spu_logical_stream(dvd
int8_t dvdnav_get_active_audio_stream(dvdnav_t *this) {
int8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -1058,10 +995,6 @@ int8_t dvdnav_get_active_audio_stream(dv
int8_t dvdnav_get_active_spu_stream(dvdnav_t *this) {
int8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -1082,10 +1015,6 @@ int8_t dvdnav_get_active_spu_stream(dvdn
static int8_t dvdnav_is_domain(dvdnav_t *this, domain_t domain) {
int8_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1;
@@ -1119,11 +1048,6 @@ int8_t dvdnav_is_domain_vts(dvdnav_t *th
dvdnav_status_t dvdnav_angle_change(dvdnav_t *this, int32_t angle) {
int32_t num, current;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
vm_get_angle_info(this->vm, ¤t, &num);
/* Set angle SPRM if valid */
@@ -1141,11 +1065,6 @@ dvdnav_status_t dvdnav_angle_change(dvdn
dvdnav_status_t dvdnav_get_angle_info(dvdnav_t *this, int32_t *current_angle,
int32_t *number_of_angles) {
- if(!this || !current_angle || !number_of_angles) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
vm_get_angle_info(this->vm, current_angle, number_of_angles);
pthread_mutex_unlock(&this->vm_lock);
@@ -1181,10 +1100,6 @@ user_ops_t dvdnav_get_restrictions(dvdna
ops.ops_int = 0;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return ops.ops_struct;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return ops.ops_struct;
Modified: trunk/libdvdnav/src/highlight.c
==============================================================================
--- trunk/libdvdnav/src/highlight.c (original)
+++ trunk/libdvdnav/src/highlight.c Wed Apr 11 22:13:56 2007
@@ -206,12 +206,6 @@ void nav_print_PCI(pci_t *pci) {
/* Highlighting API calls */
dvdnav_status_t dvdnav_get_current_highlight(dvdnav_t *this, int32_t *button) {
-
- if(!this || !button) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
/* Simply return the appropriate value based on the SPRM */
if(((*button) = this->position_current.button) == -1)
(*button) = this->vm->state.HL_BTNN_REG >> 10;
@@ -222,10 +216,6 @@ dvdnav_status_t dvdnav_get_current_highl
static btni_t *get_current_button(dvdnav_t *this, pci_t *pci) {
int32_t button = 0;
- if(!this || !pci) {
- printerr("Passed a NULL pointer.");
- return NULL;
- }
if(!pci->hli.hl_gi.hli_ss) {
printerr("Not in a menu.");
return NULL;
@@ -331,10 +321,6 @@ dvdnav_status_t dvdnav_button_activate(d
int32_t button;
btni_t *button_ptr = NULL;
- if(!this || !pci) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if(!pci->hli.hl_gi.hli_ss) {
printerr("Not in a menu.");
return DVDNAV_STATUS_ERR;
@@ -391,11 +377,6 @@ dvdnav_status_t dvdnav_button_activate(d
dvdnav_status_t dvdnav_button_activate_cmd(dvdnav_t *this, int32_t button, vm_cmd_t *cmd)
{
- if(!this || !cmd) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
/* make the VM execute the appropriate code and probably
* schedule a jump */
@@ -417,11 +398,6 @@ dvdnav_status_t dvdnav_button_activate_c
}
dvdnav_status_t dvdnav_button_select(dvdnav_t *this, pci_t *pci, int32_t button) {
-
- if(!this || !pci) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if(!pci->hli.hl_gi.hli_ss) {
printerr("Not in a menu.");
return DVDNAV_STATUS_ERR;
@@ -459,10 +435,6 @@ dvdnav_status_t dvdnav_mouse_select(dvdn
int32_t best,dist,d;
int32_t mx,my,dx,dy;
- if(!this || !pci) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if(!pci->hli.hl_gi.hli_ss) {
printerr("Not in a menu.");
return DVDNAV_STATUS_ERR;
Modified: trunk/libdvdnav/src/navigation.c
==============================================================================
--- trunk/libdvdnav/src/navigation.c (original)
+++ trunk/libdvdnav/src/navigation.c Wed Apr 11 22:13:56 2007
@@ -30,11 +30,6 @@
/* Navigation API calls */
dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
this->position_current.still = 0;
this->skip_still = 1;
this->sync_wait = 0;
@@ -44,11 +39,6 @@ dvdnav_status_t dvdnav_still_skip(dvdnav
}
dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
this->sync_wait = 0;
this->sync_wait_skip = 1;
@@ -56,10 +46,6 @@ dvdnav_status_t dvdnav_wait_skip(dvdnav_
}
dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
- if(!this || !titles) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if (!this->vm->vmgi) {
printerr("Bad VM state.");
return DVDNAV_STATUS_ERR;
@@ -71,10 +57,6 @@ dvdnav_status_t dvdnav_get_number_of_tit
}
dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
- if(!this || !parts) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if (!this->vm->vmgi) {
printerr("Bad VM state.");
return DVDNAV_STATUS_ERR;
@@ -92,11 +74,6 @@ dvdnav_status_t dvdnav_get_number_of_par
dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) {
int32_t retval;
- if(!this || !title || !part) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if (!this->vm->vtsi || !this->vm->vmgi) {
printerr("Bad VM state.");
@@ -134,21 +111,12 @@ dvdnav_status_t dvdnav_current_title_inf
}
dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
return dvdnav_part_play(this, title, 1);
}
dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) {
int32_t retval;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if (!this->vm->vmgi) {
printerr("Bad VM state.");
@@ -194,22 +162,12 @@ dvdnav_status_t dvdnav_part_play_auto_st
dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title,
uint64_t time) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
/* FIXME: Implement */
printerr("Not implemented yet.");
return DVDNAV_STATUS_ERR;
}
dvdnav_status_t dvdnav_stop(dvdnav_t *this) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
this->vm->stopped = 1;
pthread_mutex_unlock(&this->vm_lock);
@@ -217,11 +175,6 @@ dvdnav_status_t dvdnav_stop(dvdnav_t *th
}
dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
/* A nice easy function... delegate to the VM */
pthread_mutex_lock(&this->vm_lock);
vm_jump_up(this->vm);
Modified: trunk/libdvdnav/src/searching.c
==============================================================================
--- trunk/libdvdnav/src/searching.c (original)
+++ trunk/libdvdnav/src/searching.c Wed Apr 11 22:13:56 2007
@@ -310,12 +310,6 @@ dvdnav_status_t dvdnav_part_search(dvdna
}
dvdnav_status_t dvdnav_prev_pg_search(dvdnav_t *this) {
-
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if(!this->vm->state.pgc) {
printerr("No current PGC.");
@@ -344,12 +338,6 @@ dvdnav_status_t dvdnav_prev_pg_search(dv
}
dvdnav_status_t dvdnav_top_pg_search(dvdnav_t *this) {
-
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if(!this->vm->state.pgc) {
printerr("No current PGC.");
@@ -380,11 +368,6 @@ dvdnav_status_t dvdnav_top_pg_search(dvd
dvdnav_status_t dvdnav_next_pg_search(dvdnav_t *this) {
vm_t *try_vm;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if(!this->vm->state.pgc) {
printerr("No current PGC.");
@@ -427,11 +410,6 @@ dvdnav_status_t dvdnav_next_pg_search(dv
dvdnav_status_t dvdnav_menu_call(dvdnav_t *this, DVDMenuID_t menu) {
vm_t *try_vm;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
if(!this->vm->state.pgc) {
printerr("No current PGC.");
@@ -479,10 +457,6 @@ dvdnav_status_t dvdnav_get_position(dvdn
cell_playback_t *cell;
dvd_state_t *state;
- if(!this || !pos || !len) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return DVDNAV_STATUS_ERR;
@@ -549,11 +523,6 @@ dvdnav_status_t dvdnav_get_position_in_t
cell_playback_t *last_cell;
dvd_state_t *state;
- if(!this || !pos || !len) {
- printerr("Passed a NULL pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
state = &(this->vm->state);
if(!state->pgc) {
printerr("No current PGC.");
More information about the DVDnav-discuss
mailing list