Enlightenment CVS committal

Author  : tsauerbeck
Project : misc
Module  : eplayer

Dir     : misc/eplayer/src


Modified Files:
        callbacks.c eplayer.c eplayer.h interface.c output_plugin.c 
        vorbis.c 


Log Message:
Added ALSA and Solaris output plugins. An edb file is now used to control the evas 
engine and output plugin to use etc
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- callbacks.c 21 Oct 2003 17:53:38 -0000      1.7
+++ callbacks.c 22 Oct 2003 18:50:05 -0000      1.8
@@ -114,7 +114,7 @@
 
 void cb_time_display_toggle(ePlayer *player, Evas_Object *obj,
                             const char *emission, const char *src) {
-       player->time_display = !player->time_display;
+       player->cfg.time_display = !player->cfg.time_display;
        vorbis_update_time(player);
 }
 
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- eplayer.c   21 Oct 2003 17:53:38 -0000      1.8
+++ eplayer.c   22 Oct 2003 18:50:05 -0000      1.9
@@ -3,23 +3,63 @@
 
 #include <config.h>
 #include <Ecore_Evas.h>
+#include <Edb.h>
+#include <string.h>
 #include "eplayer.h"
 #include "interface.h"
 #include "vorbis.h"
 
+static void config_init(Config *cfg) {
+       snprintf(cfg->evas_engine, sizeof(cfg->evas_engine),
+                "software");
+       snprintf(cfg->output_plugin, sizeof(cfg->output_plugin),
+                "OSS");
+}
+
+static int config_load(Config *cfg, const char *file) {
+       E_DB_File *edb;
+       char *str;
+       int val = 0;
+       
+       if (!cfg || !file || !*file)
+               return 0;
+
+       if (!(edb = e_db_open_read((char *) file)))
+               return 0;
+
+       if (e_db_int_get(edb, "/eplayer/time_display_show_left", &val))
+               cfg->time_display = !!val;
+       
+       if ((str = e_db_str_get(edb, "/eplayer/evas_engine"))) {
+               snprintf(cfg->evas_engine, sizeof(cfg->evas_engine), str);
+               free(str);
+       }
+       
+       if ((str = e_db_str_get(edb, "/eplayer/output_plugin"))) {
+               snprintf(cfg->output_plugin, sizeof(cfg->output_plugin), str);
+               free(str);
+       }
+
+       return 1;
+}
+
 static void eplayer_free(ePlayer *player) {
        if (!player)
                return;
 
        playlist_free(player->playlist);
-       output_plugin_free(player->output);
+
+       if (player->output) {
+               player->output->shutdown();
+               output_plugin_free(player->output);
+       }
        
        free(player);
 }
 
 static ePlayer *eplayer_new() {
        ePlayer *player;
-       const char *plugin = PLUGIN_DIR"/output/libOSS.so";
+       char cfg_file[PATH_MAX + 1];
 
        if (!(player = malloc(sizeof(ePlayer))))
                return NULL;
@@ -28,11 +68,31 @@
 
        player->playlist = playlist_new();
 
+       /* load config */
+       config_init(&player->cfg);
+       
+       snprintf(cfg_file, sizeof(cfg_file), "%s/." PACKAGE ".db",
+                getenv("HOME"));
+       
+       if (!config_load(&player->cfg, cfg_file)) {
+               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
+               }
+       }
+
        /* load the output plugin */
-       player->output = output_plugin_new(plugin);
+       player->output = output_plugin_new(player->cfg.output_plugin);
 
        if (!player->output) {
-               fprintf(stderr, "Cannot load output plugin %s!\n", plugin);
+               fprintf(stderr, "Cannot load %s output plugin!\n",
+                       player->cfg.output_plugin);
+
                eplayer_free(player);
                return NULL;
        }
@@ -90,10 +150,8 @@
        ePlayer *player;
        int args;
 
-       if (!(player = eplayer_new())) {
-               fprintf(stderr, "Out of memory!\n");
+       if (!(player = eplayer_new()))
                return 1;
-       }
 
        if (argc == 1) {
                printf("%s v%s  - Usage: %s playlist.m3u [file.ogg] [some/dir] 
...\n\n",
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -3 -r1.6 -r1.7
--- eplayer.h   21 Oct 2003 17:53:39 -0000      1.6
+++ eplayer.h   22 Oct 2003 18:50:05 -0000      1.7
@@ -12,22 +12,29 @@
 } TimeDisplay;
 
 typedef struct {
+       char evas_engine[255];
+       char output_plugin[255];
+       TimeDisplay time_display;
+} Config;
+
+typedef struct {
+       Evas *evas;
+       Evas_Object *edje;
+       Evas_Object *playlist; /* playlist container */
+       Evas_Object *playlist_col[2];
+       int playlist_font_size[2]; /* 0 -> title, 1 -> length */
+} Gui;
+
+typedef struct {
        PlayList *playlist;
        Ecore_Idler *play_idler;
        Ecore_Timer *time_timer;
-       
-       struct {
-               Evas *evas;
-               Evas_Object *edje;
-               Evas_Object *playlist; /* playlist container */
-               Evas_Object *playlist_col[2];
-               int playlist_font_size[2]; /* 0 -> title, 1 -> length */
-       } gui;
-
-       TimeDisplay time_display;
 
        OggVorbis_File current_track;
        OutputPlugin *output;
+
+       Config cfg;
+       Gui gui;
 } ePlayer;
 
 void eplayer_playback_stop(ePlayer *player, int rewind_track);
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/interface.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- interface.c 21 Oct 2003 17:53:39 -0000      1.7
+++ interface.c 22 Oct 2003 18:50:05 -0000      1.8
@@ -27,7 +27,11 @@
        ecore_evas_init();
        ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL);
 
-       ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 500, 500);
+       if (!strcasecmp(player->cfg.evas_engine, "gl"))
+               ee = ecore_evas_gl_x11_new(NULL, 0,  0, 0, 500, 500);
+       else
+               ee = ecore_evas_software_x11_new(NULL, 0,  0, 0, 500, 500);
+       
        ecore_evas_title_set(ee, "eVorbisPlayer");
        ecore_evas_name_class_set(ee, "ecore_test", "test_evas");
        ecore_evas_borderless_set(ee, 1);
@@ -35,7 +39,7 @@
        ecore_evas_show(ee);
 
        player->gui.evas = ecore_evas_get(ee);
-       evas_font_path_append(player->gui.evas, DATA_DIR"/themes/fonts");
+       evas_font_path_append(player->gui.evas, DATA_DIR "/themes/fonts");
 
        /* EDJE */
 #ifdef DEBUG
@@ -45,7 +49,7 @@
        player->gui.edje = edje_object_add(player->gui.evas);
        
        if (!(edje_object_file_set(player->gui.edje,
-                            DATA_DIR"/themes/eplayer.eet", "eplayer"))) {
+                            DATA_DIR "/themes/eplayer.eet", "eplayer"))) {
                fprintf(stderr, "Cannot load theme!\n");
                return 0;
        }
@@ -87,12 +91,14 @@
        edje_object_signal_callback_add(player->gui.edje,
                                        "PAUSE", "pause_button",
                                        cb_pause, player);
+       
        edje_object_signal_callback_add(player->gui.edje,
                                        "VOL_INCR", "vol_incr_button",
                                        cb_volume_raise, player);
        edje_object_signal_callback_add(player->gui.edje,
                                        "VOL_DECR", "vol_decr_button",
                                        cb_volume_lower, player);
+
        edje_object_signal_callback_add(player->gui.edje,
                                        "SWITCH_TIME_DISPLAY", "time_text",
                                        cb_time_display_toggle, player);
@@ -133,7 +139,10 @@
                /* add the title/length items to the container */
                for (i = 0; i < 2; i++) {
                        o = edje_object_add(player->gui.evas);
-                       edje_object_file_set(o, DATA_DIR"/themes/eplayer.eet", 
name[i]);
+
+                       edje_object_file_set(o, DATA_DIR "/themes/eplayer.eet",
+                                            name[i]);
+                       
                        edje_object_part_text_set(o, "text", i ? len : title);
                        edje_object_size_min_get(o, &w, &h);
                        evas_object_resize(o, w, h);
@@ -143,7 +152,8 @@
                         * the edje object first, to get the width/height
                         */
                        if (!added_cols) {
-                               evas_object_geometry_get(player->gui.playlist, NULL, 
NULL, NULL, &h);
+                               evas_object_geometry_get(player->gui.playlist,
+                                                        NULL, NULL, NULL, &h);
 
                                player->gui.playlist_col[i] = 
                                        playlist_column_add(player, w, h,
@@ -202,7 +212,7 @@
        fmt[TIME_DISPLAY_ELAPSED] = "%i:%02i";
        fmt[TIME_DISPLAY_LEFT] = "-%i:%02i";
 
-       snprintf(buf, sizeof(buf), fmt[player->time_display],
+       snprintf(buf, sizeof(buf), fmt[player->cfg.time_display],
                 (time / 60), (time % 60));
        
        edje_object_part_text_set(player->gui.edje, "time_text", buf);
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/output_plugin.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- output_plugin.c     21 Oct 2003 17:53:39 -0000      1.1
+++ output_plugin.c     22 Oct 2003 18:50:05 -0000      1.2
@@ -1,14 +1,17 @@
+#include <config.h>
 #include <stdlib.h>
 #include <dlfcn.h>
+#include <stdio.h>
 #include <string.h>
+#include <limits.h>
 #include "output_plugin.h"
 
-OutputPlugin *output_plugin_new(const char *file) {
+OutputPlugin *output_plugin_new(const char *name) {
        OutputPlugin *op;
        int (*init)(OutputPlugin *op);
-       char *error;
+       char *error, path[PATH_MAX + 1];
 
-       if (!file || !*file)
+       if (!name || !*name)
                return NULL;
 
        if (!(op = malloc(sizeof(OutputPlugin))))
@@ -16,7 +19,9 @@
 
        memset(op, 0, sizeof(OutputPlugin));
 
-       if (!(op->handle = dlopen(file, RTLD_LAZY))) {
+       snprintf(path, sizeof(path), PLUGIN_DIR "/output/lib%s.so", name);
+
+       if (!(op->handle = dlopen(path, RTLD_LAZY))) {
                output_plugin_free(op);
                return NULL;
        }
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/vorbis.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- vorbis.c    21 Oct 2003 17:53:39 -0000      1.10
+++ vorbis.c    22 Oct 2003 18:50:05 -0000      1.11
@@ -46,7 +46,7 @@
 
        cur_time = ov_time_tell(&player->current_track);
        
-       if (player->time_display == TIME_DISPLAY_LEFT)
+       if (player->cfg.time_display == TIME_DISPLAY_LEFT)
                cur_time = current_item->duration - cur_time;
 
        if (cur_time == old_time) /* value didn't change, so don't update */




-------------------------------------------------------
This SF.net email is sponsored by OSDN developer relations
Here's your chance to show off your extensive product knowledge
We want to know what you know. Tell us and you have a chance to win $100
http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to