summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-12-09 17:24:39 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-12-09 17:24:39 +0000
commit2651276ca6ee76c33adce1f1794c897fb98d3e7e (patch)
tree117af931334833a3167f9018cc17c4a36c1b2bf7
parentb8649f02441f19b9c32027651690700e79775cdc (diff)
downloadxine-lib-2651276ca6ee76c33adce1f1794c897fb98d3e7e.tar.gz
xine-lib-2651276ca6ee76c33adce1f1794c897fb98d3e7e.tar.bz2
xine log functions for gui output
CVS patchset: 1191 CVS date: 2001/12/09 17:24:39
-rw-r--r--include/xine.h.tmpl.in12
-rw-r--r--src/xine-engine/Makefile.am4
-rw-r--r--src/xine-engine/scratch.c82
-rw-r--r--src/xine-engine/scratch.h49
-rw-r--r--src/xine-engine/xine.c48
-rw-r--r--src/xine-engine/xine_internal.h22
6 files changed, 209 insertions, 8 deletions
diff --git a/include/xine.h.tmpl.in b/include/xine.h.tmpl.in
index 52761cd8a..d07272978 100644
--- a/include/xine.h.tmpl.in
+++ b/include/xine.h.tmpl.in
@@ -28,7 +28,7 @@
\endverbatim
*/
/*
- * $Id: xine.h.tmpl.in,v 1.60 2001/12/08 00:45:26 guenter Exp $
+ * $Id: xine.h.tmpl.in,v 1.61 2001/12/09 17:24:39 guenter Exp $
*
*/
@@ -1675,6 +1675,16 @@ struct osd_renderer_s {
osd_renderer_t *xine_get_osd_renderer (xine_t *self);
+/*
+ * xine log functions
+ */
+
+void xine_log (xine_t *self, int buf, const char *format, ...);
+
+char **xine_get_log (xine_t *self, int buf);
+
+
+
/** @} end of xine_api */
#ifdef __cplusplus
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
index ccf76e5e7..00d270735 100644
--- a/src/xine-engine/Makefile.am
+++ b/src/xine-engine/Makefile.am
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = libxine.la
libxine_la_SOURCES = xine.c metronom.c configfile.c buffer.c \
load_plugins.c video_decoder.c buffer_types.c \
audio_decoder.c video_out.c audio_out.c resample.c events.c lrb.c \
- video_overlay.c osd.c
+ video_overlay.c osd.c scratch.c
libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) -lm -lz
libxine_la_LDFLAGS = \
@@ -19,7 +19,7 @@ libxine_la_LDFLAGS = \
include_HEADERS = buffer.h metronom.h configfile.h \
audio_out.h resample.h video_out.h xine_internal.h spu_decoder.h \
- events.h lrb.h video_overlay.h osd.h
+ events.h lrb.h video_overlay.h osd.h scratch.h
noinst_HEADERS = bswap.h
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
new file mode 100644
index 000000000..4d8336d46
--- /dev/null
+++ b/src/xine-engine/scratch.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2000-2001 the xine project
+ *
+ * This file is part of xine, a unix video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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.1 2001/12/09 17:24:39 guenter Exp $
+ *
+ * top-level xine functions
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "scratch.h"
+#include "xineutils.h"
+
+static void scratch_printf (scratch_buffer_t *this, const char *format, va_list argp) {
+
+ vsprintf (this->lines[this->cur], format, argp);
+
+ this->cur = (this->cur + 1) % this->num_lines;
+
+}
+
+static char **scratch_get_content (scratch_buffer_t *this) {
+
+ int i;
+
+ for (i=0; i<this->num_lines; i++) {
+
+ this->lines[i] = xine_xmalloc (1024);
+ this->ordered[i] = this->lines[(this->cur + i) % this->num_lines];
+
+ }
+
+ return this->ordered;
+
+}
+
+scratch_buffer_t *new_scratch_buffer (int num_lines) {
+
+ scratch_buffer_t *this;
+ int i;
+
+ 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] = xine_xmalloc (1024);
+ }
+
+ this->ordered[i] = NULL;
+ this->lines[i] = NULL;
+
+ this->printf = scratch_printf;
+ this->get_content = scratch_get_content;
+
+ this->num_lines = num_lines;
+ this->cur = 0;
+
+ return this;
+}
diff --git a/src/xine-engine/scratch.h b/src/xine-engine/scratch.h
new file mode 100644
index 000000000..aad303b32
--- /dev/null
+++ b/src/xine-engine/scratch.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2000-2001 the xine project
+ *
+ * This file is part of xine, a unix video player.
+ *
+ * xine is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * xine is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * 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.1 2001/12/09 17:24:39 guenter Exp $
+ *
+ * scratch buffer for log output
+ *
+ */
+
+#ifndef HAVE_SCRATCH_H
+#define HAVE_SCRATCH_H
+
+#include <stdarg.h>
+
+typedef struct scratch_buffer_s scratch_buffer_t;
+
+struct scratch_buffer_s {
+
+ void (*printf) (scratch_buffer_t *this, const char *format, va_list ap);
+
+ char **(*get_content) (scratch_buffer_t *this);
+
+ char **lines;
+ char **ordered;
+
+ int num_lines;
+ int cur;
+
+};
+
+scratch_buffer_t *new_scratch_buffer (int num_lines);
+
+#endif
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 0572dd658..2be5b9dbc 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.86 2001/12/08 13:37:58 guenter Exp $
+ * $Id: xine.c,v 1.87 2001/12/09 17:24:39 guenter Exp $
*
* top-level xine functions
*
@@ -247,6 +247,10 @@ void xine_play (xine_t *this, char *mrl,
printf ("xine_play: xine open %s, start pos = %d, start time = %d (sec)\n",
mrl, start_pos, start_time);
+ xine_log (this, XINE_LOG_MSG,
+ "xine_play: xine open %s, start pos = %d, start time = %d (sec)\n",
+ mrl, start_pos, start_time);
+
pthread_mutex_lock (&this->xine_lock);
/*
@@ -295,8 +299,11 @@ void xine_play (xine_t *this, char *mrl,
return;
}
- printf ("xine: using input plugin >%s< for this MRL.\n",
- this->cur_input_plugin->get_identifier(this->cur_input_plugin));
+ xine_log (this, XINE_LOG_MSG,
+ "xine: using input plugin >%s< for this MRL (%s).\n",
+ this->cur_input_plugin->get_identifier(this->cur_input_plugin), mrl);
+ printf ("xine: using input plugin >%s< for this MRL (%s).\n",
+ this->cur_input_plugin->get_identifier(this->cur_input_plugin), mrl);
/*
* find demuxer plugin
@@ -308,6 +315,10 @@ void xine_play (xine_t *this, char *mrl,
return;
}
+ xine_log (this, XINE_LOG_MSG,
+ "xine: using demuxer plugin >%s< for this MRL.\n",
+ this->cur_demuxer_plugin->get_identifier());
+
printf ("xine: using demuxer plugin >%s< for this MRL.\n",
this->cur_demuxer_plugin->get_identifier());
@@ -395,9 +406,10 @@ xine_t *xine_init (vo_driver_t *vo,
ao_driver_t *ao,
config_values_t *config) {
- xine_t *this = xine_xmalloc (sizeof (xine_t));
+ xine_t *this = xine_xmalloc (sizeof (xine_t));
static char *demux_strategies[] = {"default", "reverse", "content",
"extension", NULL};
+ int i;
printf("xine_init entered\n");
@@ -407,6 +419,11 @@ xine_t *xine_init (vo_driver_t *vo,
/* initialize aligned mem allocator */
xine_init_mem_aligned();
+
+ /* init log buffers */
+
+ for (i=0; i<XINE_LOG_NUM; i++)
+ this->log_buffers[i] = new_scratch_buffer (25);
/*
* init locks
@@ -776,3 +793,26 @@ osd_renderer_t *xine_get_osd_renderer (xine_t *this) {
return this->osd_renderer;
}
+
+/*
+ * log functions
+ */
+
+void xine_log (xine_t *this, int buf, const char *format, ...) {
+
+ va_list argp;
+
+ va_start (argp, format);
+
+ this->log_buffers[buf]->printf (this->log_buffers[buf], format, argp);
+
+ va_end (argp);
+}
+
+char **xine_get_log (xine_t *this, int buf) {
+
+ return this->log_buffers[buf]->get_content (this->log_buffers[buf]);
+
+}
+
+
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 3affa406f..8921d385d 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.60 2001/12/08 13:37:58 guenter Exp $
+ * $Id: xine_internal.h,v 1.61 2001/12/09 17:24:39 guenter Exp $
*
*/
@@ -49,6 +49,7 @@ extern "C" {
#include "spu_decoder_api.h"
#endif
#include "osd.h"
+#include "scratch.h"
#define INPUT_PLUGIN_MAX 50
#define DEMUXER_PLUGIN_MAX 50
@@ -131,6 +132,13 @@ struct audio_decoder_s {
#define XINE_PLAY 1
#define XINE_QUIT 2
+/*
+ * log output
+ */
+#define XINE_LOG_MSG 0
+#define XINE_LOG_CODEC 1
+#define XINE_LOG_NUM 2 /* # of log buffers defined */
+
typedef struct xine_s xine_t;
typedef void (*xine_event_listener_t) (void *user_data, xine_event_t *);
@@ -211,6 +219,10 @@ struct xine_s {
/* scratch string buffer */
char str[1024];
+
+ /* log output that may be presented to the user */
+ scratch_buffer_t *log_buffers[XINE_LOG_NUM];
+
};
/*
@@ -567,6 +579,14 @@ int xine_get_current_frame (xine_t *this, int *width, int *height,
#define XINE_ASPECT_RATIO_DONT_TOUCH 42
osd_renderer_t *xine_get_osd_renderer (xine_t *this);
+
+/*
+ * xine log functions
+ */
+
+void xine_log (xine_t *this, int buf, const char *format, ...);
+
+char **xine_get_log (xine_t *this, int buf);
#ifdef __cplusplus
}