summaryrefslogtreecommitdiff
path: root/src/xine-engine
diff options
context:
space:
mode:
authorDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2003-11-26 23:44:08 +0000
committerDaniel Caujolle-Bert <f1rmb@users.sourceforge.net>2003-11-26 23:44:08 +0000
commite76d60c53d666cc42408bcea5e4060ac173798dd (patch)
treea2b395870a898ad7bdfe1f49a7717499f40e1386 /src/xine-engine
parent23176d5f3aaafdf90795fb847a064d0bb1b8d198 (diff)
downloadxine-lib-e76d60c53d666cc42408bcea5e4060ac173798dd.tar.gz
xine-lib-e76d60c53d666cc42408bcea5e4060ac173798dd.tar.bz2
xprintf clean pass. xprintf now log into new XINE_LOG_TRACE log buffer. scratch buffer enhancement (thanks Thibaut for the malloc tips), enlarge log buffer from 25 lines (very useless), to 150 (better).
CVS patchset: 5801 CVS date: 2003/11/26 23:44:08
Diffstat (limited to 'src/xine-engine')
-rw-r--r--src/xine-engine/audio_decoder.c7
-rw-r--r--src/xine-engine/broadcaster.c12
-rw-r--r--src/xine-engine/load_plugins.c29
-rw-r--r--src/xine-engine/metronom.c10
-rw-r--r--src/xine-engine/scratch.c52
-rw-r--r--src/xine-engine/scratch.h4
-rw-r--r--src/xine-engine/video_out.c7
-rw-r--r--src/xine-engine/xine.c24
-rw-r--r--src/xine-engine/xine_internal.h5
9 files changed, 69 insertions, 81 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c
index 480a6e205..2ae362c88 100644
--- a/src/xine-engine/audio_decoder.c
+++ b/src/xine-engine/audio_decoder.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: audio_decoder.c,v 1.115 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: audio_decoder.c,v 1.116 2003/11/26 23:44:10 f1rmb Exp $
*
*
* functions that implement audio decoding
@@ -183,9 +183,8 @@ static void *audio_decoder_loop (void *stream_gen) {
case BUF_CONTROL_AUDIO_CHANNEL:
{
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("audio_decoder: suggested switching to stream_id %02x\n",
- buf->decoder_info[0]);
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG,
+ "audio_decoder: suggested switching to stream_id %02x\n", buf->decoder_info[0]);
stream->audio_channel_auto = buf->decoder_info[0] & 0xff;
}
break;
diff --git a/src/xine-engine/broadcaster.c b/src/xine-engine/broadcaster.c
index e5b4d8ffd..41f8e24e6 100644
--- a/src/xine-engine/broadcaster.c
+++ b/src/xine-engine/broadcaster.c
@@ -19,7 +19,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: broadcaster.c,v 1.3 2003/11/11 18:45:00 f1rmb Exp $
+ * $Id: broadcaster.c,v 1.4 2003/11/26 23:44:10 f1rmb Exp $
*
* broadcaster.c - xine network broadcaster
*
@@ -164,8 +164,7 @@ static void broadcaster_data_write(broadcaster_t *this, char *buf, int len) {
/* in case of failure remove from list */
if( sock_data_write(*psock, buf, len) < 0 ) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("broadcaster: closing socket %d\n", *psock);
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "broadcaster: closing socket %d\n", *psock);
close(*psock);
free(psock);
if( this->connections->cur->next )
@@ -226,8 +225,8 @@ static void *manager_loop (void *this_gen) {
int *psock = malloc(sizeof(int));
*psock = ssock;
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("broadcaster: new connection socket %d\n", *psock);
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ "broadcaster: new connection socket %d\n", *psock);
xine_list_append_content(this->connections, psock);
}
}
@@ -348,8 +347,7 @@ void _x_close_broadcaster(broadcaster_t *this)
psock = xine_list_first_content (this->connections);
while (psock) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("broadcaster: closing socket %d\n", *psock);
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "broadcaster: closing socket %d\n", *psock);
close(*psock);
free(psock);
xine_list_delete_current (this->connections);
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 15e614f4d..3d1a44ba1 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.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: load_plugins.c,v 1.165 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: load_plugins.c,v 1.166 2003/11/26 23:44:10 f1rmb Exp $
*
*
* Load input/demux/audio_out/video_out/codec plugins
@@ -305,9 +305,9 @@ static void _insert_plugin (xine_t *this,
int i;
if (info->API != api_version) {
- if (this->verbosity >= XINE_VERBOSITY_LOG)
- printf ("load_plugins: ignoring plugin %s, wrong iface version %d (should be %d)\n",
- info->id, info->API, api_version);
+ xprintf(this, XINE_VERBOSITY_LOG,
+ "load_plugins: ignoring plugin %s, wrong iface version %d (should be %d)\n",
+ info->id, info->API, api_version);
return;
}
@@ -467,12 +467,9 @@ static void collect_plugins(xine_t *this, char *path){
if(!info && !(lib = dlopen (str, RTLD_LAZY | RTLD_GLOBAL))) {
- if (this->verbosity >= XINE_VERBOSITY_LOG) {
- char *dl_error_msg = dlerror();
- /* too noisy -- but good to catch unresolved references */
- printf ("load_plugins: cannot open plugin lib %s:\n%s\n",
- str, dl_error_msg);
- }
+ /* too noisy -- but good to catch unresolved references */
+ xprintf(this, XINE_VERBOSITY_LOG,
+ "load_plugins: cannot open plugin lib %s:\n%s\n", str, dlerror());
} else {
@@ -1055,8 +1052,7 @@ static demux_plugin_t *probe_demux (xine_stream_t *stream, int method1, int meth
while (node) {
demux_plugin_t *plugin;
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("load_plugins: probing demux '%s'\n", node->info->id);
+ xprintf(stream->xine, XINE_VERBOSITY_DEBUG, "load_plugins: probing demux '%s'\n", node->info->id);
if ((plugin = ((demux_class_t *)node->plugin_class)->open_plugin(node->plugin_class, stream, input))) {
pthread_mutex_unlock (&catalog->lock);
@@ -1613,9 +1609,8 @@ video_decoder_t *_x_get_video_decoder (xine_stream_t *stream, uint8_t stream_typ
if (!node->plugin_class) {
/* remove non working plugin from catalog */
- if (stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("load_plugins: plugin %s failed to init its class.\n",
- node->info->id);
+ xprintf(stream->xine, XINE_VERBOSITY_LOG,
+ "load_plugins: plugin %s failed to init its class.\n", node->info->id);
for (j = i + 1; j < PLUGINS_PER_TYPE; j++)
catalog->video_decoder_map[stream_type][j - 1] =
catalog->video_decoder_map[stream_type][j];
@@ -1633,8 +1628,8 @@ video_decoder_t *_x_get_video_decoder (xine_stream_t *stream, uint8_t stream_typ
return vd;
} else {
/* remove non working plugin from catalog */
- if (stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("load_plugins: plugin %s failed to instantiate itself.\n", node->info->id);
+ xprintf(stream->xine, XINE_VERBOSITY_LOG,
+ "load_plugins: plugin %s failed to instantiate itself.\n", node->info->id);
for (j = i + 1; j < PLUGINS_PER_TYPE; j++)
catalog->video_decoder_map[stream_type][j - 1] =
catalog->video_decoder_map[stream_type][j];
diff --git a/src/xine-engine/metronom.c b/src/xine-engine/metronom.c
index 69a1939d1..1f8b5eee5 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.130 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: metronom.c,v 1.131 2003/11/26 23:44:10 f1rmb Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -313,8 +313,8 @@ static void metronom_handle_discontinuity (metronom_t *this, int type,
this->force_audio_jump = 1;
this->force_video_jump = 1;
this->video_drift = 0;
- xprintf(this->xine, XINE_VERBOSITY_DEBUG, "vpts adjusted with prebuffer to %lld\n",
- this->video_vpts);
+ xprintf(this->xine, XINE_VERBOSITY_DEBUG,
+ "vpts adjusted with prebuffer to %lld\n", this->video_vpts);
break;
case DISC_ABSOLUTE:
@@ -529,7 +529,7 @@ static void metronom_handle_audio_discontinuity (metronom_t *this, int type,
pthread_cond_signal (&this->audio_discontinuity_reached);
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "audio discontinuity #%d, type is %d, disc_off %lld\n",
- this->audio_discontinuity_count, type, disc_off);
+ this->audio_discontinuity_count, type, disc_off);
if (this->have_video) {
@@ -538,7 +538,7 @@ static void metronom_handle_audio_discontinuity (metronom_t *this, int type,
this->discontinuity_handled_count ) {
xprintf(this->xine, XINE_VERBOSITY_DEBUG, "waiting for in_discontinuity update #%d\n",
- this->audio_discontinuity_count);
+ this->audio_discontinuity_count);
pthread_cond_wait (&this->video_discontinuity_reached, &this->lock);
}
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
index 4a34a0ad2..777948048 100644
--- a/src/xine-engine/scratch.c
+++ b/src/xine-engine/scratch.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: scratch.c,v 1.11 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: scratch.c,v 1.12 2003/11/26 23:44:11 f1rmb Exp $
*
* top-level xine functions
*
@@ -41,16 +41,12 @@
#include "xineutils.h"
static void scratch_printf (scratch_buffer_t *this, const char *format, va_list argp) {
-
- vsnprintf (this->lines[this->cur], 1023, format, argp);
-
+ vsnprintf (this->lines[this->cur], SCRATCH_LINE_LEN_MAX, format, argp);
lprintf ("printing format %s to line %d\n", format, this->cur);
-
this->cur = (this->cur + 1) % this->num_lines;
}
static const char **scratch_get_content (scratch_buffer_t *this) {
-
int i, j;
for(i = 0, j = (this->cur - 1); i < this->num_lines; i++, j--) {
@@ -59,9 +55,7 @@ static const char **scratch_get_content (scratch_buffer_t *this) {
j = (this->num_lines - 1);
this->ordered[i] = this->lines[j];
-
lprintf ("line %d contains >%s<\n", i , this->lines[j]);
-
}
return this->ordered;
@@ -69,42 +63,42 @@ static const char **scratch_get_content (scratch_buffer_t *this) {
}
static void scratch_dispose (scratch_buffer_t *this) {
-
- int i;
-
- for(i = 0; i < this->num_lines; i++ ) {
- free (this->lines[i]);
- }
-
+ char *mem;
+ int i;
+
+ mem = (char *) this->lines[0];
+ free(mem);
+
+ for(i = 0; i < this->num_lines; i++ )
+ this->lines[i] = NULL;
+
free (this->lines);
free (this->ordered);
free (this);
-
}
scratch_buffer_t *_x_new_scratch_buffer (int num_lines) {
-
scratch_buffer_t *this;
- int i;
+ int i;
+ char *mem;
this = xine_xmalloc (sizeof (scratch_buffer_t));
this->lines = xine_xmalloc (sizeof (char *) * (num_lines + 1));
this->ordered = xine_xmalloc (sizeof (char *) * (num_lines + 1));
- for (i=0; i<num_lines; i++) {
- this->lines[i] = (char *) xine_xmalloc (sizeof(char) * 1024);
- memset(this->lines[i], 0, sizeof(this->lines[i]));
- }
- this->ordered[i] = NULL;
- this->lines[i] = NULL;
+ mem = (char *) xine_xmalloc((sizeof(char) * SCRATCH_LINE_LEN_MAX) * num_lines);
- this->scratch_printf = scratch_printf;
- this->get_content = scratch_get_content;
- this->dispose = scratch_dispose;
+ for (i = 0; i < num_lines; i++)
+ this->lines[i] = (char *) (mem + i * SCRATCH_LINE_LEN_MAX);
- this->num_lines = num_lines;
- this->cur = 0;
+ this->ordered[i] = NULL;
+ this->lines[i] = NULL;
+ this->scratch_printf = scratch_printf;
+ this->get_content = scratch_get_content;
+ this->dispose = scratch_dispose;
+ this->num_lines = num_lines;
+ this->cur = 0;
return this;
}
diff --git a/src/xine-engine/scratch.h b/src/xine-engine/scratch.h
index e79fe6b4b..72d8901c8 100644
--- a/src/xine-engine/scratch.h
+++ b/src/xine-engine/scratch.h
@@ -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: scratch.h,v 1.6 2003/11/11 18:45:01 f1rmb Exp $
+ * $Id: scratch.h,v 1.7 2003/11/26 23:44:11 f1rmb Exp $
*
* scratch buffer for log output
*
@@ -30,6 +30,8 @@
typedef struct scratch_buffer_s scratch_buffer_t;
+#define SCRATCH_LINE_LEN_MAX 1024
+
struct scratch_buffer_s {
void (*scratch_printf) (scratch_buffer_t *this, const char *format, va_list ap);
diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c
index 18bfa8300..4073690cf 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.181 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: video_out.c,v 1.182 2003/11/26 23:44:11 f1rmb Exp $
*
* frame allocation / queuing / scheduling / output functions
*/
@@ -1534,8 +1534,9 @@ xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver,
/* FIXME: how does this happen ? */
printf (_("video_out: sorry, this should not happen. please restart xine.\n"));
abort();
- } else if (xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("video_out: thread created\n");
+ }
+ else
+ xprintf(xine, XINE_VERBOSITY_DEBUG, "video_out: thread created\n");
pthread_attr_destroy(&pth_attrs);
}
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index a8e7d5587..73a968cb2 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.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: xine.c,v 1.272 2003/11/26 19:43:38 f1rmb Exp $
+ * $Id: xine.c,v 1.273 2003/11/26 23:44:11 f1rmb Exp $
*/
/*
@@ -1203,7 +1203,7 @@ xine_t *xine_new (void) {
*/
for (i = 0; i < XINE_LOG_NUM; i++)
- this->log_buffers[i] = _x_new_scratch_buffer (25);
+ this->log_buffers[i] = _x_new_scratch_buffer (150);
#ifdef WIN32
@@ -1611,27 +1611,25 @@ const char *const *xine_get_log_names (xine_t *this) {
log_sections[XINE_LOG_MSG] = _("messages");
log_sections[XINE_LOG_PLUGIN] = _("plugin");
+ log_sections[XINE_LOG_TRACE] = _("trace");
log_sections[XINE_LOG_NUM] = NULL;
return log_sections;
}
void xine_log (xine_t *this, int buf, const char *format, ...) {
-
va_list argp;
-
+ char buffer[SCRATCH_LINE_LEN_MAX];
+
va_start (argp, format);
-
this->log_buffers[buf]->scratch_printf (this->log_buffers[buf], format, argp);
- va_end (argp);
-
- if (this->verbosity) {
- va_start (argp, format);
-
- vprintf (format, argp);
-
- va_end (argp);
+
+ if(this->verbosity) {
+ vsnprintf(buffer, SCRATCH_LINE_LEN_MAX, format, argp);
+ printf(buffer);
}
+
+ va_end (argp);
}
const char *const *xine_get_log (xine_t *this, int buf) {
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 95a41398c..352cca677 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -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: xine_internal.h,v 1.149 2003/11/16 23:33:49 f1rmb Exp $
+ * $Id: xine_internal.h,v 1.150 2003/11/26 23:44:11 f1rmb Exp $
*
*/
@@ -84,7 +84,8 @@ extern "C" {
#define XINE_LOG_MSG 0 /* warnings, errors, ... */
#define XINE_LOG_PLUGIN 1
-#define XINE_LOG_NUM 2 /* # of log buffers defined */
+#define XINE_LOG_TRACE 2
+#define XINE_LOG_NUM 3 /* # of log buffers defined */
#define XINE_STREAM_INFO_MAX 99