[maemo-commits] [maemo-commits] r17836 - projects/haf/trunk/hildon-welcome/src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Fri Mar 27 14:30:37 EET 2009
Author: schulhof
Date: 2009-03-27 14:30:29 +0200 (Fri, 27 Mar 2009)
New Revision: 17836

Modified:
   projects/haf/trunk/hildon-welcome/src/tmp.c
Log:


Modified: projects/haf/trunk/hildon-welcome/src/tmp.c
===================================================================
--- projects/haf/trunk/hildon-welcome/src/tmp.c	2009-03-27 12:29:01 UTC (rev 17835)
+++ projects/haf/trunk/hildon-welcome/src/tmp.c	2009-03-27 12:30:29 UTC (rev 17836)
@@ -42,24 +42,25 @@
 }
 
 static void
-do_everything(GstElement *pipeline, int argc, char **argv, GstElement *audiosink)
+play_file(GstElement *pipeline, char *filename, GstElement *audiosink)
 {
   GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
 
+  g_print("play_file: Entering with \"%s\"\n", filename);
+
   if (bus) {
     gboolean keep_looping = TRUE;
-    static int current_logo = 1;
     GstMessage *msg = NULL;
     GstElement *new_bin = NULL;
 
-    new_bin = create_bin(argv[current_logo++], audiosink);
+    new_bin = create_bin(filename, audiosink);
     gst_bin_add(GST_BIN(pipeline), new_bin);
     gst_element_set_state(pipeline, GST_STATE_PAUSED);
     gst_element_send_event(pipeline,
       gst_event_new_seek(1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET, G_GUINT64_CONSTANT(0), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE));
     gst_element_set_state(pipeline, GST_STATE_PLAYING);
 
-    g_print("do_everything: Entering loop\n");
+    g_print("play_file: Entering loop\n");
 
     while (keep_looping) {
       msg = gst_bus_poll(bus, GST_MESSAGE_ANY, -1);
@@ -74,75 +75,22 @@
             gst_message_parse_error(msg, &err, &debug);
 
             if (err) {
-              g_print("do_everything: error: %s, debug: %s\n", err->message ? err->message : "?", debug ? debug : "?");
+              g_print("play_file: error: %s, debug: %s\n", err->message ? err->message : "?", debug ? debug : "?");
               g_error_free(err);
               err = NULL;
             }
             g_free(debug);
             debug = NULL;;
           }
-          break;
-
-        case GST_MESSAGE_EOS:
-          g_print("do_everything: EOS\n");
-          break;
-
-        case GST_MESSAGE_SEGMENT_START:
-          g_print("do_everything: SEGMENT_START\n");
-          break;
-
+          /* fall through */
         case GST_MESSAGE_SEGMENT_DONE:
-          g_print("do_everything: SEGMENT_DONE\n");
+          g_print("play_file: SEGMENT_DONE\n");
           gst_element_set_locked_state(new_bin, TRUE);
           gst_element_set_state(new_bin, GST_STATE_NULL);
           gst_bin_remove(GST_BIN(pipeline), new_bin);
-
-          if (current_logo == argc)
-            keep_looping = FALSE;
-          else {
-            new_bin = create_bin(argv[current_logo++], audiosink);
-            gst_bin_add(GST_BIN(pipeline), new_bin);
-            gst_element_set_state(pipeline, GST_STATE_PAUSED);
-            gst_element_send_event(pipeline,
-              gst_event_new_seek(1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET, G_GUINT64_CONSTANT(0), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE));
-            gst_element_set_state(pipeline, GST_STATE_PLAYING);
-          }
+          keep_looping = FALSE;
           break;
 
-        case GST_MESSAGE_STATE_CHANGED:
-          if (GST_MESSAGE_SRC(msg) == GST_OBJECT(pipeline)) {
-            GstState oldstate, newstate, pending;
-            gst_message_parse_state_changed(msg, &oldstate, &newstate, &pending);
-            g_print("do_everything: STATE_CHANGED for %s: old = %s, new = %s, pending = %s\n", 
-              gst_element_get_name(GST_MESSAGE_SRC(msg)), 
-              GST_STATE_NAME(oldstate),
-              GST_STATE_NAME(newstate),
-              GST_STATE_NAME(pending));
-          }
-          break;
-#if (0)
-          if (GST_MESSAGE_SRC(msg) == GST_OBJECT(pipeline)) {
-            GstState oldstate, newstate, pending;
-            gst_message_parse_state_changed(msg, &oldstate, &newstate, &pending);
-            if (GST_STATE_PLAYING == oldstate && GST_STATE_PAUSED == newstate) {
-              gst_element_set_locked_state(new_bin, TRUE);
-              gst_element_set_state(new_bin, GST_STATE_NULL);
-              gst_bin_remove(GST_BIN(pipeline), new_bin);
-
-              if (current_logo == argc)
-                keep_looping = FALSE;
-              else {
-                new_bin = create_bin(argv[current_logo++], audiosink);
-                gst_bin_add(GST_BIN(pipeline), new_bin);
-                gst_element_send_event(pipeline,
-                  gst_event_new_seek(1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET, G_GUINT64_CONSTANT(0), GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE));
-                gst_element_set_state(pipeline, GST_STATE_PLAYING);
-              }
-            }
-          }
-#endif /* (0) */
-          break;
-
         default:
           break;
       }
@@ -150,11 +98,14 @@
       gst_message_unref(msg);
     }
   }
+
+  g_print("play_file: === Exiting with \"%s\"\n", filename);
 }
 
 int
 main(int argc, char **argv)
 {
+  int Nix;
   GstElement *pipeline = NULL, *audiosink;
   gst_init(&argc, &argv);
 
@@ -162,7 +113,8 @@
     if ((pipeline = gst_pipeline_new("sequence-player"))) {
       audiosink = gst_element_factory_make("autoaudiosink", "the-audio-sink");
       gst_bin_add(GST_BIN(pipeline), audiosink);
-      do_everything(pipeline, argc, argv, audiosink);
+      for (Nix = 1 ; Nix < argc ; Nix++)
+        play_file(pipeline, argv[Nix], audiosink);
       gst_element_set_state(pipeline, GST_STATE_NULL);
       gst_object_unref(pipeline);
     }


More information about the maemo-commits mailing list