emotion/generic - Set filename to NULL on file_close.
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Sep 2011 16:37:20 +0000 (16:37 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 5 Sep 2011 16:37:20 +0000 (16:37 +0000)
Otherwise if we try to call file_set(<some file>) after file_set(NULL),
it will send a close command to the player for an already closed file.

Also make the example cycle through the list of movies, but still
passing through a NULL file when reaching one of the ends of the list.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/emotion@63208 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/examples/emotion_generic_example.c
src/modules/generic/emotion_generic.c

index 2eb8eef..33c1686 100644 (file)
@@ -72,7 +72,10 @@ _on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
    else if (!strcmp(ev->keyname, "n"))
      {
        const char *file;
-       curfile = eina_list_next(curfile);
+       if (!curfile)
+         curfile = filenames;
+       else
+         curfile = eina_list_next(curfile);
        file = eina_list_data_get(curfile);
        fprintf(stderr, "playing next file: %s\n", file);
        emotion_object_file_set(em, file);
@@ -80,7 +83,10 @@ _on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
    else if (!strcmp(ev->keyname, "p"))
      {
        const char *file;
-       curfile = eina_list_prev(curfile);
+       if (!curfile)
+         curfile = eina_list_last(filenames);
+       else
+         curfile = eina_list_prev(curfile);
        file = eina_list_data_get(curfile);
        fprintf(stderr, "playing next file: %s\n", file);
        emotion_object_file_set(em, file);
index bc4b447..e3aaa27 100644 (file)
@@ -200,7 +200,7 @@ _file_open(Emotion_Generic_Video *ev)
    INF("Opening file: %s", ev->filename);
    ev->drop = 0;
 
-   if (!ev->ready)
+   if (!ev->ready || !ev->filename)
      return;
    _player_send_cmd(ev, EM_CMD_FILE_SET);
    _player_send_str(ev, ev->filename, EINA_TRUE);
@@ -801,11 +801,11 @@ em_file_close(void *data)
 {
    Emotion_Generic_Video *ev = data;
 
-   if (!ev) return;
+   if (!ev || !ev->filename) return;
+
    INF("file close: %s", ev->filename);
 
-   if (!ev->filename)
-     return;
+   eina_stringshare_replace(&ev->filename, NULL);
 
    if (ev->opening)
      return;