Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : eplayer
Dir : misc/eplayer/src
Modified Files:
callbacks.c eplayer.c interface.c playlist.c track.c utils.c
utils.h
Log Message:
Added debugging stuff. Thanks to digitalfallout.
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- callbacks.c 25 Oct 2003 19:31:39 -0000 1.10
+++ callbacks.c 7 Nov 2003 22:33:28 -0000 1.11
@@ -4,6 +4,7 @@
#include "eplayer.h"
#include "track.h"
#include "interface.h"
+#include "utils.h"
static int paused = 0;
@@ -16,9 +17,7 @@
* @param event
*/
void cb_play(ePlayer *player, Evas *e, Evas_Object *o, void *event) {
-#ifdef DEBUG
- printf("DEBUG: Play callback entered\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Play callback entered\n");
if (!paused) { /* restart from beginning */
eplayer_playback_stop(player);
@@ -38,9 +37,7 @@
* @param event
*/
void cb_pause(ePlayer *player, Evas *e, Evas_Object *o, void *event) {
-#ifdef DEBUG
- printf("DEBUG: Pause callback entered\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Pause callback entered\n");
if (paused)
eplayer_playback_start(player, 0);
@@ -61,9 +58,7 @@
*/
void cb_track_next(ePlayer *player, Evas *e, Evas_Object *o,
void *event) {
-#ifdef DEBUG
- printf("DEBUG: Next File Called\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Next File Called\n");
eplayer_playback_stop(player);
@@ -90,9 +85,7 @@
*/
void cb_track_prev(ePlayer *player, Evas *e, Evas_Object *o,
void *event) {
-#ifdef DEBUG
- printf("DEBUG: Previous File Called\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Previous File Called\n");
/* first item on the list: do nothing */
if (!player->playlist->cur_item->prev)
@@ -110,9 +103,7 @@
const char *emission, const char *src) {
int left = 0, right = 0;
-#ifdef DEBUG
- printf("DEBUG: Raising volume\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Raising volume\n");
if (!player->output->volume_get(&left, &right))
return;
@@ -125,9 +116,7 @@
const char *emission, const char *src) {
int left = 0, right = 0;
-#ifdef DEBUG
- printf("DEBUG: Lowering volume\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Lowering volume\n");
if (!player->output->volume_get(&left, &right))
return;
@@ -173,9 +162,7 @@
ePlayer *player = udata;
PlayListItem *pli = player->playlist->cur_item->data;
-#ifdef DEBUG
- printf("DEBUG: Seeking forward\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Seeking forward\n");
/* We don't care if you seek past the file, the play loop
* will catch EOF and play next file
@@ -191,9 +178,9 @@
PlayListItem *pli = player->playlist->cur_item->data;
int cur_time = pli->plugin->get_current_pos();
-#ifdef DEBUG
- printf("DEBUG: Seeking backward - Current Pos: %i\n", cur_time);
-#endif
+ debug(DEBUG_LEVEL_INFO, "Seeking backward - Current Pos: %i\n",
+ cur_time);
+
eplayer_playback_stop(player);
if (cur_time < 6) /* restart from the beginning */
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- eplayer.c 3 Nov 2003 18:08:52 -0000 1.13
+++ eplayer.c 7 Nov 2003 22:33:28 -0000 1.14
@@ -112,12 +112,9 @@
snprintf(cfg_file, sizeof(cfg_file),
SYSCONF_DIR "/" PACKAGE ".db");
- if (!config_load(&player->cfg, cfg_file)) {
-#ifdef DEBUG
- printf("Cannot load config, "
- "falling back to default settings!\n");
-#endif
- }
+ if (!config_load(&player->cfg, cfg_file))
+ debug(DEBUG_LEVEL_WARNING, "Cannot load config, "
+ "falling back to default settings!\n");
}
player->input_plugins = load_input_plugins();
@@ -129,8 +126,8 @@
PLUGIN_TYPE_OUTPUT);
if (!player->output) {
- fprintf(stderr, "Cannot load %s output plugin!\n",
- player->cfg.output_plugin);
+ debug(DEBUG_LEVEL_CRITICAL, "Cannot load %s output plugin!\n",
+ player->cfg.output_plugin);
eplayer_free(player);
return NULL;
@@ -208,7 +205,7 @@
playlist_load_any(player->playlist, argv[i], i > 1);
if (!player->playlist->num) {
- fprintf(stderr, "No files loaded!\n");
+ debug(DEBUG_LEVEL_CRITICAL, "No files loaded!\n");
eplayer_free(player);
return 1;
}
@@ -226,9 +223,7 @@
track_open(player);
refresh_time(player, 0);
-#ifdef DEBUG
- printf("DEBUG: Starting main loop\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Starting main loop\n");
ecore_main_loop_begin();
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -3 -r1.9 -r1.10
--- interface.c 23 Oct 2003 17:01:49 -0000 1.9
+++ interface.c 7 Nov 2003 22:33:28 -0000 1.10
@@ -5,11 +5,10 @@
#include <Edje.h>
#include "callbacks.h"
#include "track.h"
+#include "utils.h"
static int app_signal_exit(void *data, int type, void *event) {
-#ifdef DEBUG
- printf("DEBUG: Exit called, shutting down\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Exit called, shutting down\n");
ecore_main_loop_quit();
return 1;
@@ -19,9 +18,7 @@
Ecore_Evas *ee;
double edje_w = 0, edje_h = 0;
-#ifdef DEBUG
- printf("DEBUG: Starting setup\n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "Starting setup\n");
ecore_init();
ecore_evas_init();
@@ -42,15 +39,13 @@
evas_font_path_append(player->gui.evas, DATA_DIR "/themes/fonts");
/* EDJE */
-#ifdef DEBUG
- printf("DEBUG - EDJE: Defining Edje \n");
-#endif
+ debug(DEBUG_LEVEL_INFO, "EDJE: Defining Edje \n");
player->gui.edje = edje_object_add(player->gui.evas);
if (!(edje_object_file_set(player->gui.edje,
DATA_DIR "/themes/eplayer.eet", "eplayer"))) {
- fprintf(stderr, "Cannot load theme!\n");
+ debug(DEBUG_LEVEL_CRITICAL, "Cannot load theme!\n");
return 0;
}
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- playlist.c 23 Oct 2003 19:35:55 -0000 1.7
+++ playlist.c 7 Nov 2003 22:33:28 -0000 1.8
@@ -61,9 +61,7 @@
}
if (!pli->plugin) {
-#ifdef DEBUG
- printf("No plugin found for %s!\n", file);
-#endif
+ debug(DEBUG_LEVEL_WARNING, "No plugin found for %s!\n", file);
playlist_item_free(pli);
return NULL;
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/track.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -3 -r1.4 -r1.5
--- track.c 25 Oct 2003 19:31:39 -0000 1.4
+++ track.c 7 Nov 2003 22:33:28 -0000 1.5
@@ -3,6 +3,7 @@
#include <assert.h>
#include "eplayer.h"
#include "interface.h"
+#include "utils.h"
/**
* Plays a chunk of the current track.
@@ -87,7 +88,7 @@
edje_object_part_text_set(player->gui.edje, "time_text", "0:00");
if (!player->output->configure(pli->channels, pli->sample_rate, 16)) {
- fprintf(stderr, "Cannot configure output plugin\n");
+ debug(DEBUG_LEVEL_CRITICAL, "Cannot configure output plugin\n");
/* move to the next track */
edje_object_signal_emit(player->gui.edje,
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/utils.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- utils.c 23 Oct 2003 19:35:56 -0000 1.1
+++ utils.c 7 Nov 2003 22:33:28 -0000 1.2
@@ -4,6 +4,9 @@
#include <ctype.h>
#include <sys/stat.h>
#include <dirent.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include "utils.h"
int is_dir(const char *dir) {
struct stat st;
@@ -76,4 +79,15 @@
ptr[1] = 0;
return str;
+}
+
+void debug(DebugLevel level, const char *fmt, ...) {
+ va_list list;
+
+ if (level > DEBUG_LEVEL || !fmt || !fmt[0])
+ return;
+
+ va_start(list, fmt);
+ vprintf(fmt, list);
+ va_end(list);
}
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/utils.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- utils.h 23 Oct 2003 19:35:56 -0000 1.1
+++ utils.h 7 Nov 2003 22:33:28 -0000 1.2
@@ -3,9 +3,18 @@
#include <Evas.h>
+typedef enum {
+ DEBUG_LEVEL_CRITICAL,
+ DEBUG_LEVEL_WARNING,
+ DEBUG_LEVEL_INFO,
+ DEBUG_LEVEL_NUM
+} DebugLevel;
+
int is_dir(const char *dir);
char *strstrip(char *str);
Evas_List *dir_get_files(const char *directory);
+
+void debug(DebugLevel level, const char *fmt, ...);
#endif
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs