emotion/generic-vlc: Don't try to stop the player from event thread.
authorantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 23 Mar 2012 19:42:38 +0000 (19:42 +0000)
committerantognolli <antognolli@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 23 Mar 2012 19:42:38 +0000 (19:42 +0000)
Must send the command through the pipe so the main thread can stop it.

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

src/examples/emotion_generic_example.c
src/generic_players/vlc/emotion_generic_vlc.c

index 8710c54..53398c8 100644 (file)
@@ -18,6 +18,13 @@ _playback_started_cb(void *data, Evas_Object *o, void *event_info)
     printf("Emotion object started playback.\n");
 }
 
+static void
+_playback_stopped_cb(void *data, Evas_Object *o, void *event_info)
+{
+   emotion_object_play_set(o, EINA_FALSE);
+   emotion_object_position_set(o, 0);
+}
+
 static Evas_Object *
 _create_emotion_object(Evas *e)
 {
@@ -27,6 +34,8 @@ _create_emotion_object(Evas *e)
 
    evas_object_smart_callback_add(
        em, "playback_started", _playback_started_cb, NULL);
+   evas_object_smart_callback_add(
+       em, "playback_stopped", _playback_stopped_cb, NULL);
 
    return em;
 }
@@ -57,8 +66,11 @@ _on_key_down(void *data, Evas *e, Evas_Object *o, void *event_info)
      }
    else if (!strcmp(ev->keyname, "s"))
      {
-       fprintf(stderr, "skipping to position 60\n");
-       emotion_object_position_set(em, 60);
+        float len, pos;
+        len = emotion_object_play_length_get(em);
+        pos = 0.98 * len;
+       fprintf(stderr, "skipping to position %0.3f\n", pos);
+       emotion_object_position_set(em, pos);
      }
    else if (!strcmp(ev->keyname, "1"))
      {
index feecac3..266ae65 100644 (file)
@@ -23,6 +23,7 @@
 
 enum _Thread_Events {
      EM_THREAD_POSITION_CHANGED,
+     EM_THREAD_PLAYBACK_STOPPED,
      EM_THREAD_LAST
 };
 
@@ -367,7 +368,8 @@ _event_cb(const struct libvlc_event_t *ev, void *data)
         _send_file_set(app);
         break;
       case libvlc_MediaPlayerEndReached:
-        _send_cmd(app, EM_RESULT_PLAYBACK_STOPPED);
+        thread_event = EM_THREAD_PLAYBACK_STOPPED;
+        write(app->fd_write, &thread_event, sizeof(thread_event));
         break;
    }
 }
@@ -718,6 +720,11 @@ _process_thread_events(struct _App *app)
       case EM_THREAD_POSITION_CHANGED:
         _position_changed(app);
         break;
+      case EM_THREAD_PLAYBACK_STOPPED:
+         libvlc_media_player_stop(app->mp);
+         app->playing = 0;
+        _send_cmd(app, EM_RESULT_PLAYBACK_STOPPED);
+        break;
    }
 }