Enlightenment CVS committal
Author : tsauerbeck
Project : misc
Module : eplayer
Dir : misc/eplayer/src
Modified Files:
callbacks.c eplayer.c plugin.c plugin.h
Log Message:
Switched to libltdl. Plugin loading is case sensitive now, so you probably need to
edit your config
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/callbacks.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -3 -r1.28 -r1.29
--- callbacks.c 22 Jan 2004 19:41:46 -0000 1.28
+++ callbacks.c 24 Jan 2004 20:26:38 -0000 1.29
@@ -310,66 +310,60 @@
}
EDJE_CB(update_seeker) {
- if (!strcmp(emission, "SEEKER_START"))
- {
- player->flags.seeker_seeking = 1;
- }
- else if (!strcmp(emission, "SEEKER_STOP"))
- {
- player->flags.seeker_seeking = 0;
- }
-
- if (player->flags.seeker_seeking)
- {
- PlayListItem *pli = playlist_current_item_get(player->playlist);
- Evas_Coord x, y, w, h;
- int ex, ey;
- double pos;
-
- if (ecore_event_current_type_get() == ECORE_X_EVENT_MOUSE_MOVE)
- {
- Ecore_X_Event_Mouse_Move *event;
+ if (!strcmp(emission, "SEEKER_START"))
+ player->flags.seeker_seeking = 1;
+ else if (!strcmp(emission, "SEEKER_STOP"))
+ player->flags.seeker_seeking = 0;
+
+ if (!player->flags.seeker_seeking)
+ return;
+
+ PlayListItem *pli = playlist_current_item_get(player->playlist);
+ Evas_Coord x, y, w, h;
+ int type, ex = 0, ey = 0;
+ double pos;
+
+ type = ecore_event_current_type_get();
+
+ if (type == ECORE_X_EVENT_MOUSE_MOVE) {
+ Ecore_X_Event_Mouse_Move *event;
- event = ecore_event_current_event_get();
- ex = event->x; ey = event->y;
- }
- else if (ecore_event_current_type_get() == ECORE_X_EVENT_MOUSE_BUTTON_DOWN)
- {
- Ecore_X_Event_Mouse_Button_Down *event;
+ event = ecore_event_current_event_get();
+ ex = event->x;
+ ey = event->y;
+ } else if (type == ECORE_X_EVENT_MOUSE_BUTTON_DOWN) {
+ Ecore_X_Event_Mouse_Button_Down *event;
- event = ecore_event_current_event_get();
- ex = event->x; ey = event->y;
- }
+ event = ecore_event_current_event_get();
+ ex = event->x;
+ ey = event->y;
+ }
- edje_object_part_geometry_get(player->gui.edje, "seeker_grabber",
- &x, &y, &w, &h);
+ edje_object_part_geometry_get(player->gui.edje, "seeker_grabber",
+ &x, &y, &w, &h);
- pos = ((double)(ex - x)) / ((double)w);
- if (pos < 0) pos = 0;
- if (pos > 1) pos = 1;
+ pos = ((double)(ex - x)) / ((double)w);
+
+ if (pos < 0) pos = 0;
+ if (pos > 1) pos = 1;
- track_position_set(player, (int)(pli->duration * pos));
- }
+ track_position_set(player, (int)(pli->duration * pos));
}
-int
-_eplayer_seek_timer(void *data)
+int _eplayer_seek_timer(void *data)
{
- ePlayer *player = data;
- PlayListItem *pli = playlist_current_item_get(player->playlist);
- int new_pos;
+ ePlayer *player = data;
+ PlayListItem *pli = playlist_current_item_get(player->playlist);
+ int new_pos;
- new_pos = pli->current_pos + player->flags.seek_dir;
+ new_pos = pli->current_pos + player->flags.seek_dir;
- if (new_pos <= 0) new_pos = 0;
- if (new_pos > pli->duration) new_pos = pli->duration;
+ if (new_pos <= 0) new_pos = 0;
+ if (new_pos > pli->duration) new_pos = pli->duration;
- track_position_set(player, new_pos);
+ track_position_set(player, new_pos);
- if (player->flags.seeking)
- return 1;
- else
- return 0;
+ return !!player->flags.seeking;
}
/* Handle Key Bindings via EVAS Event Callback */
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/eplayer.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- eplayer.c 16 Jan 2004 01:37:10 -0000 1.25
+++ eplayer.c 24 Jan 2004 20:27:28 -0000 1.26
@@ -4,36 +4,62 @@
#include <config.h>
#include <Edje.h>
#include <Edb.h>
+#include <ltdl.h>
#include <string.h>
-#include <sys/stat.h>
-#include <dirent.h>
+#include <assert.h>
#include "eplayer.h"
#include "interface.h"
#include "track.h"
#include "utils.h"
-static Evas_List *load_input_plugins() {
- Evas_List *files, *l, *plugins = NULL;
+static InputPlugin *find_input_plugin (ePlayer *player,
+ const char *name) {
InputPlugin *ip;
- char name[128];
+ Evas_List *l;
- if (!(files = dir_get_files(PLUGIN_DIR "/input")))
- return NULL;
+ assert(player);
+ assert(name);
+
+ for (l = player->input_plugins; l; l = l->next) {
+ ip = l->data;
+
+ if (!strcasecmp(ip->name, name))
+ return ip;
+ }
+
+ return NULL;
+}
- for (l = files; l; l = l->next) {
- /* get the plugin name from the filename */
- sscanf((char *) l->data, "lib%127[^.].so", name);
-
- if ((ip = plugin_new(name, PLUGIN_TYPE_INPUT)))
- plugins = evas_list_prepend(plugins, ip);
+static int load_input_plugin (const char *file, lt_ptr udata) {
+ ePlayer *player = udata;
+ InputPlugin *ip;
+
+ if (!(ip = plugin_new(file, PLUGIN_TYPE_INPUT))) {
+ fprintf (stderr, "Cannot load plugin: '%s'\n", file);
+ return 0;
}
- while (files) {
- free(files->data);
- files = evas_list_remove(files, files->data);
+ /* only add this plugin if it hasn't been added yet */
+ if (find_input_plugin(player, ip->name)) {
+ plugin_free(ip);
+ return 0;
}
- return plugins;
+ player->input_plugins = evas_list_append(player->input_plugins, ip);
+
+ return 0;
+}
+
+static int load_input_plugins(ePlayer *player) {
+ char path[PATH_MAX * 2 + 1];
+
+ snprintf(path, sizeof(path), "%s/.e/apps/" PACKAGE "/plugins/input:"
+ PLUGIN_DIR "/input", getenv("HOME"));
+
+ lt_dlsetsearchpath(path);
+ lt_dlforeachfile(NULL, load_input_plugin, player);
+
+ return (evas_list_count(player->input_plugins) > 0);
}
static void config_init(Config *cfg) {
@@ -100,6 +126,23 @@
free(player);
}
+static int load_output_plugin(ePlayer *player) {
+ char path[PATH_MAX * 2 + 2], name[64];
+
+ snprintf(path, sizeof(path), "%s/.e/apps/" PACKAGE "/plugins/output:"
+ PLUGIN_DIR "/output", getenv("HOME"));
+
+ lt_dlsetsearchpath(path);
+
+ if (strncmp(player->cfg.output_plugin, "lib", 3))
+ snprintf(name, sizeof(name), "lib%s",
+ player->cfg.output_plugin);
+
+ player->output = plugin_new(name, PLUGIN_TYPE_OUTPUT);
+
+ return !!player->output;
+}
+
static ePlayer *eplayer_new(const char **args) {
ePlayer *player;
char cfg_file[PATH_MAX + 1];
@@ -127,15 +170,11 @@
"falling back to default settings!\n");
}
- player->input_plugins = load_input_plugins();
+ load_input_plugins(player);
player->playlist = playlist_new(player->input_plugins);
- /* load the output plugin */
- player->output = plugin_new(player->cfg.output_plugin,
- PLUGIN_TYPE_OUTPUT);
-
- if (!player->output) {
+ if (!load_output_plugin(player)) {
debug(DEBUG_LEVEL_CRITICAL, "Cannot load %s output plugin!\n",
player->cfg.output_plugin);
@@ -247,6 +286,8 @@
PACKAGE, VERSION, argv[0]);
return 1;
}
+
+ lt_dlinit();
if (!(player = eplayer_new(argv)))
return 1;
@@ -268,6 +309,7 @@
eplayer_free(player);
ui_deinit();
+ lt_dlexit();
return 0;
}
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/plugin.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- plugin.c 30 Nov 2003 15:37:40 -0000 1.3
+++ plugin.c 24 Jan 2004 20:27:28 -0000 1.4
@@ -1,37 +1,12 @@
#include <config.h>
#include <stdlib.h>
-#include <dlfcn.h>
+#include <ltdl.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "utils.h"
#include "plugin.h"
-static char *find_plugin(const char *dir, const char *name) {
- Evas_List *files, *l;
- char *ret = NULL, tmp[128];
-
- if (!(files = dir_get_files(dir)))
- return NULL;
-
- for (l = files; l; l = l->next) {
- /* get the plugin name from the filename */
- sscanf((char *) l->data, "lib%127[^.].so", tmp);
-
- if (!strcasecmp(name, tmp)) {
- ret = strdup(l->data);
- break;
- }
- }
-
- while (files) {
- free(files->data);
- files = evas_list_remove(files, files->data);
- }
-
- return ret;
-}
-
/**
* Creates a new plugin.
*
@@ -39,52 +14,30 @@
* @param type Type of the plugin.
* @return The newly created plugin.
*/
-void *plugin_new(const char *name, PluginType type) {
+void *plugin_new(const char *file, PluginType type) {
InputPlugin *p;
int (*init)(void *p), size;
- char *error, path[PATH_MAX + 1];
- char *dir, *right_name;
- if (!name || !*name)
+ if (!file || !*file)
return NULL;
- if (type == PLUGIN_TYPE_INPUT) {
+ if (type == PLUGIN_TYPE_INPUT)
size = sizeof(InputPlugin);
- dir = PLUGIN_DIR "/input";
- } else {
+ else
size = sizeof(OutputPlugin);
- dir = PLUGIN_DIR "/output";
- }
if (!(p = malloc(size)))
return NULL;
memset(p, 0, size);
- snprintf(path, sizeof(path), "%s/lib%s.so", dir, name);
-
- if (!(p->handle = dlopen(path, RTLD_LAZY))) {
- /* couldn't load plugin, let's try with a
- * case-insensitive search
- */
- if (!(right_name = find_plugin(dir, name))) {
- plugin_free(p);
- return NULL;
- }
-
- snprintf(path, sizeof(path), "%s/%s", dir, right_name);
- free(right_name);
-
- if (!(p->handle = dlopen(path, RTLD_LAZY))) {
- plugin_free(p);
- return NULL;
- }
+ if (!(p->handle = lt_dlopenext(file))) {
+ plugin_free(p);
+ return NULL;
}
/* get the address of the init function */
- init = dlsym(p->handle, "plugin_init");
-
- if ((error = dlerror())) {
+ if (!(init = lt_dlsym(p->handle, "plugin_init"))) {
plugin_free(p);
return NULL;
}
@@ -114,8 +67,11 @@
if (p->shutdown)
p->shutdown();
+ if (p->name)
+ free(p->name);
+
if (p->handle)
- dlclose(p->handle);
+ lt_dlclose(p->handle);
free(p);
}
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/plugin.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -3 -r1.5 -r1.6
--- plugin.h 30 Nov 2003 15:37:40 -0000 1.5
+++ plugin.h 24 Jan 2004 20:27:28 -0000 1.6
@@ -20,6 +20,7 @@
typedef struct {
void *handle;
+ char *name;
void (*debug)(DebugLevel level, const char *fmt, ...);
@@ -41,6 +42,7 @@
typedef struct {
void *handle;
+ char *name;
void (*debug)(DebugLevel level, const char *fmt, ...);
@@ -55,7 +57,7 @@
int (*volume_set)(int left, int right);
} OutputPlugin;
-void *plugin_new(const char *name, PluginType type);
+void *plugin_new(const char *file, PluginType type);
void plugin_free(void *p);
#endif
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs