forked from enlightenment/efl
emotion/generic: Fix frame dropping.
Move the frame drop counter to the shared memory object, so the player can check its value and not send new frames if we didn't "consume" the previous one. Also move the triple buffering pointer changing to the display function, so it will only lock once when accessing the critical region. SVN revision: 63220
This commit is contained in:
parent
0d7da38f05
commit
4be7a99b94
|
@ -95,6 +95,11 @@ _on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
|
|||
{
|
||||
evas_object_del(em);
|
||||
}
|
||||
else if (!strcmp(ev->keyname, "l"))
|
||||
{
|
||||
// force frame dropping
|
||||
sleep(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unhandled key: %s\n", ev->keyname);
|
||||
|
|
|
@ -253,17 +253,6 @@ _lock(void *data, void **pixels)
|
|||
static void
|
||||
_unlock(void *data, void *id, void *const *pixels)
|
||||
{
|
||||
struct _App *app = data;
|
||||
|
||||
if (!app->playing)
|
||||
return;
|
||||
|
||||
sem_wait(&app->vs->lock);
|
||||
app->vs->frame.last = app->vs->frame.player;
|
||||
app->vs->frame.player = app->vs->frame.next;
|
||||
app->vs->frame.next = app->vs->frame.last;
|
||||
|
||||
sem_post(&app->vs->lock);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -273,7 +262,13 @@ _display(void *data, void *id)
|
|||
if (!app->playing)
|
||||
return;
|
||||
|
||||
_send_cmd(app, EM_RESULT_FRAME_NEW);
|
||||
sem_wait(&app->vs->lock);
|
||||
app->vs->frame.last = app->vs->frame.player;
|
||||
app->vs->frame.player = app->vs->frame.next;
|
||||
app->vs->frame.next = app->vs->frame.last;
|
||||
if (!app->vs->frame_drop++)
|
||||
_send_cmd(app, EM_RESULT_FRAME_NEW);
|
||||
sem_post(&app->vs->lock);
|
||||
}
|
||||
|
||||
static void *
|
||||
|
|
|
@ -89,6 +89,7 @@ struct _Emotion_Generic_Video_Shared
|
|||
int next;
|
||||
} frame;
|
||||
sem_t lock;
|
||||
int frame_drop;
|
||||
};
|
||||
|
||||
inline int
|
||||
|
|
|
@ -173,6 +173,7 @@ _create_shm_data(Emotion_Generic_Video *ev, const char *shmname)
|
|||
vs->frame.player = 1;
|
||||
vs->frame.last = 2;
|
||||
vs->frame.next = 2;
|
||||
vs->frame_drop = 0;
|
||||
sem_init(&vs->lock, 1, 1);
|
||||
ev->frame.frames[0] = (unsigned char *)vs + sizeof(*vs);
|
||||
ev->frame.frames[1] = (unsigned char *)vs + sizeof(*vs) + vs->height * vs->width * vs->pitch;
|
||||
|
@ -190,8 +191,7 @@ _player_new_frame(Emotion_Generic_Video *ev)
|
|||
{
|
||||
if (ev->opening || ev->closing)
|
||||
return;
|
||||
if (!ev->drop++)
|
||||
_emotion_frame_new(ev->obj);
|
||||
_emotion_frame_new(ev->obj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1103,6 +1103,10 @@ em_bgra_data_get(void *data, unsigned char **bgra_data)
|
|||
}
|
||||
*bgra_data = ev->frame.frames[ev->shared->frame.emotion];
|
||||
|
||||
if (ev->shared->frame_drop > 1)
|
||||
WRN("dropped frames: %d", ev->shared->frame_drop - 1);
|
||||
ev->shared->frame_drop = 0;
|
||||
|
||||
// unlock frame here
|
||||
sem_post(&ev->shared->lock);
|
||||
ev->drop = 0;
|
||||
|
|
Loading…
Reference in New Issue