[snappy/aurena: 5/5] handle eos messages from player into aurena client (ugly but works)



commit 2907447b89d4f303033e9ad80f216361f2f9a162
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Sun Sep 16 17:49:32 2012 +0100

    handle eos messages from player into aurena client (ugly but works)

 src/gst_engine.c  |    6 ++++--
 src/snappy.c      |    6 ++++--
 src/snra-client.c |    9 ++++-----
 src/snra-client.h |    3 +--
 4 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/src/gst_engine.c b/src/gst_engine.c
index 9cc9c73..e1be72b 100644
--- a/src/gst_engine.c
+++ b/src/gst_engine.c
@@ -27,6 +27,7 @@
 #include "user_interface.h"
 #include "gst_engine.h"
 #include "utils.h"
+#include "snra-client.h"
 
 #define SAVE_POSITION_MIN_DURATION 300 * 1000   // don't save >5 minute files
 #define SAVE_POSITION_THRESHOLD 0.05    // percentage threshold
@@ -463,7 +464,8 @@ at_the_eos (GstEngine * engine)
 gboolean
 bus_call (GstBus * bus, GstMessage * msg, gpointer data)
 {
-  UserInterface *ui = (UserInterface *) data;
+  SnraClient *client = (SnraClient *) data;
+  UserInterface *ui = client->ui;
   GstEngine *engine = ui->engine;
 
   switch (GST_MESSAGE_TYPE (msg)) {
@@ -519,7 +521,7 @@ bus_call (GstBus * bus, GstMessage * msg, gpointer data)
     case GST_MESSAGE_EOS:
     {
       GST_DEBUG ("End of stream");
-      stream_done (engine, ui);
+      on_eos_msg (client);
 
       break;
     }
diff --git a/src/snappy.c b/src/snappy.c
index 1ccbb9a..74aec8b 100644
--- a/src/snappy.c
+++ b/src/snappy.c
@@ -41,6 +41,8 @@
 #include "gst_engine.h"
 #include "utils.h"
 
+#include "snra-client.h"
+
 
 /*               Close snappy down               */
 void
@@ -153,7 +155,7 @@ process_args (int argc, char *argv[],
 
 /*            snappy's main function             */
 UserInterface *
-snappy_construct ()
+snappy_construct (SnraClient *client)
 {
   GstEngine *engine = NULL;
   ClutterActor *video_texture;
@@ -223,7 +225,7 @@ snappy_construct ()
   ui->engine = engine;
   ui->texture = video_texture;
 
-  gst_bus_add_watch (engine->bus, bus_call, ui);
+  gst_bus_add_watch (engine->bus, bus_call, client);
   gst_object_unref (engine->bus);
 
   return ui;
diff --git a/src/snra-client.c b/src/snra-client.c
index 64d1da4..40bb041 100644
--- a/src/snra-client.c
+++ b/src/snra-client.c
@@ -121,7 +121,7 @@ handle_enrol_message (SnraClient * client, GstStructure * s)
 
   if (snra_json_structure_get_double (s, "volume-level", &new_vol)) {
     if (client->ui == NULL)
-      client->ui = snappy_construct ();
+      client->ui = snappy_construct (client);
 
     engine_volume (client->ui->engine, new_vol);
   }
@@ -172,9 +172,8 @@ handle_enrol_message (SnraClient * client, GstStructure * s)
   }
 }
 
-static void
-on_eos_msg (G_GNUC_UNUSED GstBus * bus, G_GNUC_UNUSED GstMessage * msg,
-    SnraClient * client)
+void
+on_eos_msg (SnraClient * client)
 {
   SoupMessage *soup_msg;
   /* FIXME: Next song should all be handled server side */
@@ -237,7 +236,7 @@ handle_set_media_message (SnraClient * client, GstStructure * s)
       GST_TIME_ARGS (base_time));
  
   if (client->state == GST_STATE_NULL) {
-    client->ui = snappy_construct ();
+    client->ui = snappy_construct (client);
     engine_load_uri (client->ui->engine, uri);
     interface_start (client->ui, uri);
     client->state = GST_STATE_READY;
diff --git a/src/snra-client.h b/src/snra-client.h
index 6dce2f3..b220618 100644
--- a/src/snra-client.h
+++ b/src/snra-client.h
@@ -36,8 +36,6 @@ struct _SnraClient
   SoupSession *soup;
   JsonParser *json;
 
-  // GstElement *player;
-
   guint timeout;
 
   gboolean connecting;
@@ -59,6 +57,7 @@ struct _SnraClientClass
 
 GType snra_client_get_type(void);
 SnraClient *snra_client_new(const gchar *server);
+void on_eos_msg (SnraClient * client);
 
 G_END_DECLS
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]