diff options
author | Stephen Torri <storri@users.sourceforge.net> | 2003-02-28 02:51:47 +0000 |
---|---|---|
committer | Stephen Torri <storri@users.sourceforge.net> | 2003-02-28 02:51:47 +0000 |
commit | 49327f43ca2196122a60314e67eeee929efea873 (patch) | |
tree | 1b9ce1d2b141d0e411e422df265f6d57183906e1 /src/xine-engine | |
parent | 7eb769e2d3c1abb16e53d87af5f8633967e7f6ce (diff) | |
download | xine-lib-49327f43ca2196122a60314e67eeee929efea873.tar.gz xine-lib-49327f43ca2196122a60314e67eeee929efea873.tar.bz2 |
Xine assert() replacement:
All assert() function calls, with exceptions of libdvdread and libdvdnav, have been
replaced with XINE_ASSERT. Functionally XINE_ASSERT behaves just likes its predecesor but its
adding the ability to print out a stack trace at the point where the assertion fails.
So here are a few examples.
assert (0);
This use of assert was found in a couple locations most favorably being the default case of a switch
statement. This was the only thing there. So if the switch statement was unable to find a match
it would have defaulted to this and the user and the developers would be stuck wonder who died and where.
So it has been replaced with
XINE_ASSERT(0, "We have reach this point and don't have a default case");
It may seem a bit none descriptive but there is more going on behind the scene.
In addition to checking a condition is true/false, in this case '0', the XINE_ASSERT
prints out:
<filename>:<function name>:<line number> - assertion '<assertion expression>' failed. <description>
An example of this might be:
input_dvd.c:open_plugin:1178 - assertion '0' failed. xine_malloc failed!!! You have run out of memory
XINE_ASSERT and its helper function, print_trace, are found in src/xine-utils/xineutils.h
CVS patchset: 4301
CVS date: 2003/02/28 02:51:47
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/audio_out.c | 4 | ||||
-rw-r--r-- | src/xine-engine/bswap.h | 8 | ||||
-rw-r--r-- | src/xine-engine/configfile.c | 25 | ||||
-rw-r--r-- | src/xine-engine/lrb.c | 5 | ||||
-rw-r--r-- | src/xine-engine/metronom.c | 3 | ||||
-rw-r--r-- | src/xine-engine/video_out.c | 5 | ||||
-rw-r--r-- | src/xine-engine/vo_scale.c | 5 |
7 files changed, 24 insertions, 31 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index ed25f69c7..637ec42d2 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.108 2003/02/22 14:18:16 mroi Exp $ + * $Id: audio_out.c,v 1.109 2003/02/28 02:51:51 storri Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -219,7 +219,7 @@ static void fifo_append_int (audio_fifo_t *fifo, /* buf->next = NULL; */ - assert (!buf->next); + XINE_ASSERT(!buf->next, "Next audio buffer is NULL."); if (!fifo->first) { fifo->first = buf; diff --git a/src/xine-engine/bswap.h b/src/xine-engine/bswap.h index 900ef6271..72a6badbc 100644 --- a/src/xine-engine/bswap.h +++ b/src/xine-engine/bswap.h @@ -6,13 +6,13 @@ #include "config.h" #endif +#include "xineutils.h" + #ifdef HAVE_BYTESWAP_H #include <byteswap.h> -#include <assert.h> #else - #include <inttypes.h> -#include <assert.h> + #ifdef ARCH_X86 inline static unsigned short ByteSwap16(unsigned short x) @@ -106,7 +106,7 @@ inline static unsigned long long int ByteSwap64(unsigned long long int x) inline static void* check_ptr_alignment(void* ptr, int align) { - assert((int)ptr % align == 0); + XINE_ASSERT((int)ptr % align == 0, "Improper pointer alignment."); return ptr; } diff --git a/src/xine-engine/configfile.c b/src/xine-engine/configfile.c index 50892323a..433263d3c 100644 --- a/src/xine-engine/configfile.c +++ b/src/xine-engine/configfile.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: configfile.c,v 1.45 2003/02/02 12:33:23 hadess Exp $ + * $Id: configfile.c,v 1.46 2003/02/28 02:51:51 storri Exp $ * * config object (was: file) management - implementation * @@ -32,7 +32,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <assert.h> #include "configfile.h" #include "xineutils.h" #include "xine_internal.h" @@ -214,8 +213,8 @@ static char *_xine_config_register_string (config_values_t *this, cfg_entry_t *entry; - assert (key); - assert (def_value); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(def_value, "Default value is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -279,8 +278,7 @@ static int _xine_config_register_num (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -338,8 +336,7 @@ static int _xine_config_register_bool (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering %s\n", key); @@ -398,8 +395,7 @@ static int _xine_config_register_range (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering range %s\n", key); @@ -490,9 +486,8 @@ static int _xine_config_register_enum (config_values_t *this, void *cb_data) { cfg_entry_t *entry; - - assert (key); - assert (values); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(values, "Argument 'values' is NULL. This is a required argument."); #ifdef LOG printf ("configfile: registering enum %s\n", key); @@ -898,8 +893,8 @@ static void xine_config_unregister_cb (config_values_t *this, cfg_entry_t *entry; - assert (this); - assert (key); + XINE_ASSERT(key, "Register key is NULL. This is a required argument."); + XINE_ASSERT(this, "Argument 'this' is NULL. Cannot find key if this is not set."); entry = _xine_config_lookup_entry (this, key); if (entry) { diff --git a/src/xine-engine/lrb.c b/src/xine-engine/lrb.c index c3be42039..63072472b 100644 --- a/src/xine-engine/lrb.c +++ b/src/xine-engine/lrb.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: lrb.c,v 1.3 2002/10/23 17:12:31 guenter Exp $ + * $Id: lrb.c,v 1.4 2003/02/28 02:51:51 storri Exp $ * */ @@ -25,7 +25,6 @@ #include "config.h" #endif -#include <assert.h> #include "lrb.h" #include "xineutils.h" @@ -49,7 +48,7 @@ void lrb_drop (lrb_t *this) { buf_element_t *buf = this->oldest; - assert (buf); + XINE_ASSERT(buf, "Oldest buffer element is NULL"); this->oldest = buf->next; diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c index 500e13eb4..71e057f78 100644 --- a/src/xine-engine/metronom.c +++ b/src/xine-engine/metronom.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: metronom.c,v 1.111 2003/01/28 17:07:53 f1rmb Exp $ + * $Id: metronom.c,v 1.112 2003/02/28 02:51:51 storri Exp $ */ #ifdef HAVE_CONFIG_H @@ -32,7 +32,6 @@ #include <math.h> #include <string.h> #include <errno.h> -#include <assert.h> #include "xine_internal.h" #include "metronom.h" diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index faee09e35..7f4001ed8 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_out.c,v 1.146 2003/02/22 14:22:13 mroi Exp $ + * $Id: video_out.c,v 1.147 2003/02/28 02:51:51 storri Exp $ * * frame allocation / queuing / scheduling / output functions */ @@ -34,7 +34,6 @@ #include <string.h> #include <zlib.h> #include <pthread.h> -#include <assert.h> #define XINE_ENABLE_EXPERIMENTAL_FEATURES @@ -126,7 +125,7 @@ static void vo_append_to_img_buf_queue_int (img_buf_fifo_t *queue, vo_frame_t *img) { /* img already enqueue? (serious leak) */ - assert (img->next==NULL); + XINE_ASSERT (img->next==NULL, "Image is already enqueue. Next image is not NULL"); img->next = NULL; diff --git a/src/xine-engine/vo_scale.c b/src/xine-engine/vo_scale.c index a785c9f5d..ed024a1dc 100644 --- a/src/xine-engine/vo_scale.c +++ b/src/xine-engine/vo_scale.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: vo_scale.c,v 1.18 2002/11/25 16:56:06 mroi Exp $ + * $Id: vo_scale.c,v 1.19 2003/02/28 02:51:51 storri Exp $ * * Contains common code to calculate video scaling parameters. * In short, it will map frame dimensions to screen/window size. @@ -101,7 +101,8 @@ void vo_scale_compute_ideal_size (vo_scale_t *this) { this->video_pixel_aspect = desired_ratio / image_ratio; - assert (this->gui_pixel_aspect != 0.0); + XINE_ASSERT(this->gui_pixel_aspect != 0.0, "GUI pixel aspect is not 0.0: %f",this->gui_pixel_aspect); + if (fabs (this->video_pixel_aspect / this->gui_pixel_aspect - 1.0) < 0.01) { this->video_pixel_aspect = this->gui_pixel_aspect; |