r2649 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . data src

njp at sita.openmoko.org njp at sita.openmoko.org
Mon Aug 6 16:41:04 CEST 2007


Author: njp
Date: 2007-08-06 16:41:01 +0200 (Mon, 06 Aug 2007)
New Revision: 2649

Added:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/default_ringtone.ogg
Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/Makefile.am
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
Log:
2007-08-06  Neil J. Patel  <njp at o-hand.com>

	* data/Makefile.am:
	Added a default ringtone (until sound themes are finished).

	* src/moko-notify.c: (on_filesrc_eos),
	(moko_notify_start_ringtone), (moko_notify_stop_ringtone),
	(moko_notify_start), (moko_notify_stop):
	Added some basic support for playing the default ringtone when there is an
	incoming call.

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-06 13:42:02 UTC (rev 2648)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-06 14:41:01 UTC (rev 2649)
@@ -1,5 +1,16 @@
 2007-08-06  Neil J. Patel  <njp at o-hand.com>
 
+	* data/Makefile.am:
+	Added a default ringtone (until sound themes are finished).
+
+	* src/moko-notify.c: (on_filesrc_eos),
+	(moko_notify_start_ringtone), (moko_notify_stop_ringtone),
+	(moko_notify_start), (moko_notify_stop):
+	Added some basic support for playing the default ringtone when there is an
+	incoming call.
+
+2007-08-06  Neil J. Patel  <njp at o-hand.com>
+
 	* src/moko-dialer.c: (on_call_progress_changed):
 	* src/moko-notify.c: (moko_notify_start), (moko_notify_stop),
 	(moko_notify_init):

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/Makefile.am
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/Makefile.am	2007-08-06 13:42:02 UTC (rev 2648)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/Makefile.am	2007-08-06 14:41:01 UTC (rev 2649)
@@ -34,7 +34,8 @@
                 talking_3.png\
                 exit.png\
 		connecting.png\
-		incall.png
+		incall.png\
+		default_ringtone.ogg
 #
 # desktop integration: .desktop file
 #

Added: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/default_ringtone.ogg
===================================================================
(Binary files differ)


Property changes on: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/data/default_ringtone.ogg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c	2007-08-06 13:42:02 UTC (rev 2648)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c	2007-08-06 14:41:01 UTC (rev 2649)
@@ -42,7 +42,9 @@
 
 struct _MokoNotifyPrivate
 {
-  gboolean started;
+  gboolean    started;
+
+  GstElement *bin;
 };
 /*
 enum
@@ -55,7 +57,96 @@
 static guint notify_signals[LAST_SIGNAL] = {0, };
 */
 
+
 static void
+on_filesrc_eos (GstElement *element, MokoNotify *notify)
+{
+  /* Rewind and play again */
+  g_print ("Audio finished\n");
+}
+
+static void
+moko_notify_start_ringtone (MokoNotify *notify)
+{
+  MokoNotifyPrivate *priv;
+  GstElement *bin, *filesrc, *decoder, *aconvert, *aresample, *asink;
+
+  g_return_if_fail (MOKO_IS_NOTIFY (notify));
+  priv = notify->priv;
+
+  /* Create a bin to hold elements */
+  bin = gst_pipeline_new ("pipeline");
+  g_assert (bin);
+
+  /* Disk reader */
+  filesrc = gst_element_factory_make ("filesrc", "source");
+  g_assert (filesrc);
+  g_object_set (G_OBJECT (filesrc), 
+                "location", PKGDATADIR DEFAULT_RINGTONE, 
+                NULL);
+  g_signal_connect (G_OBJECT (filesrc), "eos",
+                    G_CALLBACK (on_filesrc_eos), (gpointer)notify);
+
+  /* Decoder */
+  decoder = gst_element_factory_make ("decodebin", "decode");
+  if (!decoder)
+  {
+    g_warning ("Could not load 'decodebin'");
+    return;
+  }
+  
+  /* Audio convert */
+  aconvert = gst_element_factory_make ("audioconvert", NULL);
+  if (!aconvert)
+  {
+    g_warning ("Could not load 'audioconvert'");
+    return;
+  }
+
+  /* Audio resample */
+  aresample = gst_element_factory_make ("audioresample", NULL);
+  if (!aresample)
+  {
+    g_warning ("Could not load 'audioresample'");
+    return;
+  }
+
+  /* Audio sink */
+  asink = gst_element_factory_make ("alsasink", "play_audio");
+  if (!asink)
+  {
+    g_warning ("Could not load 'alsasink'");
+    return;
+  }
+
+  /* Add objects to the bin */
+  gst_bin_add_many (GST_BIN (bin), filesrc, decoder, 
+                    aconvert, aresample, asink, NULL);
+
+  /* Link the elements */
+  gst_element_link_many (filesrc, decoder, aconvert, aresample, asink, NULL);
+
+  priv->bin = bin;
+
+  /* Start playing */
+  gst_element_set_state (bin, GST_STATE_PLAYING);
+}
+
+static void
+moko_notify_stop_ringtone (MokoNotify *notify)
+{
+  MokoNotifyPrivate *priv;
+
+  g_return_if_fail (MOKO_IS_NOTIFY (notify));
+  priv = notify->priv;
+
+  if  (GST_IS_ELEMENT (priv->bin))
+  {
+    gst_element_set_state (priv->bin, GST_STATE_NULL);
+  }
+}
+
+static void
 moko_notify_start_vibrate (void)
 {
   gint fd;
@@ -132,7 +223,8 @@
     return;
   priv->started = TRUE;
 
-  moko_notify_start_vibrate (); 
+  moko_notify_start_vibrate ();
+  moko_notify_start_ringtone (notify);
 }
 
 /* Stop the ringtone and the vibration alert */
@@ -149,6 +241,7 @@
   priv->started = FALSE;
  
   moko_notify_stop_vibrate ();
+  moko_notify_stop_ringtone (notify);
 }
 
 /* GObject functions */





More information about the commitlog mailing list