#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
+
#include <Eina.h>
#include <Evas.h>
+#include <Ecore.h>
#include "Emotion.h"
#include "emotion_private.h"
ERR("invalid command to player.");
return;
}
- write(ev->fd_write, &cmd, sizeof(cmd));
+ if (write(ev->fd_write, &cmd, sizeof(cmd)) < 0) perror("write");
}
static void
_player_send_int(Emotion_Generic_Video *ev, int number)
{
- write(ev->fd_write, &number, sizeof(number));
+ if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
}
static void
_player_send_float(Emotion_Generic_Video *ev, float number)
{
- write(ev->fd_write, &number, sizeof(number));
+ if (write(ev->fd_write, &number, sizeof(number)) < 0) perror("write");
}
static void
len = eina_stringshare_strlen(str) + 1;
else
len = strlen(str) + 1;
- write(ev->fd_write, &len, sizeof(len));
- write(ev->fd_write, str, len);
+ if (write(ev->fd_write, &len, sizeof(len)) < 0) perror("write");
+ if (write(ev->fd_write, str, len) < 0) perror("write");
}
static Eina_Bool
vs = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_SHARED, shmfd, 0);
if (vs == MAP_FAILED)
{
- ERR("error when mapping shared memory.\n");
+ ERR("error when mapping shared memory");
return EINA_FALSE;
}
vs->frame.last = 2;
vs->frame.next = 2;
vs->frame_drop = 0;
- sem_init(&vs->lock, 1, 1);
+ if (!eina_semaphore_new(&vs->lock, 1))
+ {
+ ERR("can not create semaphore");
+ return EINA_FALSE;
+ }
ev->frame.frames[0] = (unsigned char *)vs + sizeof(*vs);
ev->frame.frames[1] = (unsigned char *)vs + sizeof(*vs) + vs->height * vs->width * vs->pitch;
ev->frame.frames[2] = (unsigned char *)vs + sizeof(*vs) + 2 * vs->height * vs->width * vs->pitch;
_file_open(ev);
}
-static int
-_em_read_safe(int fd, void *buf, ssize_t size)
-{
- ssize_t todo;
- char *p;
-
- todo = size;
- p = buf;
-
- while (todo > 0)
- {
- ssize_t r;
-
- r = read(fd, p, todo);
- if (r > 0)
- {
- todo -= r;
- p += r;
- }
- else if (r == 0)
- return 0;
- else
- {
- if (errno == EINTR || errno == EAGAIN)
- return size - todo;
- else
- {
- ERR("could not read from fd %d: %s", fd, strerror(errno));
- return -1;
- }
- }
- }
-
- return size;
-}
-
static Eina_Bool
_player_cmd_param_read(Emotion_Generic_Video *ev, void *param, size_t size)
{
return EINA_FALSE;
}
-static Eina_Bool
-_player_int_read(Emotion_Generic_Video *ev, int *i)
-{
- int n;
- n = _em_read_safe(ev->fd_read, i, sizeof(*i));
- if (n <= 0)
- {
- ERR("could not read int from fd_read %d\n", ev->fd_read);
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
-}
-
-static Eina_Bool
-_player_str_read(Emotion_Generic_Video *ev, char *str, int *len)
-{
- int n;
-
- if (!_player_int_read(ev, len))
- return EINA_FALSE;
-
- n = _em_read_safe(ev->fd_read, str, *len);
- if (n <= 0)
- {
- ERR("could not read string from fd_read %d\n", ev->fd_read);
- return EINA_FALSE;
- }
-
- return EINA_TRUE;
-}
-
static void
_player_frame_resize(Emotion_Generic_Video *ev)
{
ev->pos = position;
_emotion_video_pos_update(ev->obj, ev->pos, ev->len);
-
+/* hmmm. no _emotion_progress_set() is for "buffering" progress.
if (ev->len == 0)
return;
snprintf(buf, sizeof(buf), "%0.1f%%", progress * 100);
_emotion_progress_set(ev->obj, buf, progress);
+ */
}
static void
}
static void
-_player_helper_str_read(Emotion_Generic_Video *ev, const char **pstr)
-{
- int len;
- char buf[PATH_MAX];
- if (_player_str_read(ev, buf, &len))
- *pstr = eina_stringshare_add_length(buf, len);
-}
-
-static void
_player_meta_info_free(Emotion_Generic_Video *ev)
{
eina_stringshare_replace(&ev->meta.title, NULL);
_player_file_closed(Emotion_Generic_Video *ev)
{
INF("Closed previous file.");
- sem_destroy(&ev->shared->lock);
-
+ eina_semaphore_free(&ev->shared->lock);
ev->closing = EINA_FALSE;
if (ev->opening)
_player_cmd_track_info(Emotion_Generic_Video *ev)
{
int param;
- Eina_Bool r;
int i;
if (ev->cmd.num_params == 0)
ECORE_EXE_PIPE_READ_LINE_BUFFERED | ECORE_EXE_NOT_LEADER,
ev);
- INF("created pipe emotion -> player: %d -> %d\n", pipe_out[1], pipe_out[0]);
- INF("created pipe player -> emotion: %d -> %d\n", pipe_in[1], pipe_in[0]);
+ INF("created pipe emotion -> player: %d -> %d", pipe_out[1], pipe_out[0]);
+ INF("created pipe player -> emotion: %d -> %d", pipe_in[1], pipe_in[0]);
close(pipe_in[1]);
close(pipe_out[0]);
}
static Eina_Bool
-_fork_and_exec(Evas_Object *obj, Emotion_Generic_Video *ev)
+_fork_and_exec(Evas_Object *obj __UNUSED__, Emotion_Generic_Video *ev)
{
char shmname[256];
struct timeval tv;
return ev->len;
}
+static double
+em_buffer_size_get(void *data __UNUSED__)
+{
+ return 1.0;
+}
+
static int
em_fps_num_get(void *data)
{
Emotion_Generic_Video *ev = data;
if (!ev || !ev->file_ready)
- return;
+ return 0;
// lock frame here
- sem_wait(&ev->shared->lock);
+ if (!eina_semaphore_lock(&ev->shared->lock))
+ return 0;
// send current frame to emotion
if (ev->shared->frame.emotion != ev->shared->frame.last)
ev->shared->frame_drop = 0;
// unlock frame here
- sem_post(&ev->shared->lock);
+ eina_semaphore_release(&ev->shared->lock, 1);
ev->drop = 0;
return 1;
em_size_get, /* size_get */
em_pos_set, /* pos_set */
em_len_get, /* len_get */
+ em_buffer_size_get, /* buffer_size_get */
em_fps_num_get, /* fps_num_get */
em_fps_den_get, /* fps_den_get */
em_fps_get, /* fps_get */