ethumb: now using ecore_exe to start the slave.
SVN revision: 44092
This commit is contained in:
parent
22e44c2b3b
commit
6cbcfd262f
|
@ -19,16 +19,24 @@ ethumb_DEPENDENCIES = $(top_builddir)/config.h
|
||||||
|
|
||||||
if USE_MODULE_ETHUMBD
|
if USE_MODULE_ETHUMBD
|
||||||
|
|
||||||
AM_CPPFLAGS += @EDBUS_CFLAGS@
|
AM_CPPFLAGS += @EDBUS_CFLAGS@ \
|
||||||
|
-DETHUMB_LIBEXEC_DIR=\"$(libexecdir)\"
|
||||||
bin_PROGRAMS += ethumbd ethumbd_client
|
bin_PROGRAMS += ethumbd ethumbd_client
|
||||||
noinst_HEADERS += ethumbd_private.h
|
noinst_HEADERS += ethumbd_private.h
|
||||||
|
|
||||||
ethumbd_SOURCES = ethumbd.c ethumbd_child.c
|
libexec_PROGRAMS = ethumbd_slave
|
||||||
|
|
||||||
|
ethumbd_SOURCES = ethumbd.c
|
||||||
ethumbd_LDADD = \
|
ethumbd_LDADD = \
|
||||||
@EINA_LIBS@ @ECORE_LIBS@ @EDBUS_LIBS@ \
|
@EINA_LIBS@ @ECORE_LIBS@ @EDBUS_LIBS@ \
|
||||||
$(top_builddir)/src/lib/libethumb.la
|
$(top_builddir)/src/lib/libethumb.la
|
||||||
ethumbd_DEPENDENCIES = $(top_builddir)/config.h
|
ethumbd_DEPENDENCIES = $(top_builddir)/config.h
|
||||||
|
|
||||||
|
ethumbd_slave_SOURCES = ethumbd_child.c
|
||||||
|
ethumbd_slave_LDADD = \
|
||||||
|
@EINA_LIBS@ @ECORE_LIBS@ @EDBUS_LIBS@ \
|
||||||
|
$(top_builddir)/src/lib/libethumb.la
|
||||||
|
|
||||||
ethumbd_client_SOURCES = ethumbd_client.c
|
ethumbd_client_SOURCES = ethumbd_client.c
|
||||||
ethumbd_client_LDADD = \
|
ethumbd_client_LDADD = \
|
||||||
@EINA_LIBS@ @ECORE_LIBS@ \
|
@EINA_LIBS@ @ECORE_LIBS@ \
|
||||||
|
|
|
@ -130,6 +130,16 @@ struct _Ethumb_Queue
|
||||||
int *list;
|
int *list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _Ethumb_Slave
|
||||||
|
{
|
||||||
|
Ecore_Exe *exe;
|
||||||
|
Ecore_Event_Handler *data_cb;
|
||||||
|
Ecore_Event_Handler *del_cb;
|
||||||
|
char *bufcmd; // buffer to read commands from slave
|
||||||
|
int scmd; // size of command to read
|
||||||
|
int pcmd; // position in the command buffer
|
||||||
|
};
|
||||||
|
|
||||||
struct _Ethumbd
|
struct _Ethumbd
|
||||||
{
|
{
|
||||||
E_DBus_Connection *conn;
|
E_DBus_Connection *conn;
|
||||||
|
@ -139,11 +149,9 @@ struct _Ethumbd
|
||||||
Ecore_Idler *idler;
|
Ecore_Idler *idler;
|
||||||
struct _Ethumb_Request *processing;
|
struct _Ethumb_Request *processing;
|
||||||
struct _Ethumb_Queue queue;
|
struct _Ethumb_Queue queue;
|
||||||
int pipeout;
|
|
||||||
int pipein;
|
|
||||||
Ecore_Fd_Handler *fd_handler;
|
|
||||||
double timeout;
|
double timeout;
|
||||||
Ecore_Timer *timeout_timer;
|
Ecore_Timer *timeout_timer;
|
||||||
|
struct _Ethumb_Slave slave;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _Ethumb_Object_Data
|
struct _Ethumb_Object_Data
|
||||||
|
@ -189,6 +197,7 @@ const Ecore_Getopt optdesc = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _ethumb_dbus_generated_signal(struct _Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success);
|
static void _ethumb_dbus_generated_signal(struct _Ethumbd *ed, int *id, const char *thumb_path, const char *thumb_key, Eina_Bool success);
|
||||||
|
static int _ethumbd_slave_spawn(struct _Ethumbd *ed);
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ethumbd_timeout_cb(void *data)
|
_ethumbd_timeout_cb(void *data)
|
||||||
|
@ -270,75 +279,16 @@ _ethumb_dbus_inc_min_id(struct _Ethumb_Object *eobject)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
_ethumbd_read_safe(int fd, void *buf, ssize_t size)
|
_ethumbd_write_safe(struct _Ethumbd *ed, const void *buf, ssize_t size)
|
||||||
{
|
{
|
||||||
ssize_t todo;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
todo = size;
|
if (!ed->slave.exe)
|
||||||
p = buf;
|
|
||||||
|
|
||||||
while (todo > 0)
|
|
||||||
{
|
{
|
||||||
ssize_t r;
|
ERR("slave process isn't running.\n");
|
||||||
|
return 0;
|
||||||
r = read(fd, p, todo);
|
|
||||||
if (r > 0)
|
|
||||||
{
|
|
||||||
todo -= r;
|
|
||||||
p += r;
|
|
||||||
}
|
|
||||||
else if (r == 0)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("could not read from fd %d: %s",
|
|
||||||
fd, strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
_ethumbd_write_safe(int fd, const void *buf, ssize_t size)
|
|
||||||
{
|
|
||||||
ssize_t todo;
|
|
||||||
const char *p;
|
|
||||||
|
|
||||||
todo = size;
|
|
||||||
p = buf;
|
|
||||||
|
|
||||||
while (todo > 0)
|
|
||||||
{
|
|
||||||
ssize_t r;
|
|
||||||
|
|
||||||
r = write(fd, p, todo);
|
|
||||||
if (r > 0)
|
|
||||||
{
|
|
||||||
todo -= r;
|
|
||||||
p += r;
|
|
||||||
}
|
|
||||||
else if (r == 0)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (errno == EINTR || errno == EAGAIN)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ERR("could not write to fd %d: %s", fd, strerror(errno));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ecore_exe_send(ed->slave.exe, buf, size);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,20 +296,20 @@ static void
|
||||||
_ethumbd_child_write_op_new(struct _Ethumbd *ed, int index)
|
_ethumbd_child_write_op_new(struct _Ethumbd *ed, int index)
|
||||||
{
|
{
|
||||||
int id = ETHUMBD_OP_NEW;
|
int id = ETHUMBD_OP_NEW;
|
||||||
_ethumbd_write_safe(ed->pipeout, &id, sizeof(id));
|
_ethumbd_write_safe(ed, &id, sizeof(id));
|
||||||
_ethumbd_write_safe(ed->pipeout, &index, sizeof(index));
|
_ethumbd_write_safe(ed, &index, sizeof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethumbd_child_write_op_del(struct _Ethumbd *ed, int index)
|
_ethumbd_child_write_op_del(struct _Ethumbd *ed, int index)
|
||||||
{
|
{
|
||||||
int id = ETHUMBD_OP_DEL;
|
int id = ETHUMBD_OP_DEL;
|
||||||
_ethumbd_write_safe(ed->pipeout, &id, sizeof(id));
|
_ethumbd_write_safe(ed, &id, sizeof(id));
|
||||||
_ethumbd_write_safe(ed->pipeout, &index, sizeof(index));
|
_ethumbd_write_safe(ed, &index, sizeof(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethumbd_pipe_str_write(int fd, const char *str)
|
_ethumbd_pipe_str_write(struct _Ethumbd *ed, const char *str)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
@ -368,39 +318,8 @@ _ethumbd_pipe_str_write(int fd, const char *str)
|
||||||
else
|
else
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
_ethumbd_write_safe(fd, &len, sizeof(len));
|
_ethumbd_write_safe(ed, &len, sizeof(len));
|
||||||
_ethumbd_write_safe(fd, str, len);
|
_ethumbd_write_safe(ed, str, len);
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
_ethumbd_pipe_str_read(int fd, char **str)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
int r;
|
|
||||||
char buf[PATH_MAX];
|
|
||||||
|
|
||||||
r = _ethumbd_read_safe(fd, &size, sizeof(size));
|
|
||||||
if (!r)
|
|
||||||
{
|
|
||||||
*str = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!size)
|
|
||||||
{
|
|
||||||
*str = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = _ethumbd_read_safe(fd, buf, size);
|
|
||||||
if (!r)
|
|
||||||
{
|
|
||||||
*str = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
*str = strdup(buf);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -408,13 +327,13 @@ _ethumbd_child_write_op_generate(struct _Ethumbd *ed, int index, const char *pat
|
||||||
{
|
{
|
||||||
int id = ETHUMBD_OP_GENERATE;
|
int id = ETHUMBD_OP_GENERATE;
|
||||||
|
|
||||||
_ethumbd_write_safe(ed->pipeout, &id, sizeof(id));
|
_ethumbd_write_safe(ed, &id, sizeof(id));
|
||||||
_ethumbd_write_safe(ed->pipeout, &index, sizeof(index));
|
_ethumbd_write_safe(ed, &index, sizeof(index));
|
||||||
|
|
||||||
_ethumbd_pipe_str_write(ed->pipeout, path);
|
_ethumbd_pipe_str_write(ed, path);
|
||||||
_ethumbd_pipe_str_write(ed->pipeout, key);
|
_ethumbd_pipe_str_write(ed, key);
|
||||||
_ethumbd_pipe_str_write(ed->pipeout, thumb_path);
|
_ethumbd_pipe_str_write(ed, thumb_path);
|
||||||
_ethumbd_pipe_str_write(ed->pipeout, thumb_key);
|
_ethumbd_pipe_str_write(ed, thumb_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -435,47 +354,153 @@ _generated_cb(struct _Ethumbd *ed, Eina_Bool success, const char *thumb_path, co
|
||||||
ed->processing = NULL;
|
ed->processing = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_ethumbd_slave_cmd_ready(struct _Ethumbd *ed)
|
||||||
|
{
|
||||||
|
char *bufcmd = ed->slave.bufcmd;
|
||||||
|
Eina_Bool *success;
|
||||||
|
char *thumb_path, *thumb_key;
|
||||||
|
int *size_path, *size_key;
|
||||||
|
|
||||||
|
|
||||||
|
success = (Eina_Bool *)bufcmd;
|
||||||
|
bufcmd += sizeof(*success);
|
||||||
|
|
||||||
|
size_path = (int *)bufcmd;
|
||||||
|
bufcmd += sizeof(*size_path);
|
||||||
|
|
||||||
|
write(STDERR_FILENO, bufcmd, ed->slave.scmd);
|
||||||
|
|
||||||
|
thumb_path = bufcmd;
|
||||||
|
bufcmd += *size_path;
|
||||||
|
|
||||||
|
size_key = (int *)bufcmd;
|
||||||
|
bufcmd += sizeof(*size_key);
|
||||||
|
|
||||||
|
thumb_key = bufcmd;
|
||||||
|
|
||||||
|
_generated_cb(ed, *success, thumb_path, thumb_key);
|
||||||
|
|
||||||
|
free(ed->slave.bufcmd);
|
||||||
|
ed->slave.bufcmd = NULL;
|
||||||
|
ed->slave.scmd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ethumbd_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
|
_ethumbd_slave_alloc_cmd(struct _Ethumbd *ed, int ssize, char *sdata)
|
||||||
|
{
|
||||||
|
int *scmd;
|
||||||
|
|
||||||
|
if (ed->slave.bufcmd)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
scmd = (int *)sdata;
|
||||||
|
if (ssize < sizeof(*scmd)) {
|
||||||
|
ERR("could not read size of command.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
ed->slave.bufcmd = malloc(*scmd);
|
||||||
|
ed->slave.scmd = *scmd;
|
||||||
|
ed->slave.pcmd = 0;
|
||||||
|
|
||||||
|
return sizeof(*scmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ethumbd_slave_data_read_cb(void *data, int type, void *event)
|
||||||
{
|
{
|
||||||
struct _Ethumbd *ed = data;
|
struct _Ethumbd *ed = data;
|
||||||
Eina_Bool success;
|
Ecore_Exe_Event_Data *ev = event;
|
||||||
int r;
|
int ssize;
|
||||||
char *thumb_path, *thumb_key;
|
char *sdata;
|
||||||
|
|
||||||
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_ERROR))
|
if (ev->exe != ed->slave.exe)
|
||||||
{
|
{
|
||||||
ERR("error on pipein! child exiting...\n");
|
ERR("PARENT ERROR: slave != ev->exe\n");
|
||||||
ed->fd_handler = NULL;
|
|
||||||
ecore_main_loop_quit();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = _ethumbd_read_safe(ed->pipein, &success, sizeof(success));
|
ssize = ev->size;
|
||||||
if (!r)
|
sdata = ev->data;
|
||||||
|
|
||||||
|
write(STDERR_FILENO, sdata, ssize);
|
||||||
|
|
||||||
|
while (ssize > 0)
|
||||||
{
|
{
|
||||||
ERR("ethumbd child exited!\n");
|
if (!ed->slave.bufcmd)
|
||||||
ed->fd_handler = NULL;
|
{
|
||||||
return 0;
|
int n;
|
||||||
|
n = _ethumbd_slave_alloc_cmd(ed, ssize, sdata);
|
||||||
|
ssize -= n;
|
||||||
|
sdata += n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *bdata;
|
||||||
|
int nbytes;
|
||||||
|
bdata = ed->slave.bufcmd + ed->slave.pcmd;
|
||||||
|
nbytes = ed->slave.scmd - ed->slave.pcmd;
|
||||||
|
nbytes = ssize < nbytes ? ssize : nbytes;
|
||||||
|
memcpy(bdata, sdata, nbytes);
|
||||||
|
sdata += nbytes;
|
||||||
|
ssize -= nbytes;
|
||||||
|
ed->slave.pcmd += nbytes;
|
||||||
|
|
||||||
|
if (ed->slave.pcmd == ed->slave.scmd)
|
||||||
|
_ethumbd_slave_cmd_ready(ed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = _ethumbd_pipe_str_read(ed->pipein, &thumb_path);
|
|
||||||
r = _ethumbd_pipe_str_read(ed->pipein, &thumb_key);
|
|
||||||
_generated_cb(ed, success, thumb_path, thumb_key);
|
|
||||||
|
|
||||||
free(thumb_path);
|
|
||||||
free(thumb_key);
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_ethumbd_slave_del_cb(void *data, int type, void *event)
|
||||||
|
{
|
||||||
|
struct _Ethumbd *ed = data;
|
||||||
|
Ecore_Exe_Event_Del *ev = event;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (ev->exe != ed->slave.exe)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (ev->exited)
|
||||||
|
ERR("slave exited with code: %d\n", ev->exit_code);
|
||||||
|
else if (ev->signalled)
|
||||||
|
ERR("slave exited by signal: %d\n", ev->exit_signal);
|
||||||
|
|
||||||
|
if (!ed->processing)
|
||||||
|
goto end;
|
||||||
|
|
||||||
|
i = ed->queue.current;
|
||||||
|
ERR("failed to generate thumbnail for: \"%s:%s\"\n",
|
||||||
|
ed->processing->file, ed->processing->key);
|
||||||
|
|
||||||
|
if (ed->queue.table[i].used)
|
||||||
|
_ethumb_dbus_generated_signal
|
||||||
|
(ed, &ed->processing->id, NULL, NULL, EINA_FALSE);
|
||||||
|
eina_stringshare_del(ed->processing->file);
|
||||||
|
eina_stringshare_del(ed->processing->key);
|
||||||
|
eina_stringshare_del(ed->processing->thumb);
|
||||||
|
eina_stringshare_del(ed->processing->thumb_key);
|
||||||
|
free(ed->processing);
|
||||||
|
ed->processing = NULL;
|
||||||
|
|
||||||
|
end:
|
||||||
|
ed->slave.exe = NULL;
|
||||||
|
if (ed->slave.bufcmd)
|
||||||
|
free(ed->slave.bufcmd);
|
||||||
|
|
||||||
|
return _ethumbd_slave_spawn(ed);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ethumbd_pipe_write_setup(int fd, int type, const void *data)
|
_ethumbd_pipe_write_setup(struct _Ethumbd *ed, int type, const void *data)
|
||||||
{
|
{
|
||||||
const int *i_value;
|
const int *i_value;
|
||||||
const float *f_value;
|
const float *f_value;
|
||||||
|
|
||||||
_ethumbd_write_safe(fd, &type, sizeof(type));
|
_ethumbd_write_safe(ed, &type, sizeof(type));
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
@ -490,7 +515,7 @@ _ethumbd_pipe_write_setup(int fd, int type, const void *data)
|
||||||
case ETHUMBD_VIDEO_NTIMES:
|
case ETHUMBD_VIDEO_NTIMES:
|
||||||
case ETHUMBD_VIDEO_FPS:
|
case ETHUMBD_VIDEO_FPS:
|
||||||
i_value = data;
|
i_value = data;
|
||||||
_ethumbd_write_safe(fd, i_value, sizeof(*i_value));
|
_ethumbd_write_safe(ed, i_value, sizeof(*i_value));
|
||||||
break;
|
break;
|
||||||
case ETHUMBD_CROP_X:
|
case ETHUMBD_CROP_X:
|
||||||
case ETHUMBD_CROP_Y:
|
case ETHUMBD_CROP_Y:
|
||||||
|
@ -498,14 +523,14 @@ _ethumbd_pipe_write_setup(int fd, int type, const void *data)
|
||||||
case ETHUMBD_VIDEO_START:
|
case ETHUMBD_VIDEO_START:
|
||||||
case ETHUMBD_VIDEO_INTERVAL:
|
case ETHUMBD_VIDEO_INTERVAL:
|
||||||
f_value = data;
|
f_value = data;
|
||||||
_ethumbd_write_safe(fd, f_value, sizeof(*f_value));
|
_ethumbd_write_safe(ed, f_value, sizeof(*f_value));
|
||||||
break;
|
break;
|
||||||
case ETHUMBD_DIRECTORY:
|
case ETHUMBD_DIRECTORY:
|
||||||
case ETHUMBD_CATEGORY:
|
case ETHUMBD_CATEGORY:
|
||||||
case ETHUMBD_FRAME_FILE:
|
case ETHUMBD_FRAME_FILE:
|
||||||
case ETHUMBD_FRAME_GROUP:
|
case ETHUMBD_FRAME_GROUP:
|
||||||
case ETHUMBD_FRAME_SWALLOW:
|
case ETHUMBD_FRAME_SWALLOW:
|
||||||
_ethumbd_pipe_str_write(fd, data);
|
_ethumbd_pipe_str_write(ed, data);
|
||||||
break;
|
break;
|
||||||
case ETHUMBD_SETUP_FINISHED:
|
case ETHUMBD_SETUP_FINISHED:
|
||||||
break;
|
break;
|
||||||
|
@ -519,58 +544,57 @@ _process_setup(struct _Ethumbd *ed)
|
||||||
{
|
{
|
||||||
int op_id = ETHUMBD_OP_SETUP;
|
int op_id = ETHUMBD_OP_SETUP;
|
||||||
int index = ed->queue.current;
|
int index = ed->queue.current;
|
||||||
int fd = ed->pipeout;
|
|
||||||
|
|
||||||
struct _Ethumb_Setup *setup = &ed->processing->setup;
|
struct _Ethumb_Setup *setup = &ed->processing->setup;
|
||||||
|
|
||||||
_ethumbd_write_safe(ed->pipeout, &op_id, sizeof(op_id));
|
_ethumbd_write_safe(ed, &op_id, sizeof(op_id));
|
||||||
_ethumbd_write_safe(ed->pipeout, &index, sizeof(index));
|
_ethumbd_write_safe(ed, &index, sizeof(index));
|
||||||
|
|
||||||
if (setup->flags.fdo)
|
if (setup->flags.fdo)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_FDO, &setup->fdo);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_FDO, &setup->fdo);
|
||||||
if (setup->flags.size)
|
if (setup->flags.size)
|
||||||
{
|
{
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_SIZE_W, &setup->tw);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_SIZE_W, &setup->tw);
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_SIZE_H, &setup->th);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_SIZE_H, &setup->th);
|
||||||
}
|
}
|
||||||
if (setup->flags.format)
|
if (setup->flags.format)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_FORMAT, &setup->format);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_FORMAT, &setup->format);
|
||||||
if (setup->flags.aspect)
|
if (setup->flags.aspect)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_ASPECT, &setup->aspect);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_ASPECT, &setup->aspect);
|
||||||
if (setup->flags.crop)
|
if (setup->flags.crop)
|
||||||
{
|
{
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_CROP_X, &setup->cx);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_CROP_X, &setup->cx);
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_CROP_Y, &setup->cy);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_CROP_Y, &setup->cy);
|
||||||
}
|
}
|
||||||
if (setup->flags.quality)
|
if (setup->flags.quality)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_QUALITY, &setup->quality);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_QUALITY, &setup->quality);
|
||||||
if (setup->flags.compress)
|
if (setup->flags.compress)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_COMPRESS, &setup->compress);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_COMPRESS, &setup->compress);
|
||||||
if (setup->flags.directory)
|
if (setup->flags.directory)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_DIRECTORY, setup->directory);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_DIRECTORY, setup->directory);
|
||||||
if (setup->flags.category)
|
if (setup->flags.category)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_CATEGORY, setup->category);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_CATEGORY, setup->category);
|
||||||
if (setup->flags.frame)
|
if (setup->flags.frame)
|
||||||
{
|
{
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_FRAME_FILE, setup->theme_file);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_FRAME_FILE, setup->theme_file);
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_FRAME_GROUP, setup->group);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_FRAME_GROUP, setup->group);
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_FRAME_SWALLOW, setup->swallow);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_FRAME_SWALLOW, setup->swallow);
|
||||||
}
|
}
|
||||||
if (setup->flags.video_time)
|
if (setup->flags.video_time)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_VIDEO_TIME, &setup->video_time);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_VIDEO_TIME, &setup->video_time);
|
||||||
if (setup->flags.video_start)
|
if (setup->flags.video_start)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_VIDEO_START, &setup->video_start);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_VIDEO_START, &setup->video_start);
|
||||||
if (setup->flags.video_interval)
|
if (setup->flags.video_interval)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_VIDEO_INTERVAL,
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_VIDEO_INTERVAL,
|
||||||
&setup->video_interval);
|
&setup->video_interval);
|
||||||
if (setup->flags.video_ntimes)
|
if (setup->flags.video_ntimes)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_VIDEO_NTIMES, &setup->video_ntimes);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_VIDEO_NTIMES, &setup->video_ntimes);
|
||||||
if (setup->flags.video_fps)
|
if (setup->flags.video_fps)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_VIDEO_FPS, &setup->video_fps);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_VIDEO_FPS, &setup->video_fps);
|
||||||
if (setup->flags.document_page)
|
if (setup->flags.document_page)
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_DOCUMENT_PAGE,
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_DOCUMENT_PAGE,
|
||||||
&setup->document_page);
|
&setup->document_page);
|
||||||
_ethumbd_pipe_write_setup(fd, ETHUMBD_SETUP_FINISHED, NULL);
|
_ethumbd_pipe_write_setup(ed, ETHUMBD_SETUP_FINISHED, NULL);
|
||||||
|
|
||||||
|
|
||||||
if (setup->directory) eina_stringshare_del(setup->directory);
|
if (setup->directory) eina_stringshare_del(setup->directory);
|
||||||
|
@ -1706,49 +1730,26 @@ _ethumb_dbus_finish(struct _Ethumbd *ed)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_ethumbd_spawn(struct _Ethumbd *ed)
|
_ethumbd_slave_spawn(struct _Ethumbd *ed)
|
||||||
{
|
{
|
||||||
int pparent[2]; // parent writes here
|
ed->slave.data_cb = ecore_event_handler_add(
|
||||||
int pchild[2]; // child writes here
|
ECORE_EXE_EVENT_DATA, _ethumbd_slave_data_read_cb, ed);
|
||||||
int pid;
|
ed->slave.del_cb = ecore_event_handler_add(
|
||||||
|
ECORE_EXE_EVENT_DEL, _ethumbd_slave_del_cb, ed);
|
||||||
|
|
||||||
if (pipe(pparent) == -1)
|
ed->slave.bufcmd = NULL;
|
||||||
|
ed->slave.scmd = 0;
|
||||||
|
|
||||||
|
ed->slave.exe = ecore_exe_pipe_run(
|
||||||
|
ETHUMB_LIBEXEC_DIR"/ethumbd_slave",
|
||||||
|
ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_WRITE, ed);
|
||||||
|
if (!ed->slave.exe)
|
||||||
{
|
{
|
||||||
ERR("could not create parent pipe.\n");
|
ERR("could not create slave.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pipe(pchild) == -1)
|
return 1;
|
||||||
{
|
|
||||||
ERR("could not create child pipe.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pid = fork();
|
|
||||||
if (pid == -1)
|
|
||||||
{
|
|
||||||
ERR("fork error.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pid == 0)
|
|
||||||
{
|
|
||||||
close(pparent[1]);
|
|
||||||
close(pchild[0]);
|
|
||||||
ethumbd_child_start(pparent[0], pchild[1]);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
close(pparent[0]);
|
|
||||||
close(pchild[1]);
|
|
||||||
ed->pipeout = pparent[1];
|
|
||||||
ed->pipein = pchild[0];
|
|
||||||
ed->fd_handler = ecore_main_fd_handler_add
|
|
||||||
(ed->pipein, ECORE_FD_READ | ECORE_FD_ERROR,
|
|
||||||
_ethumbd_fd_handler, ed, NULL, NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -1767,7 +1768,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
ethumb_init();
|
ethumb_init();
|
||||||
|
|
||||||
child = _ethumbd_spawn(&ed);
|
child = _ethumbd_slave_spawn(&ed);
|
||||||
if (!child)
|
if (!child)
|
||||||
{
|
{
|
||||||
exit_value = -6;
|
exit_value = -6;
|
||||||
|
@ -1831,6 +1832,8 @@ main(int argc, char *argv[])
|
||||||
finish_edbus:
|
finish_edbus:
|
||||||
e_dbus_shutdown();
|
e_dbus_shutdown();
|
||||||
finish:
|
finish:
|
||||||
|
if (ed.slave.exe)
|
||||||
|
ecore_exe_quit(ed.slave.exe);
|
||||||
ethumb_shutdown();
|
ethumb_shutdown();
|
||||||
eina_init();
|
eina_init();
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
|
|
|
@ -47,7 +47,6 @@ struct _Ethumbd_Child
|
||||||
{
|
{
|
||||||
Ecore_Fd_Handler *fd_handler;
|
Ecore_Fd_Handler *fd_handler;
|
||||||
Ethumb *ethumbt[NETHUMBS];
|
Ethumb *ethumbt[NETHUMBS];
|
||||||
int pipein, pipeout;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +130,7 @@ _ec_pipe_str_read(struct _Ethumbd_Child *ec, char **str)
|
||||||
int r;
|
int r;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &size, sizeof(size));
|
r = _ec_read_safe(STDIN_FILENO, &size, sizeof(size));
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
*str = NULL;
|
*str = NULL;
|
||||||
|
@ -144,7 +143,7 @@ _ec_pipe_str_read(struct _Ethumbd_Child *ec, char **str)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, buf, size);
|
r = _ec_read_safe(STDIN_FILENO, buf, size);
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
*str = NULL;
|
*str = NULL;
|
||||||
|
@ -155,28 +154,11 @@ _ec_pipe_str_read(struct _Ethumbd_Child *ec, char **str)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_ec_pipe_str_write(struct _Ethumbd_Child *ec, const char *str)
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if (!str)
|
|
||||||
size = 0;
|
|
||||||
else
|
|
||||||
size = strlen(str) + 1;
|
|
||||||
|
|
||||||
_ec_write_safe(ec->pipeout, &size, sizeof(size));
|
|
||||||
_ec_write_safe(ec->pipeout, str, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct _Ethumbd_Child *
|
static struct _Ethumbd_Child *
|
||||||
_ec_new(int pipein, int pipeout)
|
_ec_new(void)
|
||||||
{
|
{
|
||||||
struct _Ethumbd_Child *ec = calloc(1, sizeof(*ec));
|
struct _Ethumbd_Child *ec = calloc(1, sizeof(*ec));
|
||||||
|
|
||||||
ec->pipein = pipein;
|
|
||||||
ec->pipeout = pipeout;
|
|
||||||
|
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +185,7 @@ _ec_op_new(struct _Ethumbd_Child *ec)
|
||||||
int r;
|
int r;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index));
|
r = _ec_read_safe(STDIN_FILENO, &index, sizeof(index));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -219,7 +201,7 @@ _ec_op_del(struct _Ethumbd_Child *ec)
|
||||||
int r;
|
int r;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index));
|
r = _ec_read_safe(STDIN_FILENO, &index, sizeof(index));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -233,15 +215,34 @@ _ec_op_del(struct _Ethumbd_Child *ec)
|
||||||
static void
|
static void
|
||||||
_ec_op_generated_cb(void *data, Ethumb *e, Eina_Bool success)
|
_ec_op_generated_cb(void *data, Ethumb *e, Eina_Bool success)
|
||||||
{
|
{
|
||||||
struct _Ethumbd_Child *ec = data;
|
|
||||||
const char *thumb_path, *thumb_key;
|
const char *thumb_path, *thumb_key;
|
||||||
|
int size_path, size_key, size_cmd;
|
||||||
|
|
||||||
|
fprintf(stderr, "thumbnail generated!\n");
|
||||||
DBG("thumb generated!\n");
|
DBG("thumb generated!\n");
|
||||||
ethumb_thumb_path_get(e, &thumb_path, &thumb_key);
|
ethumb_thumb_path_get(e, &thumb_path, &thumb_key);
|
||||||
_ec_write_safe(ec->pipeout, &success, sizeof(success));
|
|
||||||
|
|
||||||
_ec_pipe_str_write(ec, thumb_path);
|
if (!thumb_path)
|
||||||
_ec_pipe_str_write(ec, thumb_key);
|
size_path = 0;
|
||||||
|
else
|
||||||
|
size_path = strlen(thumb_path) + 1;
|
||||||
|
|
||||||
|
if (!thumb_key)
|
||||||
|
size_key = 0;
|
||||||
|
else
|
||||||
|
size_key = strlen(thumb_key) + 1;
|
||||||
|
|
||||||
|
size_cmd = sizeof(success) + sizeof(size_path) + size_path +
|
||||||
|
sizeof(size_key) + size_key;
|
||||||
|
|
||||||
|
_ec_write_safe(STDOUT_FILENO, &size_cmd, sizeof(size_cmd));
|
||||||
|
_ec_write_safe(STDOUT_FILENO, &success, sizeof(success));
|
||||||
|
|
||||||
|
_ec_write_safe(STDOUT_FILENO, &size_path, sizeof(size_path));
|
||||||
|
_ec_write_safe(STDOUT_FILENO, thumb_path, size_path);
|
||||||
|
|
||||||
|
_ec_write_safe(STDOUT_FILENO, &size_key, sizeof(size_key));
|
||||||
|
_ec_write_safe(STDOUT_FILENO, thumb_key, size_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -251,7 +252,7 @@ _ec_op_generate(struct _Ethumbd_Child *ec)
|
||||||
char *path, *key, *thumb_path, *thumb_key;
|
char *path, *key, *thumb_path, *thumb_key;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index));
|
r = _ec_read_safe(STDIN_FILENO, &index, sizeof(index));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ _ec_fdo_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_fdo_set(e, value);
|
ethumb_thumb_fdo_set(e, value);
|
||||||
|
@ -302,13 +303,13 @@ _ec_size_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int w, h;
|
int w, h;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &w, sizeof(w));
|
r = _ec_read_safe(STDIN_FILENO, &w, sizeof(w));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &h, sizeof(h));
|
r = _ec_read_safe(STDIN_FILENO, &h, sizeof(h));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_size_set(e, w, h);
|
ethumb_thumb_size_set(e, w, h);
|
||||||
|
@ -323,7 +324,7 @@ _ec_format_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_format_set(e, value);
|
ethumb_thumb_format_set(e, value);
|
||||||
|
@ -338,7 +339,7 @@ _ec_aspect_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_aspect_set(e, value);
|
ethumb_thumb_aspect_set(e, value);
|
||||||
|
@ -354,13 +355,13 @@ _ec_crop_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
float x, y;
|
float x, y;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &x, sizeof(x));
|
r = _ec_read_safe(STDIN_FILENO, &x, sizeof(x));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &y, sizeof(y));
|
r = _ec_read_safe(STDIN_FILENO, &y, sizeof(y));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_crop_align_set(e, x, y);
|
ethumb_thumb_crop_align_set(e, x, y);
|
||||||
|
@ -375,7 +376,7 @@ _ec_quality_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_quality_set(e, value);
|
ethumb_thumb_quality_set(e, value);
|
||||||
|
@ -390,7 +391,7 @@ _ec_compress_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_thumb_compress_set(e, value);
|
ethumb_thumb_compress_set(e, value);
|
||||||
|
@ -409,13 +410,13 @@ _ec_frame_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
r = _ec_pipe_str_read(ec, &theme_file);
|
r = _ec_pipe_str_read(ec, &theme_file);
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_pipe_str_read(ec, &group);
|
r = _ec_pipe_str_read(ec, &group);
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
r = _ec_pipe_str_read(ec, &swallow);
|
r = _ec_pipe_str_read(ec, &swallow);
|
||||||
|
@ -468,7 +469,7 @@ _ec_video_time_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_video_time_set(e, value);
|
ethumb_video_time_set(e, value);
|
||||||
|
@ -483,7 +484,7 @@ _ec_video_start_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_video_start_set(e, value);
|
ethumb_video_start_set(e, value);
|
||||||
|
@ -498,7 +499,7 @@ _ec_video_interval_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_video_interval_set(e, value);
|
ethumb_video_interval_set(e, value);
|
||||||
|
@ -513,7 +514,7 @@ _ec_video_ntimes_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_video_ntimes_set(e, value);
|
ethumb_video_ntimes_set(e, value);
|
||||||
|
@ -528,7 +529,7 @@ _ec_video_fps_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_video_fps_set(e, value);
|
ethumb_video_fps_set(e, value);
|
||||||
|
@ -543,7 +544,7 @@ _ec_document_page_set(struct _Ethumbd_Child *ec, Ethumb *e)
|
||||||
int r;
|
int r;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &value, sizeof(value));
|
r = _ec_read_safe(STDIN_FILENO, &value, sizeof(value));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
ethumb_document_page_set(e, value);
|
ethumb_document_page_set(e, value);
|
||||||
|
@ -621,17 +622,17 @@ _ec_op_setup(struct _Ethumbd_Child *ec)
|
||||||
int index;
|
int index;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &index, sizeof(index));
|
r = _ec_read_safe(STDIN_FILENO, &index, sizeof(index));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
while (type != ETHUMBD_SETUP_FINISHED)
|
while (type != ETHUMBD_SETUP_FINISHED)
|
||||||
{
|
{
|
||||||
_ec_setup_process(ec, index, type);
|
_ec_setup_process(ec, index, type);
|
||||||
r = _ec_read_safe(ec->pipein, &type, sizeof(type));
|
r = _ec_read_safe(STDIN_FILENO, &type, sizeof(type));
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -654,7 +655,7 @@ _ec_fd_handler(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = _ec_read_safe(ec->pipein, &op_id, sizeof(op_id));
|
r = _ec_read_safe(STDIN_FILENO, &op_id, sizeof(op_id));
|
||||||
if (!r)
|
if (!r)
|
||||||
{
|
{
|
||||||
DBG("ethumbd exited! child exiting...\n");
|
DBG("ethumbd exited! child exiting...\n");
|
||||||
|
@ -699,18 +700,18 @@ static void
|
||||||
_ec_setup(struct _Ethumbd_Child *ec)
|
_ec_setup(struct _Ethumbd_Child *ec)
|
||||||
{
|
{
|
||||||
ec->fd_handler = ecore_main_fd_handler_add(
|
ec->fd_handler = ecore_main_fd_handler_add(
|
||||||
ec->pipein, ECORE_FD_READ | ECORE_FD_ERROR,
|
STDIN_FILENO, ECORE_FD_READ | ECORE_FD_ERROR,
|
||||||
_ec_fd_handler, ec, NULL, NULL);
|
_ec_fd_handler, ec, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
int
|
||||||
ethumbd_child_start(int pipein, int pipeout)
|
main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
struct _Ethumbd_Child *ec;
|
struct _Ethumbd_Child *ec;
|
||||||
|
|
||||||
ethumb_init();
|
ethumb_init();
|
||||||
|
|
||||||
ec = _ec_new(pipein, pipeout);
|
ec = _ec_new();
|
||||||
|
|
||||||
_ec_setup(ec);
|
_ec_setup(ec);
|
||||||
|
|
||||||
|
@ -721,4 +722,6 @@ ethumbd_child_start(int pipein, int pipeout)
|
||||||
_ec_free(ec);
|
_ec_free(ec);
|
||||||
|
|
||||||
ethumb_shutdown();
|
ethumb_shutdown();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue