[DVDnav-discuss] r924 - in trunk/libdvdnav2/src: dvdnav.c highlight.c navigation.c searching.c settings.c
nicodvb
subversion at mplayerhq.hu
Sun Apr 29 13:55:22 CEST 2007
Author: nicodvb
Date: Sun Apr 29 13:55:22 2007
New Revision: 924
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/libdvdnav2/src/dvdnav.c
trunk/libdvdnav2/src/highlight.c
trunk/libdvdnav2/src/navigation.c
trunk/libdvdnav2/src/searching.c
trunk/libdvdnav2/src/settings.c
Modified: trunk/libdvdnav2/src/dvdnav.c
==============================================================================
--- trunk/libdvdnav2/src/dvdnav.c (original)
+++ trunk/libdvdnav2/src/dvdnav.c Sun Apr 29 13:55:22 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,22 +174,12 @@ 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;
}
const char* dvdnav_err_to_string(dvdnav_t *this) {
-
- if(!this)
- return "Hey! You gave me a NULL pointer you naughty person!";
-
return this->err_str;
}
@@ -412,11 +392,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 +804,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 +826,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 +841,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 +860,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 */
@@ -944,10 +897,6 @@ uint16_t dvdnav_audio_stream_format(dvdn
uint16_t dvdnav_audio_stream_channels(dvdnav_t *this, uint8_t stream) {
audio_attr_t attr;
- if(!this) {
- printerr("Passed a NULL pointer.");
- return -1; /* 0xffff */
- }
if(!this->started) {
printerr("Virtual DVD machine not started.");
return -1; /* 0xffff */
@@ -963,10 +912,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;
@@ -985,10 +930,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;
@@ -1009,10 +950,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;
@@ -1033,10 +970,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;
@@ -1057,10 +990,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;
@@ -1081,10 +1010,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;
@@ -1118,11 +1043,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 */
@@ -1140,11 +1060,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);
@@ -1153,17 +1068,14 @@ dvdnav_status_t dvdnav_get_angle_info(dv
}
pci_t* dvdnav_get_current_nav_pci(dvdnav_t *this) {
- if(!this) return 0;
return &this->pci;
}
dsi_t* dvdnav_get_current_nav_dsi(dvdnav_t *this) {
- if(!this) return 0;
return &this->dsi;
}
uint32_t dvdnav_get_next_still_flag(dvdnav_t *this) {
- if(!this) return -1;
return this->position_next.still;
}
@@ -1180,10 +1092,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/libdvdnav2/src/highlight.c
==============================================================================
--- trunk/libdvdnav2/src/highlight.c (original)
+++ trunk/libdvdnav2/src/highlight.c Sun Apr 29 13:55:22 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/libdvdnav2/src/navigation.c
==============================================================================
--- trunk/libdvdnav2/src/navigation.c (original)
+++ trunk/libdvdnav2/src/navigation.c Sun Apr 29 13:55:22 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/libdvdnav2/src/searching.c
==============================================================================
--- trunk/libdvdnav2/src/searching.c (original)
+++ trunk/libdvdnav2/src/searching.c Sun Apr 29 13:55:22 2007
@@ -233,12 +233,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.");
@@ -267,12 +261,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.");
@@ -303,11 +291,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.");
@@ -350,11 +333,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.");
@@ -402,10 +380,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;
@@ -472,11 +446,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.");
Modified: trunk/libdvdnav2/src/settings.c
==============================================================================
--- trunk/libdvdnav2/src/settings.c (original)
+++ trunk/libdvdnav2/src/settings.c Sun Apr 29 13:55:22 2007
@@ -30,21 +30,11 @@
/* Characteristics/setting API calls */
dvdnav_status_t dvdnav_get_region_mask(dvdnav_t *this, int32_t *region) {
- if(!this || !region) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
(*region) = this->vm->state.registers.SPRM[20];
return DVDNAV_STATUS_OK;
}
dvdnav_status_t dvdnav_set_region_mask(dvdnav_t *this, int32_t mask) {
- if(!this) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
pthread_mutex_lock(&this->vm_lock);
this->vm->state.registers.SPRM[20] = (mask & 0xff);
pthread_mutex_unlock(&this->vm_lock);
@@ -52,31 +42,16 @@ dvdnav_status_t dvdnav_set_region_mask(d
}
dvdnav_status_t dvdnav_set_readahead_flag(dvdnav_t *this, int32_t use_readahead) {
- if(!this) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
this->use_read_ahead = use_readahead;
return DVDNAV_STATUS_OK;
}
dvdnav_status_t dvdnav_get_readahead_flag(dvdnav_t *this, int32_t *flag) {
- if(!this || !flag) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
(*flag) = this->use_read_ahead;
return DVDNAV_STATUS_OK;
}
static dvdnav_status_t set_language_register(dvdnav_t *this, char *code, int reg) {
- if(!this || !code) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
if(!code[0] || !code[1]) {
printerr("Passed illegal language code.");
return DVDNAV_STATUS_ERR;
@@ -101,21 +76,11 @@ dvdnav_status_t dvdnav_spu_language_sele
}
dvdnav_status_t dvdnav_set_PGC_positioning_flag(dvdnav_t *this, int32_t pgc) {
- if(!this) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
this->pgc_based = pgc;
return DVDNAV_STATUS_OK;
}
dvdnav_status_t dvdnav_get_PGC_positioning_flag(dvdnav_t *this, int32_t *flag) {
- if(!this || !flag) {
- printerr("Passed a NULL this pointer.");
- return DVDNAV_STATUS_ERR;
- }
-
(*flag) = this->pgc_based;
return DVDNAV_STATUS_OK;
}
More information about the DVDnav-discuss
mailing list